Suppression dossier backup
This commit is contained in:
parent
c2e129c9c9
commit
dc5ad4f07e
27 changed files with 0 additions and 11469 deletions
|
@ -1,31 +0,0 @@
|
||||||
" Preserve existing doge settings.
|
|
||||||
let b:doge_patterns = get(b:, 'doge_patterns', {})
|
|
||||||
let b:doge_supported_doc_standards = get(b:, 'doge_supported_doc_standards', [])
|
|
||||||
if index(b:doge_supported_doc_standards, 'javadoc') < 0
|
|
||||||
call add(b:doge_supported_doc_standards, 'javadoc')
|
|
||||||
endif
|
|
||||||
|
|
||||||
" DoGe uses these patterns to identify comments, change if needed.
|
|
||||||
let b:doge_pattern_single_line_comment = '\m\/\*.\{-}\*\/$'
|
|
||||||
let b:doge_pattern_multi_line_comment = '\m\/\*.\{-}\*\/$'
|
|
||||||
|
|
||||||
" Set the new doc standard as default.
|
|
||||||
let b:doge_doc_standard = 'javadoc'
|
|
||||||
|
|
||||||
" Ensure we do not overwrite an existing doc standard.
|
|
||||||
if !has_key(b:doge_patterns, 'javadoc')
|
|
||||||
let b:doge_patterns['javadoc'] = [
|
|
||||||
\ {
|
|
||||||
\ 'match': '',
|
|
||||||
\ 'tokens': ['parameters'],
|
|
||||||
\ 'parameters': {
|
|
||||||
\ 'match': '',
|
|
||||||
\ 'tokens': '',
|
|
||||||
\ 'format': '',
|
|
||||||
\ },
|
|
||||||
\ 'insert': 'above',
|
|
||||||
\ 'template': [
|
|
||||||
\ ],
|
|
||||||
\ },
|
|
||||||
\]
|
|
||||||
endif
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 811fcff1526f330e87f3d7663fe60588b22e5dd8
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,11 +0,0 @@
|
||||||
let s:exists = {}
|
|
||||||
function! emmet#lang#exists(type) abort
|
|
||||||
if len(a:type) == 0
|
|
||||||
return 0
|
|
||||||
elseif has_key(s:exists, a:type)
|
|
||||||
return s:exists[a:type]
|
|
||||||
endif
|
|
||||||
let s:exists[a:type] = len(globpath(&rtp, 'autoload/emmet/lang/'.a:type.'.vim')) > 0
|
|
||||||
return s:exists[a:type]
|
|
||||||
endfunction
|
|
||||||
|
|
|
@ -1,346 +0,0 @@
|
||||||
function! emmet#lang#css#findTokens(str) abort
|
|
||||||
let tmp = substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '')
|
|
||||||
if tmp =~ '/' && tmp =~ '^[a-zA-Z0-9/_.]\+$'
|
|
||||||
" maybe path or something
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
return substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#css#parseIntoTree(abbr, type) abort
|
|
||||||
let abbr = a:abbr
|
|
||||||
let type = a:type
|
|
||||||
let prefix = 0
|
|
||||||
let value = ''
|
|
||||||
|
|
||||||
let indent = emmet#getIndentation(type)
|
|
||||||
let aliases = emmet#getResource(type, 'aliases', {})
|
|
||||||
let snippets = emmet#getResource(type, 'snippets', {})
|
|
||||||
let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
|
|
||||||
|
|
||||||
let root = emmet#newNode()
|
|
||||||
|
|
||||||
" emmet
|
|
||||||
let tokens = split(abbr, '+\ze[^+)!]')
|
|
||||||
let block = emmet#util#searchRegion('{', '}')
|
|
||||||
if abbr !~# '^@' && emmet#getBaseType(type) ==# 'css' && type !=# 'sass' && block[0] ==# [0,0] && block[1] ==# [0,0]
|
|
||||||
let current = emmet#newNode()
|
|
||||||
let current.snippet = substitute(abbr, '\s\+$', '', '') . " {\n" . indent . "${cursor}\n}"
|
|
||||||
let current.name = ''
|
|
||||||
call add(root.child, deepcopy(current))
|
|
||||||
else
|
|
||||||
for n in range(len(tokens))
|
|
||||||
let token = tokens[n]
|
|
||||||
let prop = matchlist(token, '^\(-\{0,1}[a-zA-Z]\+\|[a-zA-Z0-9]\++\{0,1}\|([a-zA-Z0-9]\++\{0,1})\)\(\%([0-9.-]\+\%(p\|e\|em\|re\|rem\|%\)\{0,1}-\{0,1}\|-auto\)*\)$')
|
|
||||||
if len(prop)
|
|
||||||
let token = substitute(prop[1], '^(\(.*\))', '\1', '')
|
|
||||||
if token =~# '^-'
|
|
||||||
let prefix = 1
|
|
||||||
let token = token[1:]
|
|
||||||
endif
|
|
||||||
let value = ''
|
|
||||||
for v in split(prop[2], '\d\zs-')
|
|
||||||
if len(value) > 0
|
|
||||||
let value .= ' '
|
|
||||||
endif
|
|
||||||
if token =~# '^[z]'
|
|
||||||
" TODO
|
|
||||||
let value .= substitute(v, '[^0-9.]*$', '', '')
|
|
||||||
elseif v =~# 'p$'
|
|
||||||
let value .= substitute(v, 'p$', '%', '')
|
|
||||||
elseif v =~# '%$'
|
|
||||||
let value .= v
|
|
||||||
elseif v =~# 'e$'
|
|
||||||
let value .= substitute(v, 'e$', 'em', '')
|
|
||||||
elseif v =~# 'em$'
|
|
||||||
let value .= v
|
|
||||||
elseif v =~# 're$'
|
|
||||||
let value .= substitute(v, 're$', 'rem', '')
|
|
||||||
elseif v =~# 'rem$'
|
|
||||||
let value .= v
|
|
||||||
elseif v =~# '\.'
|
|
||||||
let value .= v . 'em'
|
|
||||||
elseif v ==# 'auto'
|
|
||||||
let value .= v
|
|
||||||
elseif v ==# '0'
|
|
||||||
let value .= '0'
|
|
||||||
else
|
|
||||||
let value .= v . 'px'
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
let tag_name = token
|
|
||||||
if tag_name =~# '.!$'
|
|
||||||
let tag_name = tag_name[:-2]
|
|
||||||
let important = 1
|
|
||||||
else
|
|
||||||
let important = 0
|
|
||||||
endif
|
|
||||||
" make default node
|
|
||||||
let current = emmet#newNode()
|
|
||||||
let current.important = important
|
|
||||||
let current.name = tag_name
|
|
||||||
|
|
||||||
" aliases
|
|
||||||
if has_key(aliases, tag_name)
|
|
||||||
let current.name = aliases[tag_name]
|
|
||||||
endif
|
|
||||||
|
|
||||||
" snippets
|
|
||||||
if !empty(snippets)
|
|
||||||
let snippet_name = tag_name
|
|
||||||
if !has_key(snippets, snippet_name)
|
|
||||||
let pat = '^' . join(split(tag_name, '\zs'), '\%(\|[^:-]\+-\)')
|
|
||||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
|
||||||
if len(vv) > 0
|
|
||||||
let snippet_name = vv[0]
|
|
||||||
else
|
|
||||||
let pat = '^' . join(split(tag_name, '\zs'), '\%(\|[^:-]\+-*\)')
|
|
||||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
|
||||||
if len(vv) == 0
|
|
||||||
let pat = '^' . join(split(tag_name, '\zs'), '[^:]\{-}')
|
|
||||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
|
||||||
if len(vv) == 0
|
|
||||||
let pat = '^' . join(split(tag_name, '\zs'), '.\{-}')
|
|
||||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let minl = -1
|
|
||||||
for vk in vv
|
|
||||||
let vvs = snippets[vk]
|
|
||||||
if minl == -1 || len(vvs) < minl
|
|
||||||
let snippet_name = vk
|
|
||||||
let minl = len(vvs)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if has_key(snippets, snippet_name)
|
|
||||||
let snippet = snippets[snippet_name]
|
|
||||||
if use_pipe_for_cursor
|
|
||||||
let snippet = substitute(snippet, '|', '${cursor}', 'g')
|
|
||||||
endif
|
|
||||||
let lines = split(snippet, "\n")
|
|
||||||
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
|
|
||||||
let current.snippet = join(lines, "\n")
|
|
||||||
let current.name = ''
|
|
||||||
let current.snippet = substitute(current.snippet, ';', value . ';', '')
|
|
||||||
if use_pipe_for_cursor && len(value) > 0
|
|
||||||
let current.snippet = substitute(current.snippet, '\${cursor}', '', 'g')
|
|
||||||
endif
|
|
||||||
if n < len(tokens) - 1
|
|
||||||
let current.snippet .= "\n"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
let current.pos = 0
|
|
||||||
let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$')
|
|
||||||
if len(lg) == 0
|
|
||||||
let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*)$')
|
|
||||||
if len(lg)
|
|
||||||
let [lg[1], lg[2], lg[3]] = ['linear', lg[1], lg[2]]
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if len(lg)
|
|
||||||
let current.name = ''
|
|
||||||
let current.snippet = printf("background-image:-webkit-gradient(%s, 0 0, 0 100%, from(%s), to(%s));\n", lg[1], lg[2], lg[3])
|
|
||||||
call add(root.child, deepcopy(current))
|
|
||||||
let current.snippet = printf("background-image:-webkit-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
|
||||||
call add(root.child, deepcopy(current))
|
|
||||||
let current.snippet = printf("background-image:-moz-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
|
||||||
call add(root.child, deepcopy(current))
|
|
||||||
let current.snippet = printf("background-image:-o-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
|
||||||
call add(root.child, deepcopy(current))
|
|
||||||
let current.snippet = printf("background-image:linear-gradient(%s, %s);\n", lg[2], lg[3])
|
|
||||||
call add(root.child, deepcopy(current))
|
|
||||||
elseif prefix
|
|
||||||
let snippet = current.snippet
|
|
||||||
let current.snippet = '-webkit-' . snippet . "\n"
|
|
||||||
call add(root.child, deepcopy(current))
|
|
||||||
let current.snippet = '-moz-' . snippet . "\n"
|
|
||||||
call add(root.child, deepcopy(current))
|
|
||||||
let current.snippet = snippet
|
|
||||||
call add(root.child, current)
|
|
||||||
elseif token =~# '^c#\([0-9a-fA-F]\{3}\|[0-9a-fA-F]\{6}\)\(\.[0-9]\+\)\?'
|
|
||||||
let cs = split(token, '\.')
|
|
||||||
let current.name = ''
|
|
||||||
let [r,g,b] = [0,0,0]
|
|
||||||
if len(cs[0]) == 5
|
|
||||||
let rgb = matchlist(cs[0], 'c#\(.\)\(.\)\(.\)')
|
|
||||||
let r = eval('0x'.rgb[1].rgb[1])
|
|
||||||
let g = eval('0x'.rgb[2].rgb[2])
|
|
||||||
let b = eval('0x'.rgb[3].rgb[3])
|
|
||||||
elseif len(cs[0]) == 8
|
|
||||||
let rgb = matchlist(cs[0], 'c#\(..\)\(..\)\(..\)')
|
|
||||||
let r = eval('0x'.rgb[1])
|
|
||||||
let g = eval('0x'.rgb[2])
|
|
||||||
let b = eval('0x'.rgb[3])
|
|
||||||
endif
|
|
||||||
if len(cs) == 1
|
|
||||||
let current.snippet = printf('color:rgb(%d, %d, %d);', r, g, b)
|
|
||||||
else
|
|
||||||
let current.snippet = printf('color:rgb(%d, %d, %d, %s);', r, g, b, string(str2float('0.'.cs[1])))
|
|
||||||
endif
|
|
||||||
call add(root.child, current)
|
|
||||||
elseif token =~# '^c#'
|
|
||||||
let current.name = ''
|
|
||||||
let current.snippet = 'color:\${cursor};'
|
|
||||||
call add(root.child, current)
|
|
||||||
else
|
|
||||||
call add(root.child, current)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
return root
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent) abort
|
|
||||||
let current = a:current
|
|
||||||
let value = current.value[1:-2]
|
|
||||||
let tmp = substitute(value, '\${cursor}', '', 'g')
|
|
||||||
if tmp !~ '.*{[ \t\r\n]*}$'
|
|
||||||
if emmet#useFilter(a:filters, 'fc')
|
|
||||||
let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1: \2', 'g')
|
|
||||||
else
|
|
||||||
let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1:\2', 'g')
|
|
||||||
endif
|
|
||||||
if current.important
|
|
||||||
let value = substitute(value, ';', ' !important;', '')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
return value
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#css#imageSize() abort
|
|
||||||
let img_region = emmet#util#searchRegion('{', '}')
|
|
||||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let content = emmet#util#getContent(img_region)
|
|
||||||
let fn = matchstr(content, '\<url(\zs[^)]\+\ze)')
|
|
||||||
let fn = substitute(fn, '[''" \t]', '', 'g')
|
|
||||||
if fn =~# '^\s*$'
|
|
||||||
return
|
|
||||||
elseif fn !~# '^\(/\|http\)'
|
|
||||||
let fn = simplify(expand('%:h') . '/' . fn)
|
|
||||||
endif
|
|
||||||
let [width, height] = emmet#util#getImageSize(fn)
|
|
||||||
if width == -1 && height == -1
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let indent = emmet#getIndentation('css')
|
|
||||||
if content =~# '.*\<width\s*:[^;]*;.*'
|
|
||||||
let content = substitute(content, '\<width\s*:[^;]*;', 'width: ' . width . 'px;', '')
|
|
||||||
else
|
|
||||||
let content = substitute(content, '}', indent . 'width: ' . width . "px;\n}", '')
|
|
||||||
endif
|
|
||||||
if content =~# '.*\<height\s*:[^;]*;.*'
|
|
||||||
let content = substitute(content, '\<height\s*:[^;]*;', 'height: ' . height . 'px;', '')
|
|
||||||
else
|
|
||||||
let content = substitute(content, '}', indent . 'height: ' . height . "px;\n}", '')
|
|
||||||
endif
|
|
||||||
call emmet#util#setContent(img_region, content)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#css#encodeImage() abort
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#css#parseTag(tag) abort
|
|
||||||
return {}
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#css#toggleComment() abort
|
|
||||||
let line = getline('.')
|
|
||||||
let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$'
|
|
||||||
if line =~# '{\s*$'
|
|
||||||
let block = emmet#util#searchRegion('/\*', '\*/\zs')
|
|
||||||
if emmet#util#regionIsValid(block)
|
|
||||||
let content = emmet#util#getContent(block)
|
|
||||||
let content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '')
|
|
||||||
call emmet#util#setContent(block, content)
|
|
||||||
else
|
|
||||||
let node = expand('<cword>')
|
|
||||||
if len(node)
|
|
||||||
exe "normal ciw\<c-r>='/* '.node.' */'\<cr>"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
if line =~# mx
|
|
||||||
let space = substitute(matchstr(line, mx), mx, '\1', '')
|
|
||||||
let line = substitute(matchstr(line, mx), mx, '\2', '')
|
|
||||||
let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g')
|
|
||||||
else
|
|
||||||
let mx = '^\(\s*\)\(.*\)\s*$'
|
|
||||||
let line = substitute(line, mx, '\1/* \2 */', '')
|
|
||||||
endif
|
|
||||||
call setline('.', line)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#css#balanceTag(flag) range abort
|
|
||||||
if a:flag == -2 || a:flag == 2
|
|
||||||
let curpos = [0, line("'<"), col("'<"), 0]
|
|
||||||
else
|
|
||||||
let curpos = emmet#util#getcurpos()
|
|
||||||
endif
|
|
||||||
let block = emmet#util#getVisualBlock()
|
|
||||||
if !emmet#util#regionIsValid(block)
|
|
||||||
if a:flag > 0
|
|
||||||
let block = emmet#util#searchRegion('^', ';')
|
|
||||||
if emmet#util#regionIsValid(block)
|
|
||||||
call emmet#util#selectRegion(block)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
if a:flag > 0
|
|
||||||
let content = emmet#util#getContent(block)
|
|
||||||
if content !~# '^{.*}$'
|
|
||||||
let block = emmet#util#searchRegion('{', '}')
|
|
||||||
if emmet#util#regionIsValid(block)
|
|
||||||
call emmet#util#selectRegion(block)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let pos = searchpos('.*;', 'nW')
|
|
||||||
if pos[0] != 0
|
|
||||||
call setpos('.', [0, pos[0], pos[1], 0])
|
|
||||||
let block = emmet#util#searchRegion('^', ';')
|
|
||||||
if emmet#util#regionIsValid(block)
|
|
||||||
call emmet#util#selectRegion(block)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if a:flag == -2 || a:flag == 2
|
|
||||||
silent! exe 'normal! gv'
|
|
||||||
else
|
|
||||||
call setpos('.', curpos)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#css#moveNextPrevItem(flag) abort
|
|
||||||
return emmet#lang#css#moveNextPrev(a:flag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#css#moveNextPrev(flag) abort
|
|
||||||
let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp')
|
|
||||||
if pos == 2
|
|
||||||
startinsert!
|
|
||||||
else
|
|
||||||
silent! normal! l
|
|
||||||
startinsert
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#css#splitJoinTag() abort
|
|
||||||
" nothing to do
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#css#removeTag() abort
|
|
||||||
" nothing to do
|
|
||||||
endfunction
|
|
|
@ -1,335 +0,0 @@
|
||||||
function! emmet#lang#haml#findTokens(str) abort
|
|
||||||
return emmet#lang#html#findTokens(a:str)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#haml#parseIntoTree(abbr, type) abort
|
|
||||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent) abort
|
|
||||||
let settings = a:settings
|
|
||||||
let current = a:current
|
|
||||||
let type = a:type
|
|
||||||
let inline = a:inline
|
|
||||||
let filters = a:filters
|
|
||||||
let itemno = a:itemno
|
|
||||||
let indent = emmet#getIndentation(type)
|
|
||||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
|
||||||
let attribute_style = emmet#getResource('haml', 'attribute_style', 'hash')
|
|
||||||
let str = ''
|
|
||||||
|
|
||||||
let current_name = current.name
|
|
||||||
if dollar_expr
|
|
||||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
|
||||||
endif
|
|
||||||
if len(current.name) > 0
|
|
||||||
let str .= '%' . current_name
|
|
||||||
let tmp = ''
|
|
||||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
|
||||||
if !has_key(current.attr, attr)
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
let Val = current.attr[attr]
|
|
||||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
|
||||||
if attribute_style ==# 'hash'
|
|
||||||
let tmp .= ' :' . attr . ' => true'
|
|
||||||
elseif attribute_style ==# 'html'
|
|
||||||
let tmp .= attr . '=true'
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if dollar_expr
|
|
||||||
while Val =~# '\$\([^#{]\|$\)'
|
|
||||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
endwhile
|
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
|
||||||
endif
|
|
||||||
let valtmp = substitute(Val, '\${cursor}', '', '')
|
|
||||||
if attr ==# 'id' && len(valtmp) > 0
|
|
||||||
let str .= '#' . Val
|
|
||||||
elseif attr ==# 'class' && len(valtmp) > 0
|
|
||||||
let str .= '.' . substitute(Val, ' ', '.', 'g')
|
|
||||||
else
|
|
||||||
if len(tmp) > 0
|
|
||||||
if attribute_style ==# 'hash'
|
|
||||||
let tmp .= ','
|
|
||||||
elseif attribute_style ==# 'html'
|
|
||||||
let tmp .= ' '
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let Val = substitute(Val, '\${cursor}', '', '')
|
|
||||||
if attribute_style ==# 'hash'
|
|
||||||
let tmp .= ' :' . attr . ' => "' . Val . '"'
|
|
||||||
elseif attribute_style ==# 'html'
|
|
||||||
let tmp .= attr . '="' . Val . '"'
|
|
||||||
end
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
if len(tmp)
|
|
||||||
if attribute_style ==# 'hash'
|
|
||||||
let str .= '{' . tmp . ' }'
|
|
||||||
elseif attribute_style ==# 'html'
|
|
||||||
let str .= '(' . tmp . ')'
|
|
||||||
end
|
|
||||||
endif
|
|
||||||
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0
|
|
||||||
let str .= '/'
|
|
||||||
endif
|
|
||||||
|
|
||||||
let inner = ''
|
|
||||||
if len(current.value) > 0
|
|
||||||
let text = current.value[1:-2]
|
|
||||||
if dollar_expr
|
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
|
||||||
let str = substitute(str, '\$#', text, 'g')
|
|
||||||
endif
|
|
||||||
let lines = split(text, "\n")
|
|
||||||
if len(lines) == 1
|
|
||||||
let str .= ' ' . text
|
|
||||||
else
|
|
||||||
for line in lines
|
|
||||||
let str .= "\n" . indent . line . ' |'
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
elseif len(current.child) == 0
|
|
||||||
let str .= '${cursor}'
|
|
||||||
endif
|
|
||||||
if len(current.child) == 1 && len(current.child[0].name) == 0
|
|
||||||
let text = current.child[0].value[1:-2]
|
|
||||||
if dollar_expr
|
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
|
||||||
endif
|
|
||||||
let lines = split(text, "\n")
|
|
||||||
if len(lines) == 1
|
|
||||||
let str .= ' ' . text
|
|
||||||
else
|
|
||||||
for line in lines
|
|
||||||
let str .= "\n" . indent . line . ' |'
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
elseif len(current.child) > 0
|
|
||||||
for child in current.child
|
|
||||||
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
|
|
||||||
endfor
|
|
||||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
|
||||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
|
||||||
let str .= "\n" . indent . inner
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let str = current.value[1:-2]
|
|
||||||
if dollar_expr
|
|
||||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
|
||||||
let str = substitute(str, '\\\$', '$', 'g')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let str .= "\n"
|
|
||||||
return str
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#haml#imageSize() abort
|
|
||||||
let line = getline('.')
|
|
||||||
let current = emmet#lang#haml#parseTag(line)
|
|
||||||
if empty(current) || !has_key(current.attr, 'src')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let fn = current.attr.src
|
|
||||||
if fn =~# '^\s*$'
|
|
||||||
return
|
|
||||||
elseif fn !~# '^\(/\|http\)'
|
|
||||||
let fn = simplify(expand('%:h') . '/' . fn)
|
|
||||||
endif
|
|
||||||
|
|
||||||
let [width, height] = emmet#util#getImageSize(fn)
|
|
||||||
if width == -1 && height == -1
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let current.attr.width = width
|
|
||||||
let current.attr.height = height
|
|
||||||
let current.attrs_order += ['width', 'height']
|
|
||||||
let haml = emmet#toString(current, 'haml', 1)
|
|
||||||
let haml = substitute(haml, '\${cursor}', '', '')
|
|
||||||
call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", '', 'g'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#haml#encodeImage() abort
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#haml#parseTag(tag) abort
|
|
||||||
let current = emmet#newNode()
|
|
||||||
let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
|
|
||||||
let match = matchstr(a:tag, mx)
|
|
||||||
let current.name = substitute(match, mx, '\1', '')
|
|
||||||
let attrs = substitute(match, mx, '\2', '')
|
|
||||||
let mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
|
||||||
while len(attrs) > 0
|
|
||||||
let match = matchstr(attrs, mx)
|
|
||||||
if len(match) ==# 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let attr_match = matchlist(match, mx)
|
|
||||||
let name = attr_match[1]
|
|
||||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
|
||||||
let current.attr[name] = value
|
|
||||||
let current.attrs_order += [name]
|
|
||||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
|
||||||
endwhile
|
|
||||||
return current
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#haml#toggleComment() abort
|
|
||||||
let line = getline('.')
|
|
||||||
let space = matchstr(line, '^\s*')
|
|
||||||
if line =~# '^\s*-#'
|
|
||||||
call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*'))
|
|
||||||
elseif line =~# '^\s*%[a-z]'
|
|
||||||
call setline('.', space . '-# ' . line[len(space):])
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#haml#balanceTag(flag) range abort
|
|
||||||
let block = emmet#util#getVisualBlock()
|
|
||||||
if a:flag == -2 || a:flag == 2
|
|
||||||
let curpos = [0, line("'<"), col("'<"), 0]
|
|
||||||
else
|
|
||||||
let curpos = emmet#util#getcurpos()
|
|
||||||
endif
|
|
||||||
let n = curpos[1]
|
|
||||||
let ml = len(matchstr(getline(n), '^\s*'))
|
|
||||||
|
|
||||||
if a:flag > 0
|
|
||||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
|
||||||
let n = line('.')
|
|
||||||
else
|
|
||||||
while n > 0
|
|
||||||
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
|
|
||||||
if l > 0 && l < ml
|
|
||||||
let ml = l
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n -= 1
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
let sn = n
|
|
||||||
if n == 0
|
|
||||||
let ml = 0
|
|
||||||
endif
|
|
||||||
while n < line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
if l > 0 && l <= ml
|
|
||||||
let n -= 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
call setpos('.', [0, n, 1, 0])
|
|
||||||
normal! V
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
else
|
|
||||||
while n > 0
|
|
||||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
|
||||||
if l > 0 && l > ml
|
|
||||||
let ml = l
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
let sn = n
|
|
||||||
if n == 0
|
|
||||||
let ml = 0
|
|
||||||
endif
|
|
||||||
while n < line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
if l > 0 && l <= ml
|
|
||||||
let n -= 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
call setpos('.', [0, n, 1, 0])
|
|
||||||
normal! V
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#haml#moveNextPrevItem(flag) abort
|
|
||||||
return emmet#lang#haml#moveNextPrev(a:flag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#haml#moveNextPrev(flag) abort
|
|
||||||
let pos = search('""', a:flag ? 'Wb' : 'W')
|
|
||||||
if pos != 0
|
|
||||||
silent! normal! l
|
|
||||||
startinsert
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#haml#splitJoinTag() abort
|
|
||||||
let n = line('.')
|
|
||||||
let sml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
while n > 0
|
|
||||||
if getline(n) =~# '^\s*\ze%[a-z]'
|
|
||||||
if len(matchstr(getline(n), '^\s*%[a-z]')) < sml
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let line = getline(n)
|
|
||||||
call setline(n, substitute(line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', ''))
|
|
||||||
let sn = n
|
|
||||||
let n += 1
|
|
||||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
if len(matchstr(getline(n), '^\s*')) > ml
|
|
||||||
while n <= line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*'))
|
|
||||||
if l <= ml
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
exe n 'delete'
|
|
||||||
endwhile
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
else
|
|
||||||
let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)')
|
|
||||||
let spaces = matchstr(getline(sn), '^\s*')
|
|
||||||
let settings = emmet#getSettings()
|
|
||||||
if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1
|
|
||||||
call append(sn, spaces . ' ')
|
|
||||||
call setpos('.', [0, sn+1, 1, 0])
|
|
||||||
else
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
endif
|
|
||||||
startinsert!
|
|
||||||
endif
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n -= 1
|
|
||||||
endwhile
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#haml#removeTag() abort
|
|
||||||
let n = line('.')
|
|
||||||
let ml = 0
|
|
||||||
while n > 0
|
|
||||||
if getline(n) =~# '^\s*\ze[a-z]'
|
|
||||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n -= 1
|
|
||||||
endwhile
|
|
||||||
let sn = n
|
|
||||||
while n < line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
if l > 0 && l <= ml
|
|
||||||
let n -= 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
if sn == n
|
|
||||||
exe 'delete'
|
|
||||||
else
|
|
||||||
exe sn ',' (n-1) 'delete'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
|
@ -1,857 +0,0 @@
|
||||||
let s:mx = '\([+>]\|[<^]\+\)\{-}\s*'
|
|
||||||
\ .'\((*\)\{-}\s*'
|
|
||||||
\ .'\([@#.]\{-}[a-zA-Z_\!][a-zA-Z0-9:_\!\-$]*\|{\%([^$}]\+\|\$#\|\${\w\+}\|\$\+\)*}*[ \t\r\n}]*\|\[[^\]]\+\]\)'
|
|
||||||
\ .'\('
|
|
||||||
\ .'\%('
|
|
||||||
\ .'\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)'
|
|
||||||
\ .'\|\%(\[\%("[^"]*"\|[^"\]]*\)\+\]\)'
|
|
||||||
\ .'\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)'
|
|
||||||
\ .'\)*'
|
|
||||||
\ .'\)'
|
|
||||||
\ .'\%(\({\%([^$}]\+\|\$#\|\${\w\+}\|\$\+\)*}\+\)\)\{0,1}'
|
|
||||||
\ .'\%(\(@-\{0,1}[0-9]*\)\{0,1}\*\([0-9]\+\)\)\{0,1}'
|
|
||||||
\ .'\(\%()\%(\(@-\{0,1}[0-9]*\)\{0,1}\*[0-9]\+\)\{0,1}\)*\)'
|
|
||||||
|
|
||||||
function! emmet#lang#html#findTokens(str) abort
|
|
||||||
let str = a:str
|
|
||||||
let [pos, last_pos] = [0, 0]
|
|
||||||
while 1
|
|
||||||
let tag = matchstr(str, '<[a-zA-Z].\{-}>', pos)
|
|
||||||
if len(tag) == 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let pos = stridx(str, tag, pos) + len(tag)
|
|
||||||
endwhile
|
|
||||||
let last_pos = pos
|
|
||||||
while len(str) > 0
|
|
||||||
let token = matchstr(str, s:mx, pos)
|
|
||||||
if token ==# ''
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
if token =~# '^\s'
|
|
||||||
let token = matchstr(token, '^\s*\zs.*')
|
|
||||||
let last_pos = stridx(str, token, pos)
|
|
||||||
endif
|
|
||||||
let pos = stridx(str, token, pos) + len(token)
|
|
||||||
endwhile
|
|
||||||
let str = a:str[last_pos :-1]
|
|
||||||
if str =~# '^\w\+="[^"]*$'
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
return str
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
|
||||||
let abbr = a:abbr
|
|
||||||
let type = a:type
|
|
||||||
|
|
||||||
let settings = emmet#getSettings()
|
|
||||||
if !has_key(settings, type)
|
|
||||||
let type = 'html'
|
|
||||||
endif
|
|
||||||
if len(type) == 0 | let type = 'html' | endif
|
|
||||||
|
|
||||||
let settings = emmet#getSettings()
|
|
||||||
let indent = emmet#getIndentation(type)
|
|
||||||
|
|
||||||
" try 'foo' to (foo-x)
|
|
||||||
let rabbr = emmet#getExpandos(type, abbr)
|
|
||||||
if rabbr == abbr
|
|
||||||
" try 'foo+(' to (foo-x)
|
|
||||||
let rabbr = substitute(abbr, '\%(+\|^\)\([a-zA-Z][a-zA-Z0-9+]\+\)+\([(){}>]\|$\)', '\="(".emmet#getExpandos(type, submatch(1)).")".submatch(2)', 'i')
|
|
||||||
endif
|
|
||||||
let abbr = rabbr
|
|
||||||
|
|
||||||
let root = emmet#newNode()
|
|
||||||
let parent = root
|
|
||||||
let last = root
|
|
||||||
let pos = []
|
|
||||||
while len(abbr)
|
|
||||||
" parse line
|
|
||||||
let match = matchstr(abbr, s:mx)
|
|
||||||
let str = substitute(match, s:mx, '\0', 'ig')
|
|
||||||
let operator = substitute(match, s:mx, '\1', 'ig')
|
|
||||||
let block_start = substitute(match, s:mx, '\2', 'ig')
|
|
||||||
let tag_name = substitute(match, s:mx, '\3', 'ig')
|
|
||||||
let attributes = substitute(match, s:mx, '\4', 'ig')
|
|
||||||
let value = substitute(match, s:mx, '\5', 'ig')
|
|
||||||
let basevalue = substitute(match, s:mx, '\6', 'ig')
|
|
||||||
let multiplier = 0 + substitute(match, s:mx, '\7', 'ig')
|
|
||||||
let block_end = substitute(match, s:mx, '\8', 'ig')
|
|
||||||
let important = 0
|
|
||||||
if len(str) == 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
if tag_name =~# '^#'
|
|
||||||
let attributes = tag_name . attributes
|
|
||||||
let tag_name = 'div'
|
|
||||||
endif
|
|
||||||
if tag_name =~# '[^!]!$'
|
|
||||||
let tag_name = tag_name[:-2]
|
|
||||||
let important = 1
|
|
||||||
endif
|
|
||||||
if tag_name =~# '^\.'
|
|
||||||
let attributes = tag_name . attributes
|
|
||||||
let tag_name = 'div'
|
|
||||||
endif
|
|
||||||
if tag_name =~# '^\[.*\]$'
|
|
||||||
let attributes = tag_name . attributes
|
|
||||||
let tag_name = 'div'
|
|
||||||
endif
|
|
||||||
let basedirect = basevalue[1] ==# '-' ? -1 : 1
|
|
||||||
let basevalue = 0 + abs(basevalue[1:])
|
|
||||||
if multiplier <= 0 | let multiplier = 1 | endif
|
|
||||||
|
|
||||||
" make default node
|
|
||||||
let current = emmet#newNode()
|
|
||||||
let current.name = tag_name
|
|
||||||
|
|
||||||
let current.important = important
|
|
||||||
|
|
||||||
" aliases
|
|
||||||
let aliases = emmet#getResource(type, 'aliases', {})
|
|
||||||
if has_key(aliases, tag_name)
|
|
||||||
let current.name = aliases[tag_name]
|
|
||||||
endif
|
|
||||||
|
|
||||||
let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
|
|
||||||
|
|
||||||
" snippets
|
|
||||||
let snippets = emmet#getResource(type, 'snippets', {})
|
|
||||||
if !empty(snippets)
|
|
||||||
let snippet_name = tag_name
|
|
||||||
if has_key(snippets, snippet_name)
|
|
||||||
let snippet = snippet_name
|
|
||||||
while has_key(snippets, snippet)
|
|
||||||
let snippet = snippets[snippet]
|
|
||||||
endwhile
|
|
||||||
if use_pipe_for_cursor
|
|
||||||
let snippet = substitute(snippet, '|', '${cursor}', 'g')
|
|
||||||
endif
|
|
||||||
let lines = split(snippet, "\n", 1)
|
|
||||||
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
|
|
||||||
let current.snippet = join(lines, "\n")
|
|
||||||
let current.name = ''
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
let custom_expands = emmet#getResource(type, 'custom_expands', {})
|
|
||||||
if empty(custom_expands) && has_key(settings, 'custom_expands')
|
|
||||||
let custom_expands = settings['custom_expands']
|
|
||||||
endif
|
|
||||||
for k in keys(custom_expands)
|
|
||||||
if tag_name =~# k
|
|
||||||
let current.snippet = '${' . tag_name . '}'
|
|
||||||
let current.name = ''
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" default_attributes
|
|
||||||
let default_attributes = emmet#getResource(type, 'default_attributes', {})
|
|
||||||
if !empty(default_attributes)
|
|
||||||
for pat in [current.name, tag_name]
|
|
||||||
if has_key(default_attributes, pat)
|
|
||||||
if type(default_attributes[pat]) == 4
|
|
||||||
let a = default_attributes[pat]
|
|
||||||
let current.attrs_order += keys(a)
|
|
||||||
if use_pipe_for_cursor
|
|
||||||
for k in keys(a)
|
|
||||||
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
|
|
||||||
endfor
|
|
||||||
else
|
|
||||||
for k in keys(a)
|
|
||||||
let current.attr[k] = a[k]
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
for a in default_attributes[pat]
|
|
||||||
let current.attrs_order += keys(a)
|
|
||||||
if use_pipe_for_cursor
|
|
||||||
for k in keys(a)
|
|
||||||
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
|
|
||||||
endfor
|
|
||||||
else
|
|
||||||
for k in keys(a)
|
|
||||||
let current.attr[k] = a[k]
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
if has_key(settings.html.default_attributes, current.name)
|
|
||||||
let current.name = substitute(current.name, ':.*$', '', '')
|
|
||||||
endif
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
" parse attributes
|
|
||||||
if len(attributes)
|
|
||||||
let attr = attributes
|
|
||||||
while len(attr)
|
|
||||||
let item = matchstr(attr, '\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[\%("[^"]*"\|[^"\]]*\)\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)*\)\)')
|
|
||||||
if g:emmet_debug > 1
|
|
||||||
echomsg 'attr=' . item
|
|
||||||
endif
|
|
||||||
if len(item) == 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
if item[0] ==# '#'
|
|
||||||
let current.attr.id = item[1:]
|
|
||||||
endif
|
|
||||||
if item[0] ==# '.'
|
|
||||||
let current.attr.class = substitute(item[1:], '\.', ' ', 'g')
|
|
||||||
endif
|
|
||||||
if item[0] ==# '['
|
|
||||||
let atts = item[1:-2]
|
|
||||||
if matchstr(atts, '^\s*\zs[0-9a-zA-Z-:]\+\(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\)') ==# ''
|
|
||||||
let ks = []
|
|
||||||
if has_key(default_attributes, current.name)
|
|
||||||
let dfa = default_attributes[current.name]
|
|
||||||
let ks = type(dfa) == 3 ? keys(dfa[0]) : keys(dfa)
|
|
||||||
endif
|
|
||||||
if len(ks) == 0 && has_key(default_attributes, current.name . ':src')
|
|
||||||
let ks = keys(default_attributes[current.name . ':src'])
|
|
||||||
endif
|
|
||||||
if len(ks) > 0
|
|
||||||
let current.attr[ks[0]] = atts
|
|
||||||
else
|
|
||||||
let current.attr[atts] = ''
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
while len(atts)
|
|
||||||
let amat = matchstr(atts, '^\s*\zs\([0-9a-zA-Z-:]\+\%(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\|[^ ''"\]]*\)\{0,1}\)')
|
|
||||||
if len(amat) == 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let key = split(amat, '=')[0]
|
|
||||||
let Val = amat[len(key)+1:]
|
|
||||||
if key =~# '\.$' && Val ==# ''
|
|
||||||
let key = key[:-2]
|
|
||||||
unlet Val
|
|
||||||
let Val = function('emmet#types#true')
|
|
||||||
elseif Val =~# '^["'']'
|
|
||||||
let Val = Val[1:-2]
|
|
||||||
endif
|
|
||||||
let current.attr[key] = Val
|
|
||||||
if index(current.attrs_order, key) == -1
|
|
||||||
let current.attrs_order += [key]
|
|
||||||
endif
|
|
||||||
let atts = atts[stridx(atts, amat) + len(amat):]
|
|
||||||
unlet Val
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let attr = substitute(strpart(attr, len(item)), '^\s*', '', '')
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
|
|
||||||
" parse text
|
|
||||||
if tag_name =~# '^{.*}$'
|
|
||||||
let current.name = ''
|
|
||||||
let current.value = tag_name
|
|
||||||
else
|
|
||||||
let current.value = value
|
|
||||||
endif
|
|
||||||
let current.basedirect = basedirect
|
|
||||||
let current.basevalue = basevalue
|
|
||||||
let current.multiplier = multiplier
|
|
||||||
|
|
||||||
" parse step inside/outside
|
|
||||||
if !empty(last)
|
|
||||||
if operator =~# '>'
|
|
||||||
unlet! parent
|
|
||||||
let parent = last
|
|
||||||
let current.parent = last
|
|
||||||
let current.pos = last.pos + 1
|
|
||||||
else
|
|
||||||
let current.parent = parent
|
|
||||||
let current.pos = last.pos
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let current.parent = parent
|
|
||||||
let current.pos = 1
|
|
||||||
endif
|
|
||||||
if operator =~# '[<^]'
|
|
||||||
for c in range(len(operator))
|
|
||||||
let tmp = parent.parent
|
|
||||||
if empty(tmp)
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let parent = tmp
|
|
||||||
let current.parent = tmp
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
call add(parent.child, current)
|
|
||||||
let last = current
|
|
||||||
|
|
||||||
" parse block
|
|
||||||
if block_start =~# '('
|
|
||||||
if operator =~# '>'
|
|
||||||
let last.pos += 1
|
|
||||||
endif
|
|
||||||
for n in range(len(block_start))
|
|
||||||
let pos += [last.pos]
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
if block_end =~# ')'
|
|
||||||
for n in split(substitute(substitute(block_end, ' ', '', 'g'), ')', ',),', 'g'), ',')
|
|
||||||
if n ==# ')'
|
|
||||||
if len(pos) > 0 && last.pos >= pos[-1]
|
|
||||||
for c in range(last.pos - pos[-1])
|
|
||||||
let tmp = parent.parent
|
|
||||||
if !has_key(tmp, 'parent')
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let parent = tmp
|
|
||||||
endfor
|
|
||||||
if len(pos) > 0
|
|
||||||
call remove(pos, -1)
|
|
||||||
endif
|
|
||||||
let last = parent
|
|
||||||
let last.pos += 1
|
|
||||||
endif
|
|
||||||
elseif len(n)
|
|
||||||
let cl = last.child
|
|
||||||
let cls = []
|
|
||||||
for c in range(n[1:])
|
|
||||||
for cc in cl
|
|
||||||
if cc.multiplier > 1
|
|
||||||
let cc.basedirect = c + 1
|
|
||||||
else
|
|
||||||
let cc.basevalue = c + 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
let cls += deepcopy(cl)
|
|
||||||
endfor
|
|
||||||
let last.child = cls
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
let abbr = abbr[stridx(abbr, match) + len(match):]
|
|
||||||
|
|
||||||
if g:emmet_debug > 1
|
|
||||||
echomsg 'str='.str
|
|
||||||
echomsg 'block_start='.block_start
|
|
||||||
echomsg 'tag_name='.tag_name
|
|
||||||
echomsg 'operator='.operator
|
|
||||||
echomsg 'attributes='.attributes
|
|
||||||
echomsg 'value='.value
|
|
||||||
echomsg 'basevalue='.basevalue
|
|
||||||
echomsg 'multiplier='.multiplier
|
|
||||||
echomsg 'block_end='.block_end
|
|
||||||
echomsg 'abbr='.abbr
|
|
||||||
echomsg 'pos='.string(pos)
|
|
||||||
echomsg '---'
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
return root
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:dollar_add(base,no) abort
|
|
||||||
if a:base > 0
|
|
||||||
return a:base + a:no - 1
|
|
||||||
elseif a:base < 0
|
|
||||||
return a:base - a:no + 1
|
|
||||||
else
|
|
||||||
return a:no
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#html#toString(settings, current, type, inline, filters, itemno, indent) abort
|
|
||||||
let settings = a:settings
|
|
||||||
let current = a:current
|
|
||||||
let type = a:type
|
|
||||||
let inline = a:inline
|
|
||||||
let filters = a:filters
|
|
||||||
let itemno = a:itemno
|
|
||||||
let indent = a:indent
|
|
||||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
|
||||||
let q = emmet#getResource(type, 'quote_char', '"')
|
|
||||||
let ct = emmet#getResource(type, 'comment_type', 'both')
|
|
||||||
let an = emmet#getResource(type, 'attribute_name', {})
|
|
||||||
|
|
||||||
if emmet#useFilter(filters, 'haml')
|
|
||||||
return emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
|
|
||||||
endif
|
|
||||||
if emmet#useFilter(filters, 'slim')
|
|
||||||
return emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
|
|
||||||
endif
|
|
||||||
|
|
||||||
let comment = ''
|
|
||||||
let current_name = current.name
|
|
||||||
if dollar_expr
|
|
||||||
let current_name = substitute(current_name, '\$$', itemno+1, '')
|
|
||||||
endif
|
|
||||||
|
|
||||||
let str = ''
|
|
||||||
if len(current_name) == 0
|
|
||||||
let text = current.value[1:-2]
|
|
||||||
if dollar_expr
|
|
||||||
" TODO: regexp engine specified
|
|
||||||
let nr = itemno + 1
|
|
||||||
if exists('®expengine')
|
|
||||||
let text = substitute(text, '\%#=1\%(\\\)\@\<!\(\$\+\)\(@-\?[0-9]\+\)\{0,1}\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d",s:dollar_add(submatch(2)[1:],nr)).submatch(3)', 'g')
|
|
||||||
else
|
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\(@-\?[0-9]\+\)\{0,1}\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d",s:dollar_add(submatch(2)[1:],nr).submatch(3)', 'g')
|
|
||||||
endif
|
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
|
||||||
endif
|
|
||||||
return text
|
|
||||||
endif
|
|
||||||
if len(current_name) > 0
|
|
||||||
let str .= '<' . current_name
|
|
||||||
endif
|
|
||||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
|
||||||
if !has_key(current.attr, attr)
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
let Val = current.attr[attr]
|
|
||||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
|
||||||
unlet Val
|
|
||||||
let Val = 'true'
|
|
||||||
if g:emmet_html5
|
|
||||||
let str .= ' ' . attr
|
|
||||||
else
|
|
||||||
let str .= ' ' . attr . '=' . q . attr . q
|
|
||||||
endif
|
|
||||||
if emmet#useFilter(filters, 'c')
|
|
||||||
if attr ==# 'id' | let comment .= '#' . Val | endif
|
|
||||||
if attr ==# 'class' | let comment .= '.' . Val | endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
if dollar_expr
|
|
||||||
while Val =~# '\$\([^#{]\|$\)'
|
|
||||||
" TODO: regexp engine specified
|
|
||||||
if exists('®expengine')
|
|
||||||
let Val = substitute(Val, '\%#=1\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
else
|
|
||||||
let Val = substitute(Val, '\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
|
||||||
endif
|
|
||||||
if attr ==# 'class' && emmet#useFilter(filters, 'bem')
|
|
||||||
let vals = split(Val, '\s\+')
|
|
||||||
let Val = ''
|
|
||||||
let lead = ''
|
|
||||||
for _val in vals
|
|
||||||
if len(Val) > 0
|
|
||||||
let Val .= ' '
|
|
||||||
endif
|
|
||||||
if _val =~# '^\a_'
|
|
||||||
let lead = _val[0]
|
|
||||||
let Val .= lead . ' ' . _val
|
|
||||||
elseif _val =~# '^_'
|
|
||||||
if len(lead) == 0
|
|
||||||
let pattr = current.parent.attr
|
|
||||||
if has_key(pattr, 'class')
|
|
||||||
let lead = pattr['class']
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let Val .= lead . ' ' . lead . _val
|
|
||||||
else
|
|
||||||
let Val .= _val
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
if has_key(an, attr)
|
|
||||||
let attr = an[attr]
|
|
||||||
endif
|
|
||||||
let str .= ' ' . attr . '=' . q . Val . q
|
|
||||||
if emmet#useFilter(filters, 'c')
|
|
||||||
if attr ==# 'id' | let comment .= '#' . Val | endif
|
|
||||||
if attr ==# 'class' | let comment .= '.' . Val | endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
unlet Val
|
|
||||||
endfor
|
|
||||||
if len(comment) > 0 && ct ==# 'both'
|
|
||||||
let str = '<!-- ' . comment . " -->\n" . str
|
|
||||||
endif
|
|
||||||
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1
|
|
||||||
let str .= settings.html.empty_element_suffix
|
|
||||||
else
|
|
||||||
let str .= '>'
|
|
||||||
let text = current.value[1:-2]
|
|
||||||
if dollar_expr
|
|
||||||
" TODO: regexp engine specified
|
|
||||||
let nr = itemno + 1
|
|
||||||
if exists('®expengine')
|
|
||||||
let text = substitute(text, '\%#=1\%(\\\)\@\<!\(\$\+\)\(@-\?[0-9]\+\)\{0,1}\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d",s:dollar_add(submatch(2)[1:],nr)).submatch(3)', 'g')
|
|
||||||
else
|
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\(@-\?[0-9]\+\)\{0,1}\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d",s:dollar_add(submatch(2)[1:],nr)).submatch(3)', 'g')
|
|
||||||
endif
|
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
|
||||||
if text != ''
|
|
||||||
let str = substitute(str, '\("\zs$#\ze"\|\s\zs\$#"\|"\$#\ze\s\)', text, 'g')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let str .= text
|
|
||||||
let nc = len(current.child)
|
|
||||||
let dr = 0
|
|
||||||
if nc > 0
|
|
||||||
for n in range(nc)
|
|
||||||
let child = current.child[n]
|
|
||||||
if child.multiplier > 1
|
|
||||||
let str .= "\n" . indent
|
|
||||||
let dr = 1
|
|
||||||
elseif len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
|
|
||||||
if nc > 1 || (len(child.name) > 0 && stridx(','.settings.html.inline_elements.',', ','.child.name.',') == -1)
|
|
||||||
let str .= "\n" . indent
|
|
||||||
let dr = 1
|
|
||||||
elseif current.multiplier == 1 && nc == 1 && len(child.name) == 0
|
|
||||||
let str .= "\n" . indent
|
|
||||||
let dr = 1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let inner = emmet#toString(child, type, 0, filters, itemno, indent)
|
|
||||||
let inner = substitute(inner, "^\n", '', 'g')
|
|
||||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
|
||||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
|
||||||
let str .= inner
|
|
||||||
endfor
|
|
||||||
else
|
|
||||||
if settings.html.indent_blockelement && len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
|
|
||||||
let str .= "\n" . indent . '${cursor}' . "\n"
|
|
||||||
else
|
|
||||||
let str .= '${cursor}'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if dr
|
|
||||||
let str .= "\n"
|
|
||||||
endif
|
|
||||||
let str .= '</' . current_name . '>'
|
|
||||||
endif
|
|
||||||
if len(comment) > 0
|
|
||||||
if ct ==# 'lastonly'
|
|
||||||
let str .= '<!-- ' . comment . ' -->'
|
|
||||||
else
|
|
||||||
let str .= "\n<!-- /" . comment . ' -->'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if len(current_name) > 0 && current.multiplier > 0 || stridx(','.settings.html.block_elements.',', ','.current_name.',') != -1
|
|
||||||
let str .= "\n"
|
|
||||||
endif
|
|
||||||
return str
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#html#imageSize() abort
|
|
||||||
let img_region = emmet#util#searchRegion('<img\s', '>')
|
|
||||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let content = emmet#util#getContent(img_region)
|
|
||||||
if content !~# '^<img[^><]\+>$'
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let current = emmet#lang#html#parseTag(content)
|
|
||||||
if empty(current) || !has_key(current.attr, 'src')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let fn = current.attr.src
|
|
||||||
if fn =~# '^\s*$'
|
|
||||||
return
|
|
||||||
elseif fn !~# '^\(/\|http\)'
|
|
||||||
let fn = simplify(expand('%:h') . '/' . fn)
|
|
||||||
endif
|
|
||||||
|
|
||||||
let [width, height] = emmet#util#getImageSize(fn)
|
|
||||||
if width == -1 && height == -1
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let current.attr.width = width
|
|
||||||
let current.attr.height = height
|
|
||||||
let current.attrs_order += ['width', 'height']
|
|
||||||
let html = substitute(emmet#toString(current, 'html', 1), '\n', '', '')
|
|
||||||
let html = substitute(html, '\${cursor}', '', '')
|
|
||||||
call emmet#util#setContent(img_region, html)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#html#encodeImage() abort
|
|
||||||
let img_region = emmet#util#searchRegion('<img\s', '>')
|
|
||||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let content = emmet#util#getContent(img_region)
|
|
||||||
if content !~# '^<img[^><]\+>$'
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let current = emmet#lang#html#parseTag(content)
|
|
||||||
if empty(current) || !has_key(current.attr, 'src')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let fn = current.attr.src
|
|
||||||
if fn !~# '^\(/\|http\)'
|
|
||||||
let fn = simplify(expand('%:h') . '/' . fn)
|
|
||||||
endif
|
|
||||||
|
|
||||||
let [width, height] = emmet#util#getImageSize(fn)
|
|
||||||
if width == -1 && height == -1
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let current.attr.width = width
|
|
||||||
let current.attr.height = height
|
|
||||||
let html = emmet#toString(current, 'html', 1)
|
|
||||||
call emmet#util#setContent(img_region, html)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#html#parseTag(tag) abort
|
|
||||||
let current = emmet#newNode()
|
|
||||||
let mx = '<\([a-zA-Z][a-zA-Z0-9]*\)\(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\(/\{0,1}\)>'
|
|
||||||
let match = matchstr(a:tag, mx)
|
|
||||||
let current.name = substitute(match, mx, '\1', 'i')
|
|
||||||
let attrs = substitute(match, mx, '\2', 'i')
|
|
||||||
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
|
||||||
while len(attrs) > 0
|
|
||||||
let match = matchstr(attrs, mx)
|
|
||||||
if len(match) == 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let attr_match = matchlist(match, mx)
|
|
||||||
let name = attr_match[1]
|
|
||||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
|
||||||
let current.attr[name] = value
|
|
||||||
let current.attrs_order += [name]
|
|
||||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
|
||||||
endwhile
|
|
||||||
return current
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#html#toggleComment() abort
|
|
||||||
let orgpos = emmet#util#getcurpos()
|
|
||||||
let curpos = emmet#util#getcurpos()
|
|
||||||
let mx = '<\%#[^>]*>'
|
|
||||||
while 1
|
|
||||||
let block = emmet#util#searchRegion('<!--', '-->')
|
|
||||||
if emmet#util#regionIsValid(block)
|
|
||||||
let block[1][1] += 2
|
|
||||||
let content = emmet#util#getContent(block)
|
|
||||||
let content = substitute(content, '^<!--\s\(.*\)\s-->$', '\1', '')
|
|
||||||
call emmet#util#setContent(block, content)
|
|
||||||
silent! call setpos('.', orgpos)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let block = emmet#util#searchRegion('<[^>]', '>')
|
|
||||||
if !emmet#util#regionIsValid(block)
|
|
||||||
let pos1 = searchpos('<', 'bcW')
|
|
||||||
if pos1[0] == 0 && pos1[1] == 0
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let curpos = emmet#util#getcurpos()
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
let pos1 = block[0]
|
|
||||||
let pos2 = block[1]
|
|
||||||
let content = emmet#util#getContent(block)
|
|
||||||
let tag_name = matchstr(content, '^<\zs/\{0,1}[^ \r\n>]\+')
|
|
||||||
if tag_name[0] ==# '/'
|
|
||||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
|
||||||
let pos2 = searchpairpos('<'. tag_name[1:] . '\>[^>]*>', '', '</' . tag_name[1:] . '>', 'bnW')
|
|
||||||
let pos1 = searchpos('>', 'cneW')
|
|
||||||
let block = [pos2, pos1]
|
|
||||||
elseif tag_name =~# '/$'
|
|
||||||
if !emmet#util#pointInRegion(orgpos[1:2], block)
|
|
||||||
" it's broken tree
|
|
||||||
call setpos('.', orgpos)
|
|
||||||
let block = emmet#util#searchRegion('>', '<')
|
|
||||||
let content = '><!-- ' . emmet#util#getContent(block)[1:-2] . ' --><'
|
|
||||||
call emmet#util#setContent(block, content)
|
|
||||||
silent! call setpos('.', orgpos)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
call setpos('.', [0, pos2[0], pos2[1], 0])
|
|
||||||
let pos3 = searchpairpos('<'. tag_name . '\>[^>]*>', '', '</' . tag_name . '>', 'nW')
|
|
||||||
if pos3 == [0, 0]
|
|
||||||
let block = [pos1, pos2]
|
|
||||||
else
|
|
||||||
call setpos('.', [0, pos3[0], pos3[1], 0])
|
|
||||||
let pos2 = searchpos('>', 'neW')
|
|
||||||
let block = [pos1, pos2]
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if !emmet#util#regionIsValid(block)
|
|
||||||
silent! call setpos('.', orgpos)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
if emmet#util#pointInRegion(curpos[1:2], block)
|
|
||||||
let content = '<!-- ' . emmet#util#getContent(block) . ' -->'
|
|
||||||
call emmet#util#setContent(block, content)
|
|
||||||
silent! call setpos('.', orgpos)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#html#balanceTag(flag) range abort
|
|
||||||
let vblock = emmet#util#getVisualBlock()
|
|
||||||
if a:flag == -2 || a:flag == 2
|
|
||||||
let curpos = [0, line("'<"), col("'<"), 0]
|
|
||||||
else
|
|
||||||
let curpos = emmet#util#getcurpos()
|
|
||||||
endif
|
|
||||||
let settings = emmet#getSettings()
|
|
||||||
|
|
||||||
if a:flag > 0
|
|
||||||
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*'
|
|
||||||
let last = curpos[1:2]
|
|
||||||
while 1
|
|
||||||
let pos1 = searchpos(mx, 'bW')
|
|
||||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
|
||||||
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
|
||||||
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
|
||||||
let pos2 = searchpos('>', 'nW')
|
|
||||||
else
|
|
||||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
|
||||||
endif
|
|
||||||
let block = [pos1, pos2]
|
|
||||||
if pos1[0] == 0 && pos1[1] == 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
if emmet#util#pointInRegion(last, block) && emmet#util#regionIsValid(block)
|
|
||||||
call emmet#util#selectRegion(block)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
if pos1 == last
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let last = pos1
|
|
||||||
endwhile
|
|
||||||
else
|
|
||||||
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
|
||||||
while 1
|
|
||||||
let pos1 = searchpos(mx, 'W')
|
|
||||||
if pos1 == curpos[1:2]
|
|
||||||
let pos1 = searchpos(mx . '\zs', 'W')
|
|
||||||
let pos2 = searchpos('.\ze<', 'W')
|
|
||||||
let block = [pos1, pos2]
|
|
||||||
if emmet#util#regionIsValid(block)
|
|
||||||
call emmet#util#selectRegion(block)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
|
||||||
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
|
||||||
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
|
||||||
let pos2 = searchpos('>', 'nW')
|
|
||||||
else
|
|
||||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
|
||||||
endif
|
|
||||||
let block = [pos1, pos2]
|
|
||||||
if pos1[0] == 0 && pos1[1] == 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
if emmet#util#regionIsValid(block)
|
|
||||||
call emmet#util#selectRegion(block)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
if a:flag == -2 || a:flag == 2
|
|
||||||
silent! exe 'normal! gv'
|
|
||||||
else
|
|
||||||
call setpos('.', curpos)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#html#moveNextPrevItem(flag) abort
|
|
||||||
silent! exe "normal \<esc>"
|
|
||||||
let mx = '\%([0-9a-zA-Z-:]\+\%(="[^"]*"\|=''[^'']*''\|[^ ''">\]]*\)\{0,1}\)'
|
|
||||||
let pos = searchpos('\s'.mx.'\zs', '')
|
|
||||||
if pos != [0,0]
|
|
||||||
call feedkeys('v?\s\zs'.mx."\<cr>", '')
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#html#moveNextPrev(flag) abort
|
|
||||||
let pos = search('\%(</\w\+\)\@<!\zs><\/\|\(""\)\|^\(\s*\)$', a:flag ? 'Wpb' : 'Wp')
|
|
||||||
if pos == 3
|
|
||||||
startinsert!
|
|
||||||
elseif pos != 0
|
|
||||||
silent! normal! l
|
|
||||||
startinsert
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#html#splitJoinTag() abort
|
|
||||||
let curpos = emmet#util#getcurpos()
|
|
||||||
while 1
|
|
||||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
|
||||||
let pos1 = searchpos(mx, 'bcnW')
|
|
||||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
|
||||||
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
|
||||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
|
||||||
if content[-2:] ==# '/>' && emmet#util#cursorInRegion(block)
|
|
||||||
let content = content[:-3] . '></' . tag_name . '>'
|
|
||||||
call emmet#util#setContent(block, content)
|
|
||||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
|
||||||
return
|
|
||||||
else
|
|
||||||
if tag_name[0] ==# '/'
|
|
||||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
|
||||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
|
||||||
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
|
||||||
else
|
|
||||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
|
||||||
endif
|
|
||||||
let block = [pos1, pos2]
|
|
||||||
let content = emmet#util#getContent(block)
|
|
||||||
if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~# '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
|
||||||
let content = matchstr(content, mx)[:-2] . '/>'
|
|
||||||
call emmet#util#setContent(block, content)
|
|
||||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
|
||||||
return
|
|
||||||
else
|
|
||||||
if block[0][0] > 0
|
|
||||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
|
||||||
else
|
|
||||||
call setpos('.', curpos)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#html#removeTag() abort
|
|
||||||
let curpos = emmet#util#getcurpos()
|
|
||||||
while 1
|
|
||||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*'
|
|
||||||
let pos1 = searchpos(mx, 'bcnW')
|
|
||||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
|
||||||
let tag_name = matchstr(content, '^<\zs/\{0,1}[a-zA-Z0-9:_\-]*')
|
|
||||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
|
||||||
if content[-2:] ==# '/>' && emmet#util#cursorInRegion(block)
|
|
||||||
call emmet#util#setContent(block, '')
|
|
||||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
|
||||||
return
|
|
||||||
else
|
|
||||||
if tag_name[0] ==# '/'
|
|
||||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
|
||||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
|
||||||
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
|
||||||
else
|
|
||||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
|
||||||
endif
|
|
||||||
let block = [pos1, pos2]
|
|
||||||
let content = emmet#util#getContent(block)
|
|
||||||
if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~# '^<' . tag_name . '[^a-zA-Z0-9]'
|
|
||||||
call emmet#util#setContent(block, '')
|
|
||||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
|
||||||
return
|
|
||||||
else
|
|
||||||
if block[0][0] > 0
|
|
||||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
|
||||||
else
|
|
||||||
call setpos('.', curpos)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
endfunction
|
|
|
@ -1,332 +0,0 @@
|
||||||
function! emmet#lang#jade#findTokens(str) abort
|
|
||||||
return emmet#lang#html#findTokens(a:str)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#jade#parseIntoTree(abbr, type) abort
|
|
||||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#jade#toString(settings, current, type, inline, filters, itemno, indent) abort
|
|
||||||
let settings = a:settings
|
|
||||||
let current = a:current
|
|
||||||
let type = a:type
|
|
||||||
let inline = a:inline
|
|
||||||
let filters = a:filters
|
|
||||||
let itemno = a:itemno
|
|
||||||
let indent = emmet#getIndentation(type)
|
|
||||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
|
||||||
let attribute_style = emmet#getResource('jade', 'attribute_style', 'hash')
|
|
||||||
let str = ''
|
|
||||||
|
|
||||||
let current_name = current.name
|
|
||||||
if dollar_expr
|
|
||||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
|
||||||
endif
|
|
||||||
if len(current.name) > 0
|
|
||||||
let str .= '' . current_name
|
|
||||||
let tmp = ''
|
|
||||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
|
||||||
if !has_key(current.attr, attr)
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
let Val = current.attr[attr]
|
|
||||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
|
||||||
if attribute_style ==# 'hash'
|
|
||||||
let tmp .= ' ' . attr . ' = true'
|
|
||||||
elseif attribute_style ==# 'html'
|
|
||||||
let tmp .= attr . '=true'
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if dollar_expr
|
|
||||||
while Val =~# '\$\([^#{]\|$\)'
|
|
||||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
endwhile
|
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
|
||||||
endif
|
|
||||||
let valtmp = substitute(Val, '\${cursor}', '', '')
|
|
||||||
if attr ==# 'id' && len(valtmp) > 0
|
|
||||||
let str .= '#' . Val
|
|
||||||
elseif attr ==# 'class' && len(valtmp) > 0
|
|
||||||
let str .= '.' . substitute(Val, ' ', '.', 'g')
|
|
||||||
else
|
|
||||||
if len(tmp) > 0
|
|
||||||
if attribute_style ==# 'hash'
|
|
||||||
let tmp .= ', '
|
|
||||||
elseif attribute_style ==# 'html'
|
|
||||||
let tmp .= ' '
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let Val = substitute(Val, '\${cursor}', '', '')
|
|
||||||
if attribute_style ==# 'hash'
|
|
||||||
let tmp .= '' . attr . '="' . Val . '"'
|
|
||||||
elseif attribute_style ==# 'html'
|
|
||||||
let tmp .= attr . '="' . Val . '"'
|
|
||||||
end
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
if len(tmp)
|
|
||||||
if attribute_style ==# 'hash'
|
|
||||||
let str .= '(' . tmp . ')'
|
|
||||||
elseif attribute_style ==# 'html'
|
|
||||||
let str .= '(' . tmp . ')'
|
|
||||||
end
|
|
||||||
endif
|
|
||||||
|
|
||||||
let inner = ''
|
|
||||||
if len(current.value) > 0
|
|
||||||
let text = current.value[1:-2]
|
|
||||||
if dollar_expr
|
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
|
||||||
let str = substitute(str, '\$#', text, 'g')
|
|
||||||
endif
|
|
||||||
let lines = split(text, "\n")
|
|
||||||
if len(lines) == 1
|
|
||||||
let str .= ' ' . text
|
|
||||||
else
|
|
||||||
for line in lines
|
|
||||||
let str .= "\n" . indent . line . ' |'
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
elseif len(current.child) == 0
|
|
||||||
let str .= '${cursor}'
|
|
||||||
endif
|
|
||||||
if len(current.child) == 1 && len(current.child[0].name) == 0
|
|
||||||
let text = current.child[0].value[1:-2]
|
|
||||||
if dollar_expr
|
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
|
||||||
endif
|
|
||||||
let lines = split(text, "\n")
|
|
||||||
if len(lines) == 1
|
|
||||||
let str .= ' ' . text
|
|
||||||
else
|
|
||||||
for line in lines
|
|
||||||
let str .= "\n" . indent . line . ' |'
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
elseif len(current.child) > 0
|
|
||||||
for child in current.child
|
|
||||||
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
|
|
||||||
endfor
|
|
||||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
|
||||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
|
||||||
let str .= "\n" . indent . inner
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let str = current.value[1:-2]
|
|
||||||
if dollar_expr
|
|
||||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
|
||||||
let str = substitute(str, '\\\$', '$', 'g')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let str .= "\n"
|
|
||||||
return str
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#jade#imageSize() abort
|
|
||||||
let line = getline('.')
|
|
||||||
let current = emmet#lang#jade#parseTag(line)
|
|
||||||
if empty(current) || !has_key(current.attr, 'src')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let fn = current.attr.src
|
|
||||||
if fn =~# '^\s*$'
|
|
||||||
return
|
|
||||||
elseif fn !~# '^\(/\|http\)'
|
|
||||||
let fn = simplify(expand('%:h') . '/' . fn)
|
|
||||||
endif
|
|
||||||
|
|
||||||
let [width, height] = emmet#util#getImageSize(fn)
|
|
||||||
if width == -1 && height == -1
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let current.attr.width = width
|
|
||||||
let current.attr.height = height
|
|
||||||
let current.attrs_order += ['width', 'height']
|
|
||||||
let jade = emmet#toString(current, 'jade', 1)
|
|
||||||
let jade = substitute(jade, '\${cursor}', '', '')
|
|
||||||
call setline('.', substitute(matchstr(line, '^\s*') . jade, "\n", '', 'g'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#jade#encodeImage() abort
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#jade#parseTag(tag) abort
|
|
||||||
let current = emmet#newNode()
|
|
||||||
let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
|
|
||||||
let match = matchstr(a:tag, mx)
|
|
||||||
let current.name = substitute(match, mx, '\1', '')
|
|
||||||
let attrs = substitute(match, mx, '\2', '')
|
|
||||||
let mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
|
||||||
while len(attrs) > 0
|
|
||||||
let match = matchstr(attrs, mx)
|
|
||||||
if len(match) ==# 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let attr_match = matchlist(match, mx)
|
|
||||||
let name = attr_match[1]
|
|
||||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
|
||||||
let current.attr[name] = value
|
|
||||||
let current.attrs_order += [name]
|
|
||||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
|
||||||
endwhile
|
|
||||||
return current
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#jade#toggleComment() abort
|
|
||||||
let line = getline('.')
|
|
||||||
let space = matchstr(line, '^\s*')
|
|
||||||
if line =~# '^\s*-#'
|
|
||||||
call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*'))
|
|
||||||
elseif line =~# '^\s*%[a-z]'
|
|
||||||
call setline('.', space . '-# ' . line[len(space):])
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#jade#balanceTag(flag) range abort
|
|
||||||
let block = emmet#util#getVisualBlock()
|
|
||||||
if a:flag == -2 || a:flag == 2
|
|
||||||
let curpos = [0, line("'<"), col("'<"), 0]
|
|
||||||
else
|
|
||||||
let curpos = emmet#util#getcurpos()
|
|
||||||
endif
|
|
||||||
let n = curpos[1]
|
|
||||||
let ml = len(matchstr(getline(n), '^\s*'))
|
|
||||||
|
|
||||||
if a:flag > 0
|
|
||||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
|
||||||
let n = line('.')
|
|
||||||
else
|
|
||||||
while n > 0
|
|
||||||
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
|
|
||||||
if l > 0 && l < ml
|
|
||||||
let ml = l
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n -= 1
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
let sn = n
|
|
||||||
if n == 0
|
|
||||||
let ml = 0
|
|
||||||
endif
|
|
||||||
while n < line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
if l > 0 && l <= ml
|
|
||||||
let n -= 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
call setpos('.', [0, n, 1, 0])
|
|
||||||
normal! V
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
else
|
|
||||||
while n > 0
|
|
||||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
|
||||||
if l > 0 && l > ml
|
|
||||||
let ml = l
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
let sn = n
|
|
||||||
if n == 0
|
|
||||||
let ml = 0
|
|
||||||
endif
|
|
||||||
while n < line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
if l > 0 && l <= ml
|
|
||||||
let n -= 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
call setpos('.', [0, n, 1, 0])
|
|
||||||
normal! V
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#jade#moveNextPrevItem(flag) abort
|
|
||||||
return emmet#lang#jade#moveNextPrev(a:flag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#jade#moveNextPrev(flag) abort
|
|
||||||
let pos = search('""', a:flag ? 'Wb' : 'W')
|
|
||||||
if pos != 0
|
|
||||||
silent! normal! l
|
|
||||||
startinsert
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#jade#splitJoinTag() abort
|
|
||||||
let n = line('.')
|
|
||||||
let sml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
while n > 0
|
|
||||||
if getline(n) =~# '^\s*\ze%[a-z]'
|
|
||||||
if len(matchstr(getline(n), '^\s*%[a-z]')) < sml
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let line = getline(n)
|
|
||||||
call setline(n, substitute(line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', ''))
|
|
||||||
let sn = n
|
|
||||||
let n += 1
|
|
||||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
if len(matchstr(getline(n), '^\s*')) > ml
|
|
||||||
while n <= line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*'))
|
|
||||||
if l <= ml
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
exe n 'delete'
|
|
||||||
endwhile
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
else
|
|
||||||
let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)')
|
|
||||||
let spaces = matchstr(getline(sn), '^\s*')
|
|
||||||
let settings = emmet#getSettings()
|
|
||||||
if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1
|
|
||||||
call append(sn, spaces . ' ')
|
|
||||||
call setpos('.', [0, sn+1, 1, 0])
|
|
||||||
else
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
endif
|
|
||||||
startinsert!
|
|
||||||
endif
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n -= 1
|
|
||||||
endwhile
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#jade#removeTag() abort
|
|
||||||
let n = line('.')
|
|
||||||
let ml = 0
|
|
||||||
while n > 0
|
|
||||||
if getline(n) =~# '^\s*\ze[a-z]'
|
|
||||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n -= 1
|
|
||||||
endwhile
|
|
||||||
let sn = n
|
|
||||||
while n < line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
|
||||||
if l > 0 && l <= ml
|
|
||||||
let n -= 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
if sn == n
|
|
||||||
exe 'delete'
|
|
||||||
else
|
|
||||||
exe sn ',' (n-1) 'delete'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
|
@ -1,47 +0,0 @@
|
||||||
function! emmet#lang#less#findTokens(str) abort
|
|
||||||
return emmet#lang#html#findTokens(a:str)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#less#parseIntoTree(abbr, type) abort
|
|
||||||
return emmet#lang#scss#parseIntoTree(a:abbr, a:type)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#less#toString(settings, current, type, inline, filters, itemno, indent) abort
|
|
||||||
return emmet#lang#scss#toString(a:settings, a:current, a:type, a:inline, a:filters, a:itemno, a:indent)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#less#imageSize() abort
|
|
||||||
call emmet#lang#css#imageSize()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#less#encodeImage() abort
|
|
||||||
return emmet#lang#css#encodeImage()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#less#parseTag(tag) abort
|
|
||||||
return emmet#lang#css#parseTag(a:tag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#less#toggleComment() abort
|
|
||||||
call emmet#lang#css#toggleComment()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#less#balanceTag(flag) range abort
|
|
||||||
call emmet#lang#scss#balanceTag(a:flag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#less#moveNextPrevItem(flag) abort
|
|
||||||
return emmet#lang#less#moveNextPrev(a:flag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#less#moveNextPrev(flag) abort
|
|
||||||
call emmet#lang#scss#moveNextPrev(a:flag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#less#splitJoinTag() abort
|
|
||||||
call emmet#lang#css#splitJoinTag()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#less#removeTag() abort
|
|
||||||
call emmet#lang#css#removeTag()
|
|
||||||
endfunction
|
|
|
@ -1,160 +0,0 @@
|
||||||
function! emmet#lang#sass#findTokens(str) abort
|
|
||||||
return emmet#lang#css#findTokens(a:str)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#sass#parseIntoTree(abbr, type) abort
|
|
||||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#sass#toString(settings, current, type, inline, filters, itemno, indent) abort
|
|
||||||
let settings = a:settings
|
|
||||||
let current = a:current
|
|
||||||
let type = a:type
|
|
||||||
let inline = a:inline
|
|
||||||
let filters = a:filters
|
|
||||||
let itemno = a:itemno
|
|
||||||
let indent = a:indent
|
|
||||||
let str = ''
|
|
||||||
|
|
||||||
let current_name = current.name
|
|
||||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
|
||||||
if len(current.name) > 0
|
|
||||||
let str .= current_name
|
|
||||||
let tmp = ''
|
|
||||||
for attr in keys(current.attr)
|
|
||||||
let val = current.attr[attr]
|
|
||||||
while val =~# '\$\([^#{]\|$\)'
|
|
||||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
endwhile
|
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
|
||||||
if attr ==# 'id'
|
|
||||||
let str .= '#' . val
|
|
||||||
elseif attr ==# 'class'
|
|
||||||
let str .= '.' . val
|
|
||||||
else
|
|
||||||
let tmp .= attr . ': ' . val
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
if len(tmp) > 0
|
|
||||||
let str .= "\n"
|
|
||||||
for line in split(tmp, "\n")
|
|
||||||
let str .= indent . line . "\n"
|
|
||||||
endfor
|
|
||||||
else
|
|
||||||
let str .= "\n"
|
|
||||||
endif
|
|
||||||
|
|
||||||
let inner = ''
|
|
||||||
for child in current.child
|
|
||||||
let tmp = emmet#toString(child, type, inline, filters, itemno, indent)
|
|
||||||
let tmp = substitute(tmp, "\n", "\n" . escape(indent, '\'), 'g')
|
|
||||||
let tmp = substitute(tmp, "\n" . escape(indent, '\') . '$', '${cursor}\n', 'g')
|
|
||||||
let inner .= tmp
|
|
||||||
endfor
|
|
||||||
if len(inner) > 0
|
|
||||||
let str .= indent . inner
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let text = emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
|
||||||
let text = substitute(text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g')
|
|
||||||
return text
|
|
||||||
endif
|
|
||||||
return str
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#sass#imageSize() abort
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#sass#encodeImage() abort
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#sass#parseTag(tag) abort
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#sass#toggleComment() abort
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#sass#balanceTag(flag) range abort
|
|
||||||
let block = emmet#util#getVisualBlock()
|
|
||||||
if a:flag == -2 || a:flag == 2
|
|
||||||
let curpos = [0, line("'<"), col("'<"), 0]
|
|
||||||
else
|
|
||||||
let curpos = emmet#util#getcurpos()
|
|
||||||
endif
|
|
||||||
let n = curpos[1]
|
|
||||||
let ml = len(matchstr(getline(n), '^\s*'))
|
|
||||||
|
|
||||||
if a:flag > 0
|
|
||||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
|
||||||
let n = line('.')
|
|
||||||
else
|
|
||||||
while n > 0
|
|
||||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
|
||||||
if l > 0 && l < ml
|
|
||||||
let ml = l
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n -= 1
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
let sn = n
|
|
||||||
if n == 0
|
|
||||||
let ml = 0
|
|
||||||
endif
|
|
||||||
while n < line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
|
||||||
if l > 0 && l <= ml
|
|
||||||
let n -= 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
call setpos('.', [0, n, 1, 0])
|
|
||||||
normal! V
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
else
|
|
||||||
while n > 0
|
|
||||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
|
||||||
if l > 0 && l > ml
|
|
||||||
let ml = l
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
let sn = n
|
|
||||||
if n == 0
|
|
||||||
let ml = 0
|
|
||||||
endif
|
|
||||||
while n < line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
|
||||||
if l > 0 && l <= ml
|
|
||||||
let n -= 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
call setpos('.', [0, n, 1, 0])
|
|
||||||
normal! V
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#sass#moveNextPrevItem(flag) abort
|
|
||||||
return emmet#lang#sass#moveNextPrev(a:flag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#sass#moveNextPrev(flag) abort
|
|
||||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
|
||||||
if pos == 2
|
|
||||||
startinsert!
|
|
||||||
elseif pos != 0
|
|
||||||
silent! normal! l
|
|
||||||
startinsert
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#sass#splitJoinTag() abort
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#sass#removeTag() abort
|
|
||||||
endfunction
|
|
|
@ -1,125 +0,0 @@
|
||||||
function! emmet#lang#scss#findTokens(str) abort
|
|
||||||
return emmet#lang#css#findTokens(a:str)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#scss#parseIntoTree(abbr, type) abort
|
|
||||||
if a:abbr =~# '>'
|
|
||||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
|
||||||
else
|
|
||||||
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#scss#toString(settings, current, type, inline, filters, itemno, indent) abort
|
|
||||||
let settings = a:settings
|
|
||||||
let current = a:current
|
|
||||||
let type = a:type
|
|
||||||
let inline = a:inline
|
|
||||||
let filters = a:filters
|
|
||||||
let itemno = a:itemno
|
|
||||||
let indent = a:indent
|
|
||||||
let str = ''
|
|
||||||
|
|
||||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
|
||||||
if len(current.name) > 0
|
|
||||||
let str .= current_name
|
|
||||||
let tmp = ''
|
|
||||||
for attr in keys(current.attr)
|
|
||||||
let val = current.attr[attr]
|
|
||||||
while val =~# '\$\([^#{]\|$\)'
|
|
||||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
endwhile
|
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
|
||||||
if attr ==# 'id'
|
|
||||||
let str .= '#' . val
|
|
||||||
elseif attr ==# 'class'
|
|
||||||
let str .= '.' . val
|
|
||||||
else
|
|
||||||
let tmp .= attr . ': ' . val . ';'
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
if len(tmp) > 0
|
|
||||||
let str .= " {\n"
|
|
||||||
for line in split(tmp, "\n")
|
|
||||||
let str .= indent . line . "\n"
|
|
||||||
endfor
|
|
||||||
else
|
|
||||||
let str .= " {\n"
|
|
||||||
endif
|
|
||||||
|
|
||||||
let inner = ''
|
|
||||||
for child in current.child
|
|
||||||
let inner .= emmet#toString(child, type, inline, filters, itemno)
|
|
||||||
endfor
|
|
||||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
|
||||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
|
||||||
let str .= indent . inner . "\n}\n"
|
|
||||||
else
|
|
||||||
return emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
|
||||||
endif
|
|
||||||
return str
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#scss#imageSize() abort
|
|
||||||
call emmet#lang#css#imageSize()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#scss#encodeImage() abort
|
|
||||||
return emmet#lang#css#encodeImage()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#scss#parseTag(tag) abort
|
|
||||||
return emmet#lang#css#parseTag(a:tag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#scss#toggleComment() abort
|
|
||||||
call emmet#lang#css#toggleComment()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#scss#balanceTag(flag) range abort
|
|
||||||
if a:flag == -2 || a:flag == 2
|
|
||||||
let curpos = [0, line("'<"), col("'<"), 0]
|
|
||||||
call setpos('.', curpos)
|
|
||||||
else
|
|
||||||
let curpos = emmet#util#getcurpos()
|
|
||||||
endif
|
|
||||||
if a:flag < 0
|
|
||||||
let ret = searchpair('}', '', '.\zs{')
|
|
||||||
else
|
|
||||||
let ret = searchpair('{', '', '}', 'bW')
|
|
||||||
endif
|
|
||||||
if ret > 0
|
|
||||||
let pos1 = emmet#util#getcurpos()[1:2]
|
|
||||||
if a:flag < 0
|
|
||||||
let pos2 = searchpairpos('{', '', '}')
|
|
||||||
else
|
|
||||||
let pos2 = searchpairpos('{', '', '}')
|
|
||||||
endif
|
|
||||||
let block = [pos1, pos2]
|
|
||||||
if emmet#util#regionIsValid(block)
|
|
||||||
call emmet#util#selectRegion(block)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if a:flag == -2 || a:flag == 2
|
|
||||||
silent! exe 'normal! gv'
|
|
||||||
else
|
|
||||||
call setpos('.', curpos)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#scss#moveNextPrevItem(flag) abort
|
|
||||||
return emmet#lang#scss#moveNextPrev(a:flag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#scss#moveNextPrev(flag) abort
|
|
||||||
call emmet#lang#css#moveNextPrev(a:flag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#scss#splitJoinTag() abort
|
|
||||||
call emmet#lang#css#splitJoinTag()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#scss#removeTag() abort
|
|
||||||
call emmet#lang#css#removeTag()
|
|
||||||
endfunction
|
|
|
@ -1,281 +0,0 @@
|
||||||
function! emmet#lang#slim#findTokens(str) abort
|
|
||||||
return emmet#lang#html#findTokens(a:str)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#slim#parseIntoTree(abbr, type) abort
|
|
||||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent) abort
|
|
||||||
let current = a:current
|
|
||||||
let type = a:type
|
|
||||||
let inline = a:inline
|
|
||||||
let filters = a:filters
|
|
||||||
let itemno = a:itemno
|
|
||||||
let indent = emmet#getIndentation(type)
|
|
||||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
|
||||||
let str = ''
|
|
||||||
|
|
||||||
let current_name = current.name
|
|
||||||
if dollar_expr
|
|
||||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
|
||||||
endif
|
|
||||||
if len(current.name) > 0
|
|
||||||
let str .= current_name
|
|
||||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
|
||||||
if !has_key(current.attr, attr)
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
let Val = current.attr[attr]
|
|
||||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
|
||||||
let str .= ' ' . attr . '=true'
|
|
||||||
else
|
|
||||||
if dollar_expr
|
|
||||||
while Val =~# '\$\([^#{]\|$\)'
|
|
||||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
|
||||||
let str .= ' ' . attr . '="' . Val . '"'
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
let inner = ''
|
|
||||||
if len(current.value) > 0
|
|
||||||
let str .= "\n"
|
|
||||||
let text = current.value[1:-2]
|
|
||||||
if dollar_expr
|
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
|
||||||
let str = substitute(str, '\$#', text, 'g')
|
|
||||||
endif
|
|
||||||
for line in split(text, "\n")
|
|
||||||
let str .= indent . '| ' . line . "\n"
|
|
||||||
endfor
|
|
||||||
elseif len(current.child) == 0
|
|
||||||
let str .= '${cursor}'
|
|
||||||
endif
|
|
||||||
if len(current.child) == 1 && len(current.child[0].name) == 0
|
|
||||||
let str .= "\n"
|
|
||||||
let text = current.child[0].value[1:-2]
|
|
||||||
if dollar_expr
|
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
|
||||||
endif
|
|
||||||
for line in split(text, "\n")
|
|
||||||
let str .= indent . '| ' . line . "\n"
|
|
||||||
endfor
|
|
||||||
elseif len(current.child) > 0
|
|
||||||
for child in current.child
|
|
||||||
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
|
|
||||||
endfor
|
|
||||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
|
||||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
|
||||||
let str .= "\n" . indent . inner
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let str = current.value[1:-2]
|
|
||||||
if dollar_expr
|
|
||||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
|
||||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
|
||||||
let str = substitute(str, '\\\$', '$', 'g')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if str !~# "\n$"
|
|
||||||
let str .= "\n"
|
|
||||||
endif
|
|
||||||
return str
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#slim#imageSize() abort
|
|
||||||
let line = getline('.')
|
|
||||||
let current = emmet#lang#slim#parseTag(line)
|
|
||||||
if empty(current) || !has_key(current.attr, 'src')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let fn = current.attr.src
|
|
||||||
if fn =~# '^\s*$'
|
|
||||||
return
|
|
||||||
elseif fn !~# '^\(/\|http\)'
|
|
||||||
let fn = simplify(expand('%:h') . '/' . fn)
|
|
||||||
endif
|
|
||||||
|
|
||||||
let [width, height] = emmet#util#getImageSize(fn)
|
|
||||||
if width == -1 && height == -1
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let current.attr.width = width
|
|
||||||
let current.attr.height = height
|
|
||||||
let current.attrs_order += ['width', 'height']
|
|
||||||
let slim = emmet#toString(current, 'slim', 1)
|
|
||||||
let slim = substitute(slim, '\${cursor}', '', '')
|
|
||||||
call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", '', 'g'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#slim#encodeImage() abort
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#slim#parseTag(tag) abort
|
|
||||||
let current = emmet#newNode()
|
|
||||||
let mx = '\([a-zA-Z][a-zA-Z0-9]*\)\s\+\(.*\)'
|
|
||||||
let match = matchstr(a:tag, mx)
|
|
||||||
let current.name = substitute(match, mx, '\1', '')
|
|
||||||
let attrs = substitute(match, mx, '\2', '')
|
|
||||||
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
|
||||||
while len(attrs) > 0
|
|
||||||
let match = matchstr(attrs, mx)
|
|
||||||
if len(match) == 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let attr_match = matchlist(match, mx)
|
|
||||||
let name = attr_match[1]
|
|
||||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
|
||||||
let current.attr[name] = value
|
|
||||||
let current.attrs_order += [name]
|
|
||||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
|
||||||
endwhile
|
|
||||||
return current
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#slim#toggleComment() abort
|
|
||||||
let line = getline('.')
|
|
||||||
let space = matchstr(line, '^\s*')
|
|
||||||
if line =~# '^\s*/'
|
|
||||||
call setline('.', space . line[len(space)+1:])
|
|
||||||
elseif line =~# '^\s*[a-z]'
|
|
||||||
call setline('.', space . '/' . line[len(space):])
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#slim#balanceTag(flag) range abort
|
|
||||||
let block = emmet#util#getVisualBlock()
|
|
||||||
if a:flag == -2 || a:flag == 2
|
|
||||||
let curpos = [0, line("'<"), col("'<"), 0]
|
|
||||||
else
|
|
||||||
let curpos = emmet#util#getcurpos()
|
|
||||||
endif
|
|
||||||
let n = curpos[1]
|
|
||||||
let ml = len(matchstr(getline(n), '^\s*'))
|
|
||||||
|
|
||||||
if a:flag > 0
|
|
||||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
|
||||||
let n = line('.')
|
|
||||||
else
|
|
||||||
while n > 0
|
|
||||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
|
||||||
if l > 0 && l < ml
|
|
||||||
let ml = l
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n -= 1
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
let sn = n
|
|
||||||
if n == 0
|
|
||||||
let ml = 0
|
|
||||||
endif
|
|
||||||
while n < line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
|
||||||
if l > 0 && l <= ml
|
|
||||||
let n -= 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
call setpos('.', [0, n, 1, 0])
|
|
||||||
normal! V
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
else
|
|
||||||
while n > 0
|
|
||||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
|
||||||
if l > 0 && l > ml
|
|
||||||
let ml = l
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
let sn = n
|
|
||||||
if n == 0
|
|
||||||
let ml = 0
|
|
||||||
endif
|
|
||||||
while n < line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
|
||||||
if l > 0 && l <= ml
|
|
||||||
let n -= 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
call setpos('.', [0, n, 1, 0])
|
|
||||||
normal! V
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#slim#moveNextPrevItem(flag) abort
|
|
||||||
return emmet#lang#slim#moveNextPrev(a:flag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#slim#moveNextPrev(flag) abort
|
|
||||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
|
||||||
if pos == 2
|
|
||||||
startinsert!
|
|
||||||
elseif pos != 0
|
|
||||||
silent! normal! l
|
|
||||||
startinsert
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#slim#splitJoinTag() abort
|
|
||||||
let n = line('.')
|
|
||||||
while n > 0
|
|
||||||
if getline(n) =~# '^\s*\ze[a-z]'
|
|
||||||
let sn = n
|
|
||||||
let n += 1
|
|
||||||
if getline(n) =~# '^\s*|'
|
|
||||||
while n <= line('$')
|
|
||||||
if getline(n) !~# '^\s*|'
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
exe n 'delete'
|
|
||||||
endwhile
|
|
||||||
call setpos('.', [0, sn, 1, 0])
|
|
||||||
else
|
|
||||||
let spaces = matchstr(getline(sn), '^\s*')
|
|
||||||
call append(sn, spaces . ' | ')
|
|
||||||
call setpos('.', [0, sn+1, 1, 0])
|
|
||||||
startinsert!
|
|
||||||
endif
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n -= 1
|
|
||||||
endwhile
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#lang#slim#removeTag() abort
|
|
||||||
let n = line('.')
|
|
||||||
let ml = 0
|
|
||||||
while n > 0
|
|
||||||
if getline(n) =~# '^\s*\ze[a-z]'
|
|
||||||
let ml = len(matchstr(getline(n), '^\s*[a-z]'))
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n -= 1
|
|
||||||
endwhile
|
|
||||||
let sn = n
|
|
||||||
while n < line('$')
|
|
||||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
|
||||||
if l > 0 && l <= ml
|
|
||||||
let n -= 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let n += 1
|
|
||||||
endwhile
|
|
||||||
if sn == n
|
|
||||||
exe 'delete'
|
|
||||||
else
|
|
||||||
exe sn ',' (n-1) 'delete'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
|
@ -1,65 +0,0 @@
|
||||||
function! emmet#lorem#en#expand(command) abort
|
|
||||||
let wcount = matchstr(a:command, '\(\d*\)$')
|
|
||||||
let wcount = wcount > 0 ? wcount : 30
|
|
||||||
|
|
||||||
let common = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit']
|
|
||||||
let words = ['exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet',
|
|
||||||
\ 'sunt', 'iure', 'nam', 'nobis', 'eum', 'cum', 'officiis', 'excepturi',
|
|
||||||
\ 'odio', 'consectetur', 'quasi', 'aut', 'quisquam', 'vel', 'eligendi',
|
|
||||||
\ 'itaque', 'non', 'odit', 'tempore', 'quaerat', 'dignissimos',
|
|
||||||
\ 'facilis', 'neque', 'nihil', 'expedita', 'vitae', 'vero', 'ipsum',
|
|
||||||
\ 'nisi', 'animi', 'cumque', 'pariatur', 'velit', 'modi', 'natus',
|
|
||||||
\ 'iusto', 'eaque', 'sequi', 'illo', 'sed', 'ex', 'et', 'voluptatibus',
|
|
||||||
\ 'tempora', 'veritatis', 'ratione', 'assumenda', 'incidunt', 'nostrum',
|
|
||||||
\ 'placeat', 'aliquid', 'fuga', 'provident', 'praesentium', 'rem',
|
|
||||||
\ 'necessitatibus', 'suscipit', 'adipisci', 'quidem', 'possimus',
|
|
||||||
\ 'voluptas', 'debitis', 'sint', 'accusantium', 'unde', 'sapiente',
|
|
||||||
\ 'voluptate', 'qui', 'aspernatur', 'laudantium', 'soluta', 'amet',
|
|
||||||
\ 'quo', 'aliquam', 'saepe', 'culpa', 'libero', 'ipsa', 'dicta',
|
|
||||||
\ 'reiciendis', 'nesciunt', 'doloribus', 'autem', 'impedit', 'minima',
|
|
||||||
\ 'maiores', 'repudiandae', 'ipsam', 'obcaecati', 'ullam', 'enim',
|
|
||||||
\ 'totam', 'delectus', 'ducimus', 'quis', 'voluptates', 'dolores',
|
|
||||||
\ 'molestiae', 'harum', 'dolorem', 'quia', 'voluptatem', 'molestias',
|
|
||||||
\ 'magni', 'distinctio', 'omnis', 'illum', 'dolorum', 'voluptatum', 'ea',
|
|
||||||
\ 'quas', 'quam', 'corporis', 'quae', 'blanditiis', 'atque', 'deserunt',
|
|
||||||
\ 'laboriosam', 'earum', 'consequuntur', 'hic', 'cupiditate',
|
|
||||||
\ 'quibusdam', 'accusamus', 'ut', 'rerum', 'error', 'minus', 'eius',
|
|
||||||
\ 'ab', 'ad', 'nemo', 'fugit', 'officia', 'at', 'in', 'id', 'quos',
|
|
||||||
\ 'reprehenderit', 'numquam', 'iste', 'fugiat', 'sit', 'inventore',
|
|
||||||
\ 'beatae', 'repellendus', 'magnam', 'recusandae', 'quod', 'explicabo',
|
|
||||||
\ 'doloremque', 'aperiam', 'consequatur', 'asperiores', 'commodi',
|
|
||||||
\ 'optio', 'dolor', 'labore', 'temporibus', 'repellat', 'veniam',
|
|
||||||
\ 'architecto', 'est', 'esse', 'mollitia', 'nulla', 'a', 'similique',
|
|
||||||
\ 'eos', 'alias', 'dolore', 'tenetur', 'deleniti', 'porro', 'facere',
|
|
||||||
\ 'maxime', 'corrupti']
|
|
||||||
let ret = []
|
|
||||||
let sentence = 0
|
|
||||||
for i in range(wcount)
|
|
||||||
let arr = common
|
|
||||||
if sentence > 0
|
|
||||||
let arr += words
|
|
||||||
endif
|
|
||||||
let r = emmet#util#rand()
|
|
||||||
let word = arr[r % len(arr)]
|
|
||||||
if sentence == 0
|
|
||||||
let word = substitute(word, '^.', '\U&', '')
|
|
||||||
endif
|
|
||||||
let sentence += 1
|
|
||||||
call add(ret, word)
|
|
||||||
if (sentence > 5 && emmet#util#rand() < 10000) || i == wcount - 1
|
|
||||||
if i == wcount - 1
|
|
||||||
let endc = '?!...'[emmet#util#rand() % 5]
|
|
||||||
call add(ret, endc)
|
|
||||||
else
|
|
||||||
let endc = '?!,...'[emmet#util#rand() % 6]
|
|
||||||
call add(ret, endc . ' ')
|
|
||||||
endif
|
|
||||||
if endc !=# ','
|
|
||||||
let sentence = 0
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
call add(ret, ' ')
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
return join(ret, '')
|
|
||||||
endfunction
|
|
|
@ -1,27 +0,0 @@
|
||||||
scriptencoding utf-8
|
|
||||||
|
|
||||||
function! emmet#lorem#ja#expand(command) abort
|
|
||||||
let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '')
|
|
||||||
let wcount = wcount > 0 ? wcount : 30
|
|
||||||
|
|
||||||
let url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html"
|
|
||||||
let content = emmet#util#cache(url)
|
|
||||||
if len(content) == 0
|
|
||||||
let content = emmet#util#getContentFromURL(url)
|
|
||||||
let content = matchstr(content, '<div[^>]*>\zs.\{-}</div>')
|
|
||||||
let content = substitute(content, '[ \r]', '', 'g')
|
|
||||||
let content = substitute(content, '<br[^>]*>', "\n", 'g')
|
|
||||||
let content = substitute(content, '<[^>]\+>', '', 'g')
|
|
||||||
let content = join(filter(split(content, "\n"), 'len(v:val)>0'), "\n")
|
|
||||||
call emmet#util#cache(url, content)
|
|
||||||
endif
|
|
||||||
|
|
||||||
let content = substitute(content, "、\n", "、", "g")
|
|
||||||
let clines = split(content, '\n')
|
|
||||||
let lines = filter(clines, 'len(substitute(v:val,".",".","g"))<=wcount')
|
|
||||||
if len(lines) == 0
|
|
||||||
let lines = clines
|
|
||||||
endif
|
|
||||||
let r = emmet#util#rand()
|
|
||||||
return lines[r % len(lines)]
|
|
||||||
endfunction
|
|
|
@ -1,349 +0,0 @@
|
||||||
"==============================================================================
|
|
||||||
" region utils
|
|
||||||
"==============================================================================
|
|
||||||
" deleteContent : delete content in region
|
|
||||||
" if region make from between '<foo>' and '</foo>'
|
|
||||||
" --------------------
|
|
||||||
" begin:<foo>
|
|
||||||
" </foo>:end
|
|
||||||
" --------------------
|
|
||||||
" this function make the content as following
|
|
||||||
" --------------------
|
|
||||||
" begin::end
|
|
||||||
" --------------------
|
|
||||||
function! emmet#util#deleteContent(region) abort
|
|
||||||
let lines = getline(a:region[0][0], a:region[1][0])
|
|
||||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
|
||||||
silent! exe 'delete '.(a:region[1][0] - a:region[0][0])
|
|
||||||
call setline(line('.'), lines[0][:a:region[0][1]-2] . lines[-1][a:region[1][1]])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" change_content : change content in region
|
|
||||||
" if region make from between '<foo>' and '</foo>'
|
|
||||||
" --------------------
|
|
||||||
" begin:<foo>
|
|
||||||
" </foo>:end
|
|
||||||
" --------------------
|
|
||||||
" and content is
|
|
||||||
" --------------------
|
|
||||||
" foo
|
|
||||||
" bar
|
|
||||||
" baz
|
|
||||||
" --------------------
|
|
||||||
" this function make the content as following
|
|
||||||
" --------------------
|
|
||||||
" begin:foo
|
|
||||||
" bar
|
|
||||||
" baz:end
|
|
||||||
" --------------------
|
|
||||||
function! emmet#util#setContent(region, content) abort
|
|
||||||
let newlines = split(a:content, '\n', 1)
|
|
||||||
let oldlines = getline(a:region[0][0], a:region[1][0])
|
|
||||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
|
||||||
silent! exe 'delete '.(a:region[1][0] - a:region[0][0])
|
|
||||||
if len(newlines) == 0
|
|
||||||
let tmp = ''
|
|
||||||
if a:region[0][1] > 1
|
|
||||||
let tmp = oldlines[0][:a:region[0][1]-2]
|
|
||||||
endif
|
|
||||||
if a:region[1][1] >= 1
|
|
||||||
let tmp .= oldlines[-1][a:region[1][1]:]
|
|
||||||
endif
|
|
||||||
call setline(line('.'), tmp)
|
|
||||||
elseif len(newlines) == 1
|
|
||||||
if a:region[0][1] > 1
|
|
||||||
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
|
|
||||||
endif
|
|
||||||
if a:region[1][1] >= 1
|
|
||||||
let newlines[0] .= oldlines[-1][a:region[1][1]:]
|
|
||||||
endif
|
|
||||||
call setline(line('.'), newlines[0])
|
|
||||||
else
|
|
||||||
if a:region[0][1] > 1
|
|
||||||
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
|
|
||||||
endif
|
|
||||||
if a:region[1][1] >= 1
|
|
||||||
let newlines[-1] .= oldlines[-1][a:region[1][1]:]
|
|
||||||
endif
|
|
||||||
call setline(line('.'), newlines[0])
|
|
||||||
call append(line('.'), newlines[1:])
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" select_region : select region
|
|
||||||
" this function make a selection of region
|
|
||||||
function! emmet#util#selectRegion(region) abort
|
|
||||||
call setpos('.', [0, a:region[1][0], a:region[1][1], 0])
|
|
||||||
normal! v
|
|
||||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" point_in_region : check point is in the region
|
|
||||||
" this function return 0 or 1
|
|
||||||
function! emmet#util#pointInRegion(point, region) abort
|
|
||||||
if !emmet#util#regionIsValid(a:region) | return 0 | endif
|
|
||||||
if a:region[0][0] > a:point[0] | return 0 | endif
|
|
||||||
if a:region[1][0] < a:point[0] | return 0 | endif
|
|
||||||
if a:region[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif
|
|
||||||
if a:region[1][0] == a:point[0] && a:region[1][1] < a:point[1] | return 0 | endif
|
|
||||||
return 1
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" cursor_in_region : check cursor is in the region
|
|
||||||
" this function return 0 or 1
|
|
||||||
function! emmet#util#cursorInRegion(region) abort
|
|
||||||
if !emmet#util#regionIsValid(a:region) | return 0 | endif
|
|
||||||
let cur = emmet#util#getcurpos()[1:2]
|
|
||||||
return emmet#util#pointInRegion(cur, a:region)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" region_is_valid : check region is valid
|
|
||||||
" this function return 0 or 1
|
|
||||||
function! emmet#util#regionIsValid(region) abort
|
|
||||||
if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif
|
|
||||||
return 1
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" search_region : make region from pattern which is composing start/end
|
|
||||||
" this function return array of position
|
|
||||||
function! emmet#util#searchRegion(start, end) abort
|
|
||||||
let b = searchpairpos(a:start, '', a:end, 'bcnW')
|
|
||||||
if b == [0, 0]
|
|
||||||
return [searchpairpos(a:start, '', a:end, 'bnW'), searchpairpos(a:start, '\%#', a:end, 'nW')]
|
|
||||||
else
|
|
||||||
return [b, searchpairpos(a:start, '', a:end. '', 'nW')]
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" get_content : get content in region
|
|
||||||
" this function return string in region
|
|
||||||
function! emmet#util#getContent(region) abort
|
|
||||||
if !emmet#util#regionIsValid(a:region)
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
let lines = getline(a:region[0][0], a:region[1][0])
|
|
||||||
if a:region[0][0] == a:region[1][0]
|
|
||||||
let lines[0] = lines[0][a:region[0][1]-1:a:region[1][1]-1]
|
|
||||||
else
|
|
||||||
let lines[0] = lines[0][a:region[0][1]-1:]
|
|
||||||
let lines[-1] = lines[-1][:a:region[1][1]-1]
|
|
||||||
endif
|
|
||||||
return join(lines, "\n")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" region_in_region : check region is in the region
|
|
||||||
" this function return 0 or 1
|
|
||||||
function! emmet#util#regionInRegion(outer, inner) abort
|
|
||||||
if !emmet#util#regionIsValid(a:inner) || !emmet#util#regionIsValid(a:outer)
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
return emmet#util#pointInRegion(a:inner[0], a:outer) && emmet#util#pointInRegion(a:inner[1], a:outer)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" get_visualblock : get region of visual block
|
|
||||||
" this function return region of visual block
|
|
||||||
function! emmet#util#getVisualBlock() abort
|
|
||||||
return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"==============================================================================
|
|
||||||
" html utils
|
|
||||||
"==============================================================================
|
|
||||||
function! emmet#util#getContentFromURL(url) abort
|
|
||||||
let res = system(printf('%s -i %s', g:emmet_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
|
|
||||||
while res =~# '^HTTP/1.\d 3' || res =~# '^HTTP/1\.\d 200 Connection established' || res =~# '^HTTP/1\.\d 100 Continue'
|
|
||||||
let pos = stridx(res, "\r\n\r\n")
|
|
||||||
if pos != -1
|
|
||||||
let res = strpart(res, pos+4)
|
|
||||||
else
|
|
||||||
let pos = stridx(res, "\n\n")
|
|
||||||
let res = strpart(res, pos+2)
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
let pos = stridx(res, "\r\n\r\n")
|
|
||||||
if pos != -1
|
|
||||||
let content = strpart(res, pos+4)
|
|
||||||
else
|
|
||||||
let pos = stridx(res, "\n\n")
|
|
||||||
let content = strpart(res, pos+2)
|
|
||||||
endif
|
|
||||||
let header = res[:pos-1]
|
|
||||||
let charset = matchstr(content, '<meta[^>]\+content=["''][^;"'']\+;\s*charset=\zs[^;"'']\+\ze["''][^>]*>')
|
|
||||||
if len(charset) == 0
|
|
||||||
let charset = matchstr(content, '<meta\s\+charset=["'']\?\zs[^"'']\+\ze["'']\?[^>]*>')
|
|
||||||
endif
|
|
||||||
if len(charset) == 0
|
|
||||||
let charset = matchstr(header, '\nContent-Type:.* charset=[''"]\?\zs[^''";\n]\+\ze')
|
|
||||||
endif
|
|
||||||
if len(charset) == 0
|
|
||||||
let s1 = len(split(content, '?'))
|
|
||||||
let utf8 = iconv(content, 'utf-8', &encoding)
|
|
||||||
let s2 = len(split(utf8, '?'))
|
|
||||||
return (s2 == s1 || s2 >= s1 * 2) ? utf8 : content
|
|
||||||
endif
|
|
||||||
return iconv(content, charset, &encoding)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#util#getTextFromHTML(buf) abort
|
|
||||||
let threshold_len = 100
|
|
||||||
let threshold_per = 0.1
|
|
||||||
let buf = a:buf
|
|
||||||
|
|
||||||
let buf = strpart(buf, stridx(buf, '</head>'))
|
|
||||||
let buf = substitute(buf, '<style[^>]*>.\{-}</style>', '', 'g')
|
|
||||||
let buf = substitute(buf, '<script[^>]*>.\{-}</script>', '', 'g')
|
|
||||||
let res = ''
|
|
||||||
let max = 0
|
|
||||||
let mx = '\(<td[^>]\{-}>\)\|\(<\/td>\)\|\(<div[^>]\{-}>\)\|\(<\/div>\)'
|
|
||||||
let m = split(buf, mx)
|
|
||||||
for str in m
|
|
||||||
let c = split(str, '<[^>]*?>')
|
|
||||||
let str = substitute(str, '<[^>]\{-}>', ' ', 'g')
|
|
||||||
let str = substitute(str, '>', '>', 'g')
|
|
||||||
let str = substitute(str, '<', '<', 'g')
|
|
||||||
let str = substitute(str, '"', '"', 'g')
|
|
||||||
let str = substitute(str, ''', '''', 'g')
|
|
||||||
let str = substitute(str, ' ', ' ', 'g')
|
|
||||||
let str = substitute(str, '¥', '\¥', 'g')
|
|
||||||
let str = substitute(str, '&', '\&', 'g')
|
|
||||||
let str = substitute(str, '^\s*\(.*\)\s*$', '\1', '')
|
|
||||||
let str = substitute(str, '\s\+', ' ', 'g')
|
|
||||||
let l = len(str)
|
|
||||||
if l > threshold_len
|
|
||||||
let per = (l+0.0) / len(c)
|
|
||||||
if max < l && per > threshold_per
|
|
||||||
let max = l
|
|
||||||
let res = str
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
let res = substitute(res, '^\s*\(.*\)\s*$', '\1', 'g')
|
|
||||||
return res
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#util#getImageSize(fn) abort
|
|
||||||
let fn = a:fn
|
|
||||||
|
|
||||||
if emmet#util#isImageMagickInstalled()
|
|
||||||
return emmet#util#imageSizeWithImageMagick(fn)
|
|
||||||
endif
|
|
||||||
|
|
||||||
if filereadable(fn)
|
|
||||||
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
|
|
||||||
else
|
|
||||||
if fn !~# '^\w\+://'
|
|
||||||
let path = fnamemodify(expand('%'), ':p:gs?\\?/?')
|
|
||||||
if has('win32') || has('win64') |
|
|
||||||
let path = tolower(path)
|
|
||||||
endif
|
|
||||||
for k in keys(g:emmet_docroot)
|
|
||||||
let root = fnamemodify(k, ':p:gs?\\?/?')
|
|
||||||
if has('win32') || has('win64') |
|
|
||||||
let root = tolower(root)
|
|
||||||
endif
|
|
||||||
if stridx(path, root) == 0
|
|
||||||
let v = g:emmet_docroot[k]
|
|
||||||
let fn = (len(v) == 0 ? k : v) . fn
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
let hex = substitute(system(g:emmet_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g')
|
|
||||||
endif
|
|
||||||
|
|
||||||
let [width, height] = [-1, -1]
|
|
||||||
if hex =~# '^89504e470d0a1a0a'
|
|
||||||
let width = eval('0x'.hex[32:39])
|
|
||||||
let height = eval('0x'.hex[40:47])
|
|
||||||
endif
|
|
||||||
if hex =~# '^ffd8'
|
|
||||||
let pos = 4
|
|
||||||
while pos < len(hex)
|
|
||||||
let bs = hex[pos+0:pos+3]
|
|
||||||
let pos += 4
|
|
||||||
if bs ==# 'ffc0' || bs ==# 'ffc2'
|
|
||||||
let pos += 6
|
|
||||||
let height = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
|
|
||||||
let pos += 4
|
|
||||||
let width = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
|
|
||||||
break
|
|
||||||
elseif bs =~# 'ffd[9a]'
|
|
||||||
break
|
|
||||||
elseif bs =~# 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)'
|
|
||||||
let pos += (eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])) * 2
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
if hex =~# '^47494638'
|
|
||||||
let width = eval('0x'.hex[14:15].hex[12:13])
|
|
||||||
let height = eval('0x'.hex[18:19].hex[16:17])
|
|
||||||
endif
|
|
||||||
|
|
||||||
return [width, height]
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#util#imageSizeWithImageMagick(fn) abort
|
|
||||||
let img_info = system('identify -format "%wx%h" "'.a:fn.'"')
|
|
||||||
let img_size = split(substitute(img_info, '\n', '', ''), 'x')
|
|
||||||
if len(img_size) != 2
|
|
||||||
return [-1, -1]
|
|
||||||
endif
|
|
||||||
return img_size
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#util#isImageMagickInstalled() abort
|
|
||||||
if !get(s:, 'emmet_use_identify', 1)
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
return executable('identify')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#util#unique(arr) abort
|
|
||||||
let m = {}
|
|
||||||
let r = []
|
|
||||||
for i in a:arr
|
|
||||||
if !has_key(m, i)
|
|
||||||
let m[i] = 1
|
|
||||||
call add(r, i)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
return r
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
let s:seed = localtime()
|
|
||||||
function! emmet#util#srand(seed) abort
|
|
||||||
let s:seed = a:seed
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#util#rand() abort
|
|
||||||
let s:seed = s:seed * 214013 + 2531011
|
|
||||||
return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#util#cache(name, ...) abort
|
|
||||||
let content = get(a:000, 0, '')
|
|
||||||
let dir = expand('~/.emmet/cache')
|
|
||||||
if !isdirectory(dir)
|
|
||||||
call mkdir(dir, 'p', 0700)
|
|
||||||
endif
|
|
||||||
let file = dir . '/' . substitute(a:name, '\W', '_', 'g')
|
|
||||||
if len(content) == 0
|
|
||||||
if !filereadable(file)
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
return join(readfile(file), "\n")
|
|
||||||
endif
|
|
||||||
call writefile(split(content, "\n"), file)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#util#getcurpos() abort
|
|
||||||
let pos = getpos('.')
|
|
||||||
if mode(0) ==# 'i' && pos[2] > 0
|
|
||||||
let pos[2] -=1
|
|
||||||
endif
|
|
||||||
return pos
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! emmet#util#closePopup() abort
|
|
||||||
return pumvisible() ? "\<c-e>" : ''
|
|
||||||
endfunction
|
|
|
@ -1,264 +0,0 @@
|
||||||
" pathogen.vim - path option manipulation
|
|
||||||
" Maintainer: Tim Pope <http://tpo.pe/>
|
|
||||||
" Version: 2.4
|
|
||||||
|
|
||||||
" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
|
|
||||||
"
|
|
||||||
" For management of individually installed plugins in ~/.vim/bundle (or
|
|
||||||
" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your
|
|
||||||
" .vimrc is the only other setup necessary.
|
|
||||||
"
|
|
||||||
" The API is documented inline below.
|
|
||||||
|
|
||||||
if exists("g:loaded_pathogen") || &cp
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let g:loaded_pathogen = 1
|
|
||||||
|
|
||||||
" Point of entry for basic default usage. Give a relative path to invoke
|
|
||||||
" pathogen#interpose() or an absolute path to invoke pathogen#surround().
|
|
||||||
" Curly braces are expanded with pathogen#expand(): "bundle/{}" finds all
|
|
||||||
" subdirectories inside "bundle" inside all directories in the runtime path.
|
|
||||||
" If no arguments are given, defaults "bundle/{}", and also "pack/{}/start/{}"
|
|
||||||
" on versions of Vim without native package support.
|
|
||||||
function! pathogen#infect(...) abort
|
|
||||||
if a:0
|
|
||||||
let paths = filter(reverse(copy(a:000)), 'type(v:val) == type("")')
|
|
||||||
else
|
|
||||||
let paths = ['bundle/{}', 'pack/{}/start/{}']
|
|
||||||
endif
|
|
||||||
if has('packages')
|
|
||||||
call filter(paths, 'v:val !~# "^pack/[^/]*/start/[^/]*$"')
|
|
||||||
endif
|
|
||||||
let static = '^\%([$~\\/]\|\w:[\\/]\)[^{}*]*$'
|
|
||||||
for path in filter(copy(paths), 'v:val =~# static')
|
|
||||||
call pathogen#surround(path)
|
|
||||||
endfor
|
|
||||||
for path in filter(copy(paths), 'v:val !~# static')
|
|
||||||
if path =~# '^\%([$~\\/]\|\w:[\\/]\)'
|
|
||||||
call pathogen#surround(path)
|
|
||||||
else
|
|
||||||
call pathogen#interpose(path)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
call pathogen#cycle_filetype()
|
|
||||||
if pathogen#is_disabled($MYVIMRC)
|
|
||||||
return 'finish'
|
|
||||||
endif
|
|
||||||
return ''
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Split a path into a list.
|
|
||||||
function! pathogen#split(path) abort
|
|
||||||
if type(a:path) == type([]) | return a:path | endif
|
|
||||||
if empty(a:path) | return [] | endif
|
|
||||||
let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
|
|
||||||
return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Convert a list to a path.
|
|
||||||
function! pathogen#join(...) abort
|
|
||||||
if type(a:1) == type(1) && a:1
|
|
||||||
let i = 1
|
|
||||||
let space = ' '
|
|
||||||
else
|
|
||||||
let i = 0
|
|
||||||
let space = ''
|
|
||||||
endif
|
|
||||||
let path = ""
|
|
||||||
while i < a:0
|
|
||||||
if type(a:000[i]) == type([])
|
|
||||||
let list = a:000[i]
|
|
||||||
let j = 0
|
|
||||||
while j < len(list)
|
|
||||||
let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
|
|
||||||
let path .= ',' . escaped
|
|
||||||
let j += 1
|
|
||||||
endwhile
|
|
||||||
else
|
|
||||||
let path .= "," . a:000[i]
|
|
||||||
endif
|
|
||||||
let i += 1
|
|
||||||
endwhile
|
|
||||||
return substitute(path,'^,','','')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
|
|
||||||
function! pathogen#legacyjoin(...) abort
|
|
||||||
return call('pathogen#join',[1] + a:000)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Turn filetype detection off and back on again if it was already enabled.
|
|
||||||
function! pathogen#cycle_filetype() abort
|
|
||||||
if exists('g:did_load_filetypes')
|
|
||||||
filetype off
|
|
||||||
filetype on
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Check if a bundle is disabled. A bundle is considered disabled if its
|
|
||||||
" basename or full name is included in the list g:pathogen_blacklist or the
|
|
||||||
" comma delimited environment variable $VIMBLACKLIST.
|
|
||||||
function! pathogen#is_disabled(path) abort
|
|
||||||
if a:path =~# '\~$'
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
let sep = pathogen#slash()
|
|
||||||
let blacklist = get(g:, 'pathogen_blacklist', get(g:, 'pathogen_disabled', [])) + pathogen#split($VIMBLACKLIST)
|
|
||||||
if !empty(blacklist)
|
|
||||||
call map(blacklist, 'substitute(v:val, "[\\/]$", "", "")')
|
|
||||||
endif
|
|
||||||
return index(blacklist, fnamemodify(a:path, ':t')) != -1 || index(blacklist, a:path) != -1
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Prepend the given directory to the runtime path and append its corresponding
|
|
||||||
" after directory. Curly braces are expanded with pathogen#expand().
|
|
||||||
function! pathogen#surround(path) abort
|
|
||||||
let sep = pathogen#slash()
|
|
||||||
let rtp = pathogen#split(&rtp)
|
|
||||||
let path = fnamemodify(a:path, ':s?[\\/]\=$??')
|
|
||||||
let before = filter(pathogen#expand(path), '!pathogen#is_disabled(v:val)')
|
|
||||||
let after = filter(reverse(pathogen#expand(path, sep.'after')), '!pathogen#is_disabled(v:val[0:-7])')
|
|
||||||
call filter(rtp, 'index(before + after, v:val) == -1')
|
|
||||||
let &rtp = pathogen#join(before, rtp, after)
|
|
||||||
return &rtp
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" For each directory in the runtime path, add a second entry with the given
|
|
||||||
" argument appended. Curly braces are expanded with pathogen#expand().
|
|
||||||
function! pathogen#interpose(name) abort
|
|
||||||
let sep = pathogen#slash()
|
|
||||||
let name = a:name
|
|
||||||
if has_key(s:done_bundles, name)
|
|
||||||
return ""
|
|
||||||
endif
|
|
||||||
let s:done_bundles[name] = 1
|
|
||||||
let list = []
|
|
||||||
for dir in pathogen#split(&rtp)
|
|
||||||
if dir =~# '\<after$'
|
|
||||||
let list += reverse(filter(pathogen#expand(dir[0:-6].name, sep.'after'), '!pathogen#is_disabled(v:val[0:-7])')) + [dir]
|
|
||||||
else
|
|
||||||
let list += [dir] + filter(pathogen#expand(dir.sep.name), '!pathogen#is_disabled(v:val)')
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
let &rtp = pathogen#join(pathogen#uniq(list))
|
|
||||||
return 1
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
let s:done_bundles = {}
|
|
||||||
|
|
||||||
" Invoke :helptags on all non-$VIM doc directories in runtimepath.
|
|
||||||
function! pathogen#helptags() abort
|
|
||||||
let sep = pathogen#slash()
|
|
||||||
for glob in pathogen#split(&rtp)
|
|
||||||
for dir in map(split(glob(glob), "\n"), 'v:val.sep."/doc/".sep')
|
|
||||||
if (dir)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir) == 2 && !empty(split(glob(dir.'*.txt'))) && (!filereadable(dir.'tags') || filewritable(dir.'tags'))
|
|
||||||
silent! execute 'helptags' pathogen#fnameescape(dir)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endfor
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command! -bar Helptags :call pathogen#helptags()
|
|
||||||
|
|
||||||
" Execute the given command. This is basically a backdoor for --remote-expr.
|
|
||||||
function! pathogen#execute(...) abort
|
|
||||||
for command in a:000
|
|
||||||
execute command
|
|
||||||
endfor
|
|
||||||
return ''
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Section: Unofficial
|
|
||||||
|
|
||||||
function! pathogen#is_absolute(path) abort
|
|
||||||
return a:path =~# (has('win32') ? '^\%([\\/]\|\w:\)[\\/]\|^[~$]' : '^[/~$]')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Given a string, returns all possible permutations of comma delimited braced
|
|
||||||
" alternatives of that string. pathogen#expand('/{a,b}/{c,d}') yields
|
|
||||||
" ['/a/c', '/a/d', '/b/c', '/b/d']. Empty braces are treated as a wildcard
|
|
||||||
" and globbed. Actual globs are preserved.
|
|
||||||
function! pathogen#expand(pattern, ...) abort
|
|
||||||
let after = a:0 ? a:1 : ''
|
|
||||||
let pattern = substitute(a:pattern, '^[~$][^\/]*', '\=expand(submatch(0))', '')
|
|
||||||
if pattern =~# '{[^{}]\+}'
|
|
||||||
let [pre, pat, post] = split(substitute(pattern, '\(.\{-\}\){\([^{}]\+\)}\(.*\)', "\\1\001\\2\001\\3", ''), "\001", 1)
|
|
||||||
let found = map(split(pat, ',', 1), 'pre.v:val.post')
|
|
||||||
let results = []
|
|
||||||
for pattern in found
|
|
||||||
call extend(results, pathogen#expand(pattern))
|
|
||||||
endfor
|
|
||||||
elseif pattern =~# '{}'
|
|
||||||
let pat = matchstr(pattern, '^.*{}[^*]*\%($\|[\\/]\)')
|
|
||||||
let post = pattern[strlen(pat) : -1]
|
|
||||||
let results = map(split(glob(substitute(pat, '{}', '*', 'g')), "\n"), 'v:val.post')
|
|
||||||
else
|
|
||||||
let results = [pattern]
|
|
||||||
endif
|
|
||||||
let vf = pathogen#slash() . 'vimfiles'
|
|
||||||
call map(results, 'v:val =~# "\\*" ? v:val.after : isdirectory(v:val.vf.after) ? v:val.vf.after : isdirectory(v:val.after) ? v:val.after : ""')
|
|
||||||
return filter(results, '!empty(v:val)')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" \ on Windows unless shellslash is set, / everywhere else.
|
|
||||||
function! pathogen#slash() abort
|
|
||||||
return !exists("+shellslash") || &shellslash ? '/' : '\'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! pathogen#separator() abort
|
|
||||||
return pathogen#slash()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Convenience wrapper around glob() which returns a list.
|
|
||||||
function! pathogen#glob(pattern) abort
|
|
||||||
let files = split(glob(a:pattern),"\n")
|
|
||||||
return map(files,'substitute(v:val,"[".pathogen#slash()."/]$","","")')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Like pathogen#glob(), only limit the results to directories.
|
|
||||||
function! pathogen#glob_directories(pattern) abort
|
|
||||||
return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Remove duplicates from a list.
|
|
||||||
function! pathogen#uniq(list) abort
|
|
||||||
let i = 0
|
|
||||||
let seen = {}
|
|
||||||
while i < len(a:list)
|
|
||||||
if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
|
|
||||||
call remove(a:list,i)
|
|
||||||
elseif a:list[i] ==# ''
|
|
||||||
let i += 1
|
|
||||||
let empty = 1
|
|
||||||
else
|
|
||||||
let seen[a:list[i]] = 1
|
|
||||||
let i += 1
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
return a:list
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Backport of fnameescape().
|
|
||||||
function! pathogen#fnameescape(string) abort
|
|
||||||
if exists('*fnameescape')
|
|
||||||
return fnameescape(a:string)
|
|
||||||
elseif a:string ==# '-'
|
|
||||||
return '\-'
|
|
||||||
else
|
|
||||||
return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Like findfile(), but hardcoded to use the runtimepath.
|
|
||||||
function! pathogen#runtime_findfile(file,count) abort
|
|
||||||
let rtp = pathogen#join(1,pathogen#split(&rtp))
|
|
||||||
let file = findfile(a:file,rtp,a:count)
|
|
||||||
if file ==# ''
|
|
||||||
return ''
|
|
||||||
else
|
|
||||||
return fnamemodify(file,':p')
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=':
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,128 +0,0 @@
|
||||||
" Copyright 2013 LuoChen (luochen1990@gmail.com). Licensed under the Apache License 2.0.
|
|
||||||
|
|
||||||
if exists('s:loaded') | finish | endif | let s:loaded = 1
|
|
||||||
|
|
||||||
fun s:trim(s)
|
|
||||||
return substitute(a:s, '\v^\s*(.{-})\s*$', '\1', '')
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun s:concat(strs)
|
|
||||||
return join(filter(a:strs, "v:val !~ '^[ ]*$'"), ',')
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun s:resolve_parenthesis_with(init_state, p)
|
|
||||||
let [paren, contained, containedin, contains_prefix, contains, op] = a:init_state
|
|
||||||
let p = (type(a:p) == type([])) ? ((len(a:p) == 3) ? printf('start=#%s# step=%s end=#%s#', a:p[0], op, a:p[-1]) : printf('start=#%s# end=#%s#', a:p[0], a:p[-1])) : a:p "NOTE: preprocess the old style parentheses config
|
|
||||||
|
|
||||||
let ls = split(p, '\v%(%(start|step|end)\=(.)%(\1@!.)*\1[^ ]*|\w+%(\=[^ ]*)?) ?\zs', 0)
|
|
||||||
for s in ls
|
|
||||||
let [k, v] = [matchstr(s, '^[^=]\+\ze\(=\|$\)'), matchstr(s, '^[^=]\+=\zs.*')]
|
|
||||||
if k == 'step'
|
|
||||||
let op = s:trim(v)
|
|
||||||
elseif k == 'contains_prefix'
|
|
||||||
let contains_prefix = s:trim(v)
|
|
||||||
elseif k == 'contains'
|
|
||||||
let contains = s:concat([contains, s:trim(v)])
|
|
||||||
elseif k == 'containedin'
|
|
||||||
let containedin = s:concat([containedin, s:trim(v)])
|
|
||||||
elseif k == 'contained'
|
|
||||||
let contained = 1
|
|
||||||
else
|
|
||||||
let paren .= s
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
let rst = [paren, contained, containedin, contains_prefix, contains, op]
|
|
||||||
"echom json_encode(rst)
|
|
||||||
return rst
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun s:resolve_parenthesis_from_config(config)
|
|
||||||
return s:resolve_parenthesis_with(['', 0, '', a:config.contains_prefix, '', a:config.operators], a:config.parentheses_options)
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun s:synID(prefix, group, lv, id)
|
|
||||||
return a:prefix.'_lv'.a:lv.'_'.a:group.a:id
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun s:synGroupID(prefix, group, lv)
|
|
||||||
return a:prefix.a:group.'_lv'.a:lv
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun rainbow#syn(config)
|
|
||||||
let conf = a:config
|
|
||||||
let prefix = conf.syn_name_prefix
|
|
||||||
let cycle = conf.cycle
|
|
||||||
|
|
||||||
let glob_paran_opts = s:resolve_parenthesis_from_config(conf)
|
|
||||||
let b:rainbow_loaded = cycle
|
|
||||||
for id in range(len(conf.parentheses))
|
|
||||||
let [paren, contained, containedin, contains_prefix, contains, op] = s:resolve_parenthesis_with(glob_paran_opts, conf.parentheses[id])
|
|
||||||
for lv in range(cycle)
|
|
||||||
let lv2 = ((lv + cycle - 1) % cycle)
|
|
||||||
let [rid, pid, gid2] = [s:synID(prefix, 'r', lv, id), s:synID(prefix, 'p', lv, id), s:synGroupID(prefix, 'Regions', lv2)]
|
|
||||||
|
|
||||||
if len(op) > 2
|
|
||||||
exe 'syn match '.s:synID(prefix, 'o', lv, id).' '.op.' containedin='.s:synID(prefix, 'r', lv, id).' contained'
|
|
||||||
endif
|
|
||||||
|
|
||||||
let real_contained = (lv == 0)? (contained? 'contained ' : '') : 'contained '
|
|
||||||
let real_containedin = (lv == 0)? s:concat([containedin, '@'.gid2]) : '@'.gid2
|
|
||||||
let real_contains = s:concat([contains_prefix, contains])
|
|
||||||
exe 'syn region '.rid.' matchgroup='.pid.' '.real_contained.'containedin='.real_containedin.' contains='.real_contains.' '.paren
|
|
||||||
endfor
|
|
||||||
endfor
|
|
||||||
for lv in range(cycle)
|
|
||||||
exe 'syn cluster '.s:synGroupID(prefix, 'Regions', lv).' contains='.join(map(range(len(conf.parentheses)), 's:synID(prefix, "r", lv, v:val)'), ',')
|
|
||||||
exe 'syn cluster '.s:synGroupID(prefix, 'Parentheses', lv).' contains='.join(map(range(len(conf.parentheses)), 's:synID(prefix, "p", lv, v:val)'), ',')
|
|
||||||
exe 'syn cluster '.s:synGroupID(prefix, 'Operators', lv).' contains='.join(map(range(len(conf.parentheses)), 's:synID(prefix, "o", lv, v:val)'), ',')
|
|
||||||
endfor
|
|
||||||
exe 'syn cluster '.prefix.'Regions contains='.join(map(range(cycle), '"@".s:synGroupID(prefix, "Regions", v:val)'), ',')
|
|
||||||
exe 'syn cluster '.prefix.'Parentheses contains='.join(map(range(cycle), '"@".s:synGroupID(prefix, "Parentheses", v:val)'), ',')
|
|
||||||
exe 'syn cluster '.prefix.'Operators contains='.join(map(range(cycle), '"@".s:synGroupID(prefix, "Operators", v:val)'), ',')
|
|
||||||
if has_key(conf, 'after') | for cmd in conf.after | exe cmd | endfor | endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun rainbow#syn_clear(config)
|
|
||||||
let conf = a:config
|
|
||||||
let prefix = conf.syn_name_prefix
|
|
||||||
|
|
||||||
for id in range(len(conf.parentheses))
|
|
||||||
for lv in range(conf.cycle)
|
|
||||||
let [rid, oid] = [s:synID(prefix, 'r', lv, id), s:synID(prefix, 'o', lv, id)]
|
|
||||||
exe 'syn clear '.rid
|
|
||||||
exe 'syn clear '.oid
|
|
||||||
endfor
|
|
||||||
endfor
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun rainbow#hi(config)
|
|
||||||
let conf = a:config
|
|
||||||
let prefix = conf.syn_name_prefix
|
|
||||||
|
|
||||||
for id in range(len(conf.parentheses))
|
|
||||||
for lv in range(conf.cycle)
|
|
||||||
let [pid, oid] = [s:synID(prefix, 'p', lv, id), s:synID(prefix, 'o', lv, id)]
|
|
||||||
let ctermfg = conf.ctermfgs[lv % len(conf.ctermfgs)]
|
|
||||||
let guifg = conf.guifgs[lv % len(conf.guifgs)]
|
|
||||||
let cterm = conf.cterms[lv % len(conf.cterms)]
|
|
||||||
let gui = conf.guis[lv % len(conf.guis)]
|
|
||||||
let hi_style = 'ctermfg='.ctermfg.' guifg='.guifg.(len(cterm) > 0 ? ' cterm='.cterm : '').(len(gui) > 0 ? ' gui='.gui : '')
|
|
||||||
exe 'hi '.pid.' '.hi_style
|
|
||||||
exe 'hi '.oid.' '.hi_style
|
|
||||||
endfor
|
|
||||||
endfor
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun rainbow#hi_clear(config)
|
|
||||||
let conf = a:config
|
|
||||||
let prefix = conf.syn_name_prefix
|
|
||||||
|
|
||||||
for id in range(len(conf.parentheses))
|
|
||||||
for lv in range(conf.cycle)
|
|
||||||
let [pid, oid] = [s:synID(prefix, 'p', lv, id), s:synID(prefix, 'o', lv, id)]
|
|
||||||
exe 'hi clear '.pid
|
|
||||||
exe 'hi clear '.oid
|
|
||||||
endfor
|
|
||||||
endfor
|
|
||||||
endfun
|
|
||||||
|
|
|
@ -1,132 +0,0 @@
|
||||||
" Copyright 2013 LuoChen (luochen1990@gmail.com). Licensed under the Apache License 2.0.
|
|
||||||
|
|
||||||
let s:rainbow_conf = {
|
|
||||||
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
|
|
||||||
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
|
|
||||||
\ 'guis': [''],
|
|
||||||
\ 'cterms': [''],
|
|
||||||
\ 'operators': '_,_',
|
|
||||||
\ 'contains_prefix': 'TOP',
|
|
||||||
\ 'parentheses_options': '',
|
|
||||||
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
|
|
||||||
\ 'separately': {
|
|
||||||
\ '*': {},
|
|
||||||
\ 'markdown': {
|
|
||||||
\ 'parentheses_options': 'containedin=markdownCode contained',
|
|
||||||
\ },
|
|
||||||
\ 'lisp': {
|
|
||||||
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
|
|
||||||
\ },
|
|
||||||
\ 'haskell': {
|
|
||||||
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'],
|
|
||||||
\ },
|
|
||||||
\ 'ocaml': {
|
|
||||||
\ 'parentheses': ['start=/(\ze[^*]/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\[|/ end=/|\]/ fold', 'start=/{/ end=/}/ fold'],
|
|
||||||
\ },
|
|
||||||
\ 'tex': {
|
|
||||||
\ 'parentheses_options': 'containedin=texDocZone',
|
|
||||||
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
|
|
||||||
\ },
|
|
||||||
\ 'vim': {
|
|
||||||
\ 'parentheses_options': 'containedin=vimFuncBody,vimExecute',
|
|
||||||
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold'],
|
|
||||||
\ },
|
|
||||||
\ 'xml': {
|
|
||||||
\ 'syn_name_prefix': 'xmlRainbow',
|
|
||||||
\ 'parentheses': ['start=/\v\<\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'))?)*\>/ end=#</\z1># fold'],
|
|
||||||
\ },
|
|
||||||
\ 'xhtml': {
|
|
||||||
\ 'parentheses': ['start=/\v\<\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'))?)*\>/ end=#</\z1># fold'],
|
|
||||||
\ },
|
|
||||||
\ 'html': {
|
|
||||||
\ 'parentheses': ['start=/\v\<((script|style|area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
|
|
||||||
\ },
|
|
||||||
\ 'perl': {
|
|
||||||
\ 'syn_name_prefix': 'perlBlockFoldRainbow',
|
|
||||||
\ },
|
|
||||||
\ 'php': {
|
|
||||||
\ 'syn_name_prefix': 'phpBlockRainbow',
|
|
||||||
\ 'contains_prefix': '',
|
|
||||||
\ 'parentheses': ['start=/(/ end=/)/ containedin=@htmlPreproc contains=@phpClTop', 'start=/\[/ end=/\]/ containedin=@htmlPreproc contains=@phpClTop', 'start=/{/ end=/}/ containedin=@htmlPreproc contains=@phpClTop', 'start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold contains_prefix=TOP'],
|
|
||||||
\ },
|
|
||||||
\ 'stylus': {
|
|
||||||
\ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'],
|
|
||||||
\ },
|
|
||||||
\ 'css': 0,
|
|
||||||
\ 'sh': 0,
|
|
||||||
\ }
|
|
||||||
\}
|
|
||||||
|
|
||||||
fun s:eq(x, y)
|
|
||||||
return type(a:x) == type(a:y) && a:x == a:y
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun s:gcd(a, b)
|
|
||||||
let [a, b, t] = [a:a, a:b, 0]
|
|
||||||
while b != 0
|
|
||||||
let t = b
|
|
||||||
let b = a % b
|
|
||||||
let a = t
|
|
||||||
endwhile
|
|
||||||
return a
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun s:lcm(a, b)
|
|
||||||
return (a:a / s:gcd(a:a, a:b)) * a:b
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun rainbow_main#gen_config(ft)
|
|
||||||
let g = exists('g:rainbow_conf')? g:rainbow_conf : {}
|
|
||||||
"echom 'g:rainbow_conf:' string(g)
|
|
||||||
let s = get(g, 'separately', {})
|
|
||||||
"echom 'g:rainbow_conf.separately:' string(s)
|
|
||||||
let dft_conf = extend(copy(s:rainbow_conf), g) | unlet dft_conf.separately
|
|
||||||
"echom 'default config options:' string(dft_conf)
|
|
||||||
let dx_conf = s:rainbow_conf.separately['*']
|
|
||||||
"echom 'default star config:' string(dx_conf)
|
|
||||||
let ds_conf = get(s:rainbow_conf.separately, a:ft, dx_conf)
|
|
||||||
"echom 'default separately config:' string(ds_conf)
|
|
||||||
let ux_conf = get(s, '*', ds_conf)
|
|
||||||
"echom 'user star config:' string(ux_conf)
|
|
||||||
let us_conf = get(s, a:ft, ux_conf)
|
|
||||||
"echom 'user separately config:' string(us_conf)
|
|
||||||
let af_conf = (s:eq(us_conf, 'default') ? ds_conf : us_conf)
|
|
||||||
"echom 'almost finally config:' string(af_conf)
|
|
||||||
if s:eq(af_conf, 0)
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
let conf = extend(extend({'syn_name_prefix': substitute(a:ft, '\v\A+(\a)', '\u\1', 'g').'Rainbow'}, dft_conf), af_conf)
|
|
||||||
let conf.cycle = (has('gui_running') || (has('termguicolors') && &termguicolors)) ? s:lcm(len(conf.guifgs), len(conf.guis)) : s:lcm(len(conf.ctermfgs), len(conf.cterms))
|
|
||||||
return conf
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun rainbow_main#gen_configs(ft)
|
|
||||||
return filter(map(split(a:ft, '\v\.'), 'rainbow_main#gen_config(v:val)'), 'type(v:val) == type({})')
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun rainbow_main#load()
|
|
||||||
let b:rainbow_confs = rainbow_main#gen_configs(&filetype)
|
|
||||||
for conf in b:rainbow_confs
|
|
||||||
call rainbow#syn(conf)
|
|
||||||
call rainbow#hi(conf)
|
|
||||||
endfor
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun rainbow_main#clear()
|
|
||||||
if !exists('b:rainbow_confs') | return | endif
|
|
||||||
for conf in b:rainbow_confs
|
|
||||||
call rainbow#hi_clear(conf)
|
|
||||||
call rainbow#syn_clear(conf)
|
|
||||||
endfor
|
|
||||||
unlet b:rainbow_confs
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun rainbow_main#toggle()
|
|
||||||
if exists('b:rainbow_confs')
|
|
||||||
call rainbow_main#clear()
|
|
||||||
else
|
|
||||||
call rainbow_main#load()
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 8e5d86f7b85234d3d1b4207dceebc43a768ed5d4
|
|
1745
backup/doc/emmet.txt
1745
backup/doc/emmet.txt
File diff suppressed because it is too large
Load diff
|
@ -1,673 +0,0 @@
|
||||||
" Insert or delete brackets, parens, quotes in pairs.
|
|
||||||
" Maintainer: JiangMiao <jiangfriend@gmail.com>
|
|
||||||
" Contributor: camthompson
|
|
||||||
" Last Change: 2019-02-02
|
|
||||||
" Version: 2.0.0
|
|
||||||
" Homepage: http://www.vim.org/scripts/script.php?script_id=3599
|
|
||||||
" Repository: https://github.com/jiangmiao/auto-pairs
|
|
||||||
" License: MIT
|
|
||||||
|
|
||||||
if exists('g:AutoPairsLoaded') || &cp
|
|
||||||
finish
|
|
||||||
end
|
|
||||||
let g:AutoPairsLoaded = 1
|
|
||||||
|
|
||||||
if !exists('g:AutoPairs')
|
|
||||||
let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '```':'```', '"""':'"""', "'''":"'''", "`":"`"}
|
|
||||||
end
|
|
||||||
|
|
||||||
" default pairs base on filetype
|
|
||||||
func! AutoPairsDefaultPairs()
|
|
||||||
if exists('b:autopairs_defaultpairs')
|
|
||||||
return b:autopairs_defaultpairs
|
|
||||||
end
|
|
||||||
let r = copy(g:AutoPairs)
|
|
||||||
let allPairs = {
|
|
||||||
\ 'vim': {'\v^\s*\zs"': ''},
|
|
||||||
\ 'rust': {'\w\zs<': '>', '&\zs''': ''},
|
|
||||||
\ 'php': {'<?': '?>//k]', '<?php': '?>//k]'}
|
|
||||||
\ }
|
|
||||||
for [filetype, pairs] in items(allPairs)
|
|
||||||
if &filetype == filetype
|
|
||||||
for [open, close] in items(pairs)
|
|
||||||
let r[open] = close
|
|
||||||
endfor
|
|
||||||
end
|
|
||||||
endfor
|
|
||||||
let b:autopairs_defaultpairs = r
|
|
||||||
return r
|
|
||||||
endf
|
|
||||||
|
|
||||||
if !exists('g:AutoPairsMapBS')
|
|
||||||
let g:AutoPairsMapBS = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
" Map <C-h> as the same BS
|
|
||||||
if !exists('g:AutoPairsMapCh')
|
|
||||||
let g:AutoPairsMapCh = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if !exists('g:AutoPairsMapCR')
|
|
||||||
let g:AutoPairsMapCR = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if !exists('g:AutoPairsWildClosedPair')
|
|
||||||
let g:AutoPairsWildClosedPair = ''
|
|
||||||
end
|
|
||||||
|
|
||||||
if !exists('g:AutoPairsMapSpace')
|
|
||||||
let g:AutoPairsMapSpace = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if !exists('g:AutoPairsCenterLine')
|
|
||||||
let g:AutoPairsCenterLine = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if !exists('g:AutoPairsShortcutToggle')
|
|
||||||
let g:AutoPairsShortcutToggle = '<M-p>'
|
|
||||||
end
|
|
||||||
|
|
||||||
if !exists('g:AutoPairsShortcutFastWrap')
|
|
||||||
let g:AutoPairsShortcutFastWrap = '<M-e>'
|
|
||||||
end
|
|
||||||
|
|
||||||
if !exists('g:AutoPairsMoveCharacter')
|
|
||||||
let g:AutoPairsMoveCharacter = "()[]{}\"'"
|
|
||||||
end
|
|
||||||
|
|
||||||
if !exists('g:AutoPairsShortcutJump')
|
|
||||||
let g:AutoPairsShortcutJump = '<M-n>'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Fly mode will for closed pair to jump to closed pair instead of insert.
|
|
||||||
" also support AutoPairsBackInsert to insert pairs where jumped.
|
|
||||||
if !exists('g:AutoPairsFlyMode')
|
|
||||||
let g:AutoPairsFlyMode = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
" When skipping the closed pair, look at the current and
|
|
||||||
" next line as well.
|
|
||||||
if !exists('g:AutoPairsMultilineClose')
|
|
||||||
let g:AutoPairsMultilineClose = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Work with Fly Mode, insert pair where jumped
|
|
||||||
if !exists('g:AutoPairsShortcutBackInsert')
|
|
||||||
let g:AutoPairsShortcutBackInsert = '<M-b>'
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:AutoPairsSmartQuotes')
|
|
||||||
let g:AutoPairsSmartQuotes = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 7.4.849 support <C-G>U to avoid breaking '.'
|
|
||||||
" Issue talk: https://github.com/jiangmiao/auto-pairs/issues/3
|
|
||||||
" Vim note: https://github.com/vim/vim/releases/tag/v7.4.849
|
|
||||||
if v:version > 704 || v:version == 704 && has("patch849")
|
|
||||||
let s:Go = "\<C-G>U"
|
|
||||||
else
|
|
||||||
let s:Go = ""
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:Left = s:Go."\<LEFT>"
|
|
||||||
let s:Right = s:Go."\<RIGHT>"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" unicode len
|
|
||||||
func! s:ulen(s)
|
|
||||||
return len(split(a:s, '\zs'))
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! s:left(s)
|
|
||||||
return repeat(s:Left, s:ulen(a:s))
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! s:right(s)
|
|
||||||
return repeat(s:Right, s:ulen(a:s))
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! s:delete(s)
|
|
||||||
return repeat("\<DEL>", s:ulen(a:s))
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! s:backspace(s)
|
|
||||||
return repeat("\<BS>", s:ulen(a:s))
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! s:getline()
|
|
||||||
let line = getline('.')
|
|
||||||
let pos = col('.') - 1
|
|
||||||
let before = strpart(line, 0, pos)
|
|
||||||
let after = strpart(line, pos)
|
|
||||||
let afterline = after
|
|
||||||
if g:AutoPairsMultilineClose
|
|
||||||
let n = line('$')
|
|
||||||
let i = line('.')+1
|
|
||||||
while i <= n
|
|
||||||
let line = getline(i)
|
|
||||||
let after = after.' '.line
|
|
||||||
if !(line =~ '\v^\s*$')
|
|
||||||
break
|
|
||||||
end
|
|
||||||
let i = i+1
|
|
||||||
endwhile
|
|
||||||
end
|
|
||||||
return [before, after, afterline]
|
|
||||||
endf
|
|
||||||
|
|
||||||
" split text to two part
|
|
||||||
" returns [orig, text_before_open, open]
|
|
||||||
func! s:matchend(text, open)
|
|
||||||
let m = matchstr(a:text, '\V'.a:open.'\v$')
|
|
||||||
if m == ""
|
|
||||||
return []
|
|
||||||
end
|
|
||||||
return [a:text, strpart(a:text, 0, len(a:text)-len(m)), m]
|
|
||||||
endf
|
|
||||||
|
|
||||||
" returns [orig, close, text_after_close]
|
|
||||||
func! s:matchbegin(text, close)
|
|
||||||
let m = matchstr(a:text, '^\V'.a:close)
|
|
||||||
if m == ""
|
|
||||||
return []
|
|
||||||
end
|
|
||||||
return [a:text, m, strpart(a:text, len(m), len(a:text)-len(m))]
|
|
||||||
endf
|
|
||||||
|
|
||||||
" add or delete pairs base on g:AutoPairs
|
|
||||||
" AutoPairsDefine(addPairs:dict[, removeOpenPairList:list])
|
|
||||||
"
|
|
||||||
" eg:
|
|
||||||
" au FileType html let b:AutoPairs = AutoPairsDefine({'<!--' : '-->'}, ['{'])
|
|
||||||
" add <!-- --> pair and remove '{' for html file
|
|
||||||
func! AutoPairsDefine(pairs, ...)
|
|
||||||
let r = AutoPairsDefaultPairs()
|
|
||||||
if a:0 > 0
|
|
||||||
for open in a:1
|
|
||||||
unlet r[open]
|
|
||||||
endfor
|
|
||||||
end
|
|
||||||
for [open, close] in items(a:pairs)
|
|
||||||
let r[open] = close
|
|
||||||
endfor
|
|
||||||
return r
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! AutoPairsInsert(key)
|
|
||||||
if !b:autopairs_enabled
|
|
||||||
return a:key
|
|
||||||
end
|
|
||||||
|
|
||||||
let b:autopairs_saved_pair = [a:key, getpos('.')]
|
|
||||||
|
|
||||||
let [before, after, afterline] = s:getline()
|
|
||||||
|
|
||||||
" Ignore auto close if prev character is \
|
|
||||||
if before[-1:-1] == '\'
|
|
||||||
return a:key
|
|
||||||
end
|
|
||||||
|
|
||||||
" check open pairs
|
|
||||||
for [open, close, opt] in b:AutoPairsList
|
|
||||||
let ms = s:matchend(before.a:key, open)
|
|
||||||
let m = matchstr(afterline, '^\v\s*\zs\V'.close)
|
|
||||||
if len(ms) > 0
|
|
||||||
" process the open pair
|
|
||||||
|
|
||||||
" remove inserted pair
|
|
||||||
" eg: if the pairs include < > and <!-- -->
|
|
||||||
" when <!-- is detected the inserted pair < > should be clean up
|
|
||||||
let target = ms[1]
|
|
||||||
let openPair = ms[2]
|
|
||||||
if len(openPair) == 1 && m == openPair
|
|
||||||
break
|
|
||||||
end
|
|
||||||
let bs = ''
|
|
||||||
let del = ''
|
|
||||||
while len(before) > len(target)
|
|
||||||
let found = 0
|
|
||||||
" delete pair
|
|
||||||
for [o, c, opt] in b:AutoPairsList
|
|
||||||
let os = s:matchend(before, o)
|
|
||||||
if len(os) && len(os[1]) < len(target)
|
|
||||||
" any text before openPair should not be deleted
|
|
||||||
continue
|
|
||||||
end
|
|
||||||
let cs = s:matchbegin(afterline, c)
|
|
||||||
if len(os) && len(cs)
|
|
||||||
let found = 1
|
|
||||||
let before = os[1]
|
|
||||||
let afterline = cs[2]
|
|
||||||
let bs = bs.s:backspace(os[2])
|
|
||||||
let del = del.s:delete(cs[1])
|
|
||||||
break
|
|
||||||
end
|
|
||||||
endfor
|
|
||||||
if !found
|
|
||||||
" delete charactor
|
|
||||||
let ms = s:matchend(before, '\v.')
|
|
||||||
if len(ms)
|
|
||||||
let before = ms[1]
|
|
||||||
let bs = bs.s:backspace(ms[2])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
endwhile
|
|
||||||
return bs.del.openPair.close.s:left(close)
|
|
||||||
end
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" check close pairs
|
|
||||||
for [open, close, opt] in b:AutoPairsList
|
|
||||||
if close == ''
|
|
||||||
continue
|
|
||||||
end
|
|
||||||
if a:key == g:AutoPairsWildClosedPair || opt['mapclose'] && opt['key'] == a:key
|
|
||||||
" the close pair is in the same line
|
|
||||||
let m = matchstr(afterline, '^\v\s*\V'.close)
|
|
||||||
if m != ''
|
|
||||||
if before =~ '\V'.open.'\v\s*$' && m[0] =~ '\v\s'
|
|
||||||
" remove the space we inserted if the text in pairs is blank
|
|
||||||
return "\<DEL>".s:right(m[1:])
|
|
||||||
else
|
|
||||||
return s:right(m)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
let m = matchstr(after, '^\v\s*\zs\V'.close)
|
|
||||||
if m != ''
|
|
||||||
if a:key == g:AutoPairsWildClosedPair || opt['multiline']
|
|
||||||
if b:autopairs_return_pos == line('.') && getline('.') =~ '\v^\s*$'
|
|
||||||
normal! ddk$
|
|
||||||
end
|
|
||||||
call search(m, 'We')
|
|
||||||
return "\<Right>"
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
endfor
|
|
||||||
|
|
||||||
|
|
||||||
" Fly Mode, and the key is closed-pairs, search closed-pair and jump
|
|
||||||
if g:AutoPairsFlyMode && a:key =~ '\v[\}\]\)]'
|
|
||||||
if search(a:key, 'We')
|
|
||||||
return "\<Right>"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
return a:key
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! AutoPairsDelete()
|
|
||||||
if !b:autopairs_enabled
|
|
||||||
return "\<BS>"
|
|
||||||
end
|
|
||||||
|
|
||||||
let [before, after, ig] = s:getline()
|
|
||||||
for [open, close, opt] in b:AutoPairsList
|
|
||||||
let b = matchstr(before, '\V'.open.'\v\s?$')
|
|
||||||
let a = matchstr(after, '^\v\s*\V'.close)
|
|
||||||
if b != '' && a != ''
|
|
||||||
if b[-1:-1] == ' '
|
|
||||||
if a[0] == ' '
|
|
||||||
return "\<BS>\<DELETE>"
|
|
||||||
else
|
|
||||||
return "\<BS>"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return s:backspace(b).s:delete(a)
|
|
||||||
end
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return "\<BS>"
|
|
||||||
" delete the pair foo[]| <BS> to foo
|
|
||||||
for [open, close, opt] in b:AutoPairsList
|
|
||||||
let m = s:matchend(before, '\V'.open.'\v\s*'.'\V'.close.'\v$')
|
|
||||||
if len(m) > 0
|
|
||||||
return s:backspace(m[2])
|
|
||||||
end
|
|
||||||
endfor
|
|
||||||
return "\<BS>"
|
|
||||||
endf
|
|
||||||
|
|
||||||
|
|
||||||
" Fast wrap the word in brackets
|
|
||||||
func! AutoPairsFastWrap()
|
|
||||||
let c = @"
|
|
||||||
normal! x
|
|
||||||
let [before, after, ig] = s:getline()
|
|
||||||
if after[0] =~ '\v[\{\[\(\<]'
|
|
||||||
normal! %
|
|
||||||
normal! p
|
|
||||||
else
|
|
||||||
for [open, close, opt] in b:AutoPairsList
|
|
||||||
if close == ''
|
|
||||||
continue
|
|
||||||
end
|
|
||||||
if after =~ '^\s*\V'.open
|
|
||||||
call search(close, 'We')
|
|
||||||
normal! p
|
|
||||||
let @" = c
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
endfor
|
|
||||||
if after[1:1] =~ '\v\w'
|
|
||||||
normal! e
|
|
||||||
normal! p
|
|
||||||
else
|
|
||||||
normal! p
|
|
||||||
end
|
|
||||||
end
|
|
||||||
let @" = c
|
|
||||||
return ""
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! AutoPairsJump()
|
|
||||||
call search('["\]'')}]','W')
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! AutoPairsMoveCharacter(key)
|
|
||||||
let c = getline(".")[col(".")-1]
|
|
||||||
let escaped_key = substitute(a:key, "'", "''", 'g')
|
|
||||||
return "\<DEL>\<ESC>:call search("."'".escaped_key."'".")\<CR>a".c."\<LEFT>"
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! AutoPairsBackInsert()
|
|
||||||
let pair = b:autopairs_saved_pair[0]
|
|
||||||
let pos = b:autopairs_saved_pair[1]
|
|
||||||
call setpos('.', pos)
|
|
||||||
return pair
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! AutoPairsReturn()
|
|
||||||
if b:autopairs_enabled == 0
|
|
||||||
return ''
|
|
||||||
end
|
|
||||||
let b:autopairs_return_pos = 0
|
|
||||||
let before = getline(line('.')-1)
|
|
||||||
let [ig, ig, afterline] = s:getline()
|
|
||||||
let cmd = ''
|
|
||||||
for [open, close, opt] in b:AutoPairsList
|
|
||||||
if close == ''
|
|
||||||
continue
|
|
||||||
end
|
|
||||||
|
|
||||||
if before =~ '\V'.open.'\v\s*$' && afterline =~ '^\s*\V'.close
|
|
||||||
let b:autopairs_return_pos = line('.')
|
|
||||||
if g:AutoPairsCenterLine && winline() * 3 >= winheight(0) * 2
|
|
||||||
" Recenter before adding new line to avoid replacing line content
|
|
||||||
let cmd = "zz"
|
|
||||||
end
|
|
||||||
|
|
||||||
" If equalprg has been set, then avoid call =
|
|
||||||
" https://github.com/jiangmiao/auto-pairs/issues/24
|
|
||||||
if &equalprg != ''
|
|
||||||
return "\<ESC>".cmd."O"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" conflict with javascript and coffee
|
|
||||||
" javascript need indent new line
|
|
||||||
" coffeescript forbid indent new line
|
|
||||||
if &filetype == 'coffeescript' || &filetype == 'coffee'
|
|
||||||
return "\<ESC>".cmd."k==o"
|
|
||||||
else
|
|
||||||
return "\<ESC>".cmd."=ko"
|
|
||||||
endif
|
|
||||||
end
|
|
||||||
endfor
|
|
||||||
return ''
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! AutoPairsSpace()
|
|
||||||
if !b:autopairs_enabled
|
|
||||||
return "\<SPACE>"
|
|
||||||
end
|
|
||||||
|
|
||||||
let [before, after, ig] = s:getline()
|
|
||||||
|
|
||||||
for [open, close, opt] in b:AutoPairsList
|
|
||||||
if close == ''
|
|
||||||
continue
|
|
||||||
end
|
|
||||||
if before =~ '\V'.open.'\v$' && after =~ '^\V'.close
|
|
||||||
if close =~ '\v^[''"`]$'
|
|
||||||
return "\<SPACE>"
|
|
||||||
else
|
|
||||||
return "\<SPACE>\<SPACE>".s:Left
|
|
||||||
end
|
|
||||||
end
|
|
||||||
endfor
|
|
||||||
return "\<SPACE>"
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! AutoPairsMap(key)
|
|
||||||
" | is special key which separate map command from text
|
|
||||||
let key = a:key
|
|
||||||
if key == '|'
|
|
||||||
let key = '<BAR>'
|
|
||||||
end
|
|
||||||
let escaped_key = substitute(key, "'", "''", 'g')
|
|
||||||
" use expr will cause search() doesn't work
|
|
||||||
execute 'inoremap <buffer> <silent> '.key." <C-R>=AutoPairsInsert('".escaped_key."')<CR>"
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! AutoPairsToggle()
|
|
||||||
if b:autopairs_enabled
|
|
||||||
let b:autopairs_enabled = 0
|
|
||||||
echo 'AutoPairs Disabled.'
|
|
||||||
else
|
|
||||||
let b:autopairs_enabled = 1
|
|
||||||
echo 'AutoPairs Enabled.'
|
|
||||||
end
|
|
||||||
return ''
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! s:sortByLength(i1, i2)
|
|
||||||
return len(a:i2[0])-len(a:i1[0])
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! AutoPairsInit()
|
|
||||||
let b:autopairs_loaded = 1
|
|
||||||
if !exists('b:autopairs_enabled')
|
|
||||||
let b:autopairs_enabled = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if !exists('b:AutoPairs')
|
|
||||||
let b:AutoPairs = AutoPairsDefaultPairs()
|
|
||||||
end
|
|
||||||
|
|
||||||
if !exists('b:AutoPairsMoveCharacter')
|
|
||||||
let b:AutoPairsMoveCharacter = g:AutoPairsMoveCharacter
|
|
||||||
end
|
|
||||||
|
|
||||||
let b:autopairs_return_pos = 0
|
|
||||||
let b:autopairs_saved_pair = [0, 0]
|
|
||||||
let b:AutoPairsList = []
|
|
||||||
|
|
||||||
" buffer level map pairs keys
|
|
||||||
" n - do not map the first charactor of closed pair to close key
|
|
||||||
" m - close key jumps through multi line
|
|
||||||
" s - close key jumps only in the same line
|
|
||||||
for [open, close] in items(b:AutoPairs)
|
|
||||||
let o = open[-1:-1]
|
|
||||||
let c = close[0]
|
|
||||||
let opt = {'mapclose': 1, 'multiline':1}
|
|
||||||
let opt['key'] = c
|
|
||||||
if o == c
|
|
||||||
let opt['multiline'] = 0
|
|
||||||
end
|
|
||||||
let m = matchlist(close, '\v(.*)//(.*)$')
|
|
||||||
if len(m) > 0
|
|
||||||
if m[2] =~ 'n'
|
|
||||||
let opt['mapclose'] = 0
|
|
||||||
end
|
|
||||||
if m[2] =~ 'm'
|
|
||||||
let opt['multiline'] = 1
|
|
||||||
end
|
|
||||||
if m[2] =~ 's'
|
|
||||||
let opt['multiline'] = 0
|
|
||||||
end
|
|
||||||
let ks = matchlist(m[2], '\vk(.)')
|
|
||||||
if len(ks) > 0
|
|
||||||
let opt['key'] = ks[1]
|
|
||||||
let c = opt['key']
|
|
||||||
end
|
|
||||||
let close = m[1]
|
|
||||||
end
|
|
||||||
call AutoPairsMap(o)
|
|
||||||
if o != c && c != '' && opt['mapclose']
|
|
||||||
call AutoPairsMap(c)
|
|
||||||
end
|
|
||||||
let b:AutoPairsList += [[open, close, opt]]
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" sort pairs by length, longer pair should have higher priority
|
|
||||||
let b:AutoPairsList = sort(b:AutoPairsList, "s:sortByLength")
|
|
||||||
|
|
||||||
for item in b:AutoPairsList
|
|
||||||
let [open, close, opt] = item
|
|
||||||
if open == "'" && open == close
|
|
||||||
let item[0] = '\v(^|\W)\zs'''
|
|
||||||
end
|
|
||||||
endfor
|
|
||||||
|
|
||||||
|
|
||||||
for key in split(b:AutoPairsMoveCharacter, '\s*')
|
|
||||||
let escaped_key = substitute(key, "'", "''", 'g')
|
|
||||||
execute 'inoremap <silent> <buffer> <M-'.key."> <C-R>=AutoPairsMoveCharacter('".escaped_key."')<CR>"
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" Still use <buffer> level mapping for <BS> <SPACE>
|
|
||||||
if g:AutoPairsMapBS
|
|
||||||
" Use <C-R> instead of <expr> for issue #14 sometimes press BS output strange words
|
|
||||||
execute 'inoremap <buffer> <silent> <BS> <C-R>=AutoPairsDelete()<CR>'
|
|
||||||
end
|
|
||||||
|
|
||||||
if g:AutoPairsMapCh
|
|
||||||
execute 'inoremap <buffer> <silent> <C-h> <C-R>=AutoPairsDelete()<CR>'
|
|
||||||
endif
|
|
||||||
|
|
||||||
if g:AutoPairsMapSpace
|
|
||||||
" Try to respect abbreviations on a <SPACE>
|
|
||||||
let do_abbrev = ""
|
|
||||||
if v:version == 703 && has("patch489") || v:version > 703
|
|
||||||
let do_abbrev = "<C-]>"
|
|
||||||
endif
|
|
||||||
execute 'inoremap <buffer> <silent> <SPACE> '.do_abbrev.'<C-R>=AutoPairsSpace()<CR>'
|
|
||||||
end
|
|
||||||
|
|
||||||
if g:AutoPairsShortcutFastWrap != ''
|
|
||||||
execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutFastWrap.' <C-R>=AutoPairsFastWrap()<CR>'
|
|
||||||
end
|
|
||||||
|
|
||||||
if g:AutoPairsShortcutBackInsert != ''
|
|
||||||
execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutBackInsert.' <C-R>=AutoPairsBackInsert()<CR>'
|
|
||||||
end
|
|
||||||
|
|
||||||
if g:AutoPairsShortcutToggle != ''
|
|
||||||
" use <expr> to ensure showing the status when toggle
|
|
||||||
execute 'inoremap <buffer> <silent> <expr> '.g:AutoPairsShortcutToggle.' AutoPairsToggle()'
|
|
||||||
execute 'noremap <buffer> <silent> '.g:AutoPairsShortcutToggle.' :call AutoPairsToggle()<CR>'
|
|
||||||
end
|
|
||||||
|
|
||||||
if g:AutoPairsShortcutJump != ''
|
|
||||||
execute 'inoremap <buffer> <silent> ' . g:AutoPairsShortcutJump. ' <ESC>:call AutoPairsJump()<CR>a'
|
|
||||||
execute 'noremap <buffer> <silent> ' . g:AutoPairsShortcutJump. ' :call AutoPairsJump()<CR>'
|
|
||||||
end
|
|
||||||
|
|
||||||
if &keymap != ''
|
|
||||||
let l:imsearch = &imsearch
|
|
||||||
let l:iminsert = &iminsert
|
|
||||||
let l:imdisable = &imdisable
|
|
||||||
execute 'setlocal keymap=' . &keymap
|
|
||||||
execute 'setlocal imsearch=' . l:imsearch
|
|
||||||
execute 'setlocal iminsert=' . l:iminsert
|
|
||||||
if l:imdisable
|
|
||||||
execute 'setlocal imdisable'
|
|
||||||
else
|
|
||||||
execute 'setlocal noimdisable'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! s:ExpandMap(map)
|
|
||||||
let map = a:map
|
|
||||||
let map = substitute(map, '\(<Plug>\w\+\)', '\=maparg(submatch(1), "i")', 'g')
|
|
||||||
let map = substitute(map, '\(<Plug>([^)]*)\)', '\=maparg(submatch(1), "i")', 'g')
|
|
||||||
return map
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! AutoPairsTryInit()
|
|
||||||
if exists('b:autopairs_loaded')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
" for auto-pairs starts with 'a', so the priority is higher than supertab and vim-endwise
|
|
||||||
"
|
|
||||||
" vim-endwise doesn't support <Plug>AutoPairsReturn
|
|
||||||
" when use <Plug>AutoPairsReturn will cause <Plug> isn't expanded
|
|
||||||
"
|
|
||||||
" supertab doesn't support <SID>AutoPairsReturn
|
|
||||||
" when use <SID>AutoPairsReturn will cause Duplicated <CR>
|
|
||||||
"
|
|
||||||
" and when load after vim-endwise will cause unexpected endwise inserted.
|
|
||||||
" so always load AutoPairs at last
|
|
||||||
|
|
||||||
" Buffer level keys mapping
|
|
||||||
" comptible with other plugin
|
|
||||||
if g:AutoPairsMapCR
|
|
||||||
if v:version == 703 && has('patch32') || v:version > 703
|
|
||||||
" VIM 7.3 supports advancer maparg which could get <expr> info
|
|
||||||
" then auto-pairs could remap <CR> in any case.
|
|
||||||
let info = maparg('<CR>', 'i', 0, 1)
|
|
||||||
if empty(info)
|
|
||||||
let old_cr = '<CR>'
|
|
||||||
let is_expr = 0
|
|
||||||
else
|
|
||||||
let old_cr = info['rhs']
|
|
||||||
let old_cr = s:ExpandMap(old_cr)
|
|
||||||
let old_cr = substitute(old_cr, '<SID>', '<SNR>' . info['sid'] . '_', 'g')
|
|
||||||
let is_expr = info['expr']
|
|
||||||
let wrapper_name = '<SID>AutoPairsOldCRWrapper73'
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
" VIM version less than 7.3
|
|
||||||
" the mapping's <expr> info is lost, so guess it is expr or not, it's
|
|
||||||
" not accurate.
|
|
||||||
let old_cr = maparg('<CR>', 'i')
|
|
||||||
if old_cr == ''
|
|
||||||
let old_cr = '<CR>'
|
|
||||||
let is_expr = 0
|
|
||||||
else
|
|
||||||
let old_cr = s:ExpandMap(old_cr)
|
|
||||||
" old_cr contain (, I guess the old cr is in expr mode
|
|
||||||
let is_expr = old_cr =~ '\V(' && toupper(old_cr) !~ '\V<C-R>'
|
|
||||||
|
|
||||||
" The old_cr start with " it must be in expr mode
|
|
||||||
let is_expr = is_expr || old_cr =~ '\v^"'
|
|
||||||
let wrapper_name = '<SID>AutoPairsOldCRWrapper'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if old_cr !~ 'AutoPairsReturn'
|
|
||||||
if is_expr
|
|
||||||
" remap <expr> to `name` to avoid mix expr and non-expr mode
|
|
||||||
execute 'inoremap <buffer> <expr> <script> '. wrapper_name . ' ' . old_cr
|
|
||||||
let old_cr = wrapper_name
|
|
||||||
end
|
|
||||||
" Always silent mapping
|
|
||||||
execute 'inoremap <script> <buffer> <silent> <CR> '.old_cr.'<SID>AutoPairsReturn'
|
|
||||||
end
|
|
||||||
endif
|
|
||||||
call AutoPairsInit()
|
|
||||||
endf
|
|
||||||
|
|
||||||
" Always silent the command
|
|
||||||
inoremap <silent> <SID>AutoPairsReturn <C-R>=AutoPairsReturn()<CR>
|
|
||||||
imap <script> <Plug>AutoPairsReturn <SID>AutoPairsReturn
|
|
||||||
|
|
||||||
|
|
||||||
au BufEnter * :call AutoPairsTryInit()
|
|
|
@ -1,177 +0,0 @@
|
||||||
"=============================================================================
|
|
||||||
" File: emmet.vim
|
|
||||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
|
||||||
" Last Change: 26-Jul-2015.
|
|
||||||
" Version: 0.86
|
|
||||||
" WebPage: http://github.com/mattn/emmet-vim
|
|
||||||
" Description: vim plugins for HTML and CSS hi-speed coding.
|
|
||||||
" SeeAlso: http://emmet.io/
|
|
||||||
" Usage:
|
|
||||||
"
|
|
||||||
" This is vim script support expanding abbreviation like emmet.
|
|
||||||
" ref: http://emmet.io/
|
|
||||||
"
|
|
||||||
" Type abbreviation
|
|
||||||
" +-------------------------------------
|
|
||||||
" | html:5_
|
|
||||||
" +-------------------------------------
|
|
||||||
" "_" is a cursor position. and type "<c-y>," (Ctrl+y and Comma)
|
|
||||||
" NOTE: Don't worry about key map. you can change it easily.
|
|
||||||
" +-------------------------------------
|
|
||||||
" | <!DOCTYPE HTML>
|
|
||||||
" | <html lang="en">
|
|
||||||
" | <head>
|
|
||||||
" | <title></title>
|
|
||||||
" | <meta charset="UTF-8">
|
|
||||||
" | </head>
|
|
||||||
" | <body>
|
|
||||||
" | _
|
|
||||||
" | </body>
|
|
||||||
" | </html>
|
|
||||||
" +-------------------------------------
|
|
||||||
" Type following
|
|
||||||
" +-------------------------------------
|
|
||||||
" | div#foo$*2>div.bar
|
|
||||||
" +-------------------------------------
|
|
||||||
" And type "<c-y>,"
|
|
||||||
" +-------------------------------------
|
|
||||||
" |<div id="foo1">
|
|
||||||
" | <div class="bar">_</div>
|
|
||||||
" |</div>
|
|
||||||
" |<div id="foo2">
|
|
||||||
" | <div class="bar"></div>
|
|
||||||
" |</div>
|
|
||||||
" +-------------------------------------
|
|
||||||
"
|
|
||||||
" Tips:
|
|
||||||
"
|
|
||||||
" You can customize behavior of expanding with overriding config.
|
|
||||||
" This configuration will be marged at loading plugin.
|
|
||||||
"
|
|
||||||
" let g:user_emmet_settings = {
|
|
||||||
" \ 'indentation' : ' ',
|
|
||||||
" \ 'perl' : {
|
|
||||||
" \ 'aliases' : {
|
|
||||||
" \ 'req' : 'require '
|
|
||||||
" \ },
|
|
||||||
" \ 'snippets' : {
|
|
||||||
" \ 'use' : "use strict\nuse warnings\n\n",
|
|
||||||
" \ 'warn' : "warn \"|\";",
|
|
||||||
" \ }
|
|
||||||
" \ }
|
|
||||||
" \}
|
|
||||||
"
|
|
||||||
" You can set language attribute in html using 'emmet_settings.lang'.
|
|
||||||
"
|
|
||||||
" GetLatestVimScripts: 2981 1 :AutoInstall: emmet.vim
|
|
||||||
" script type: plugin
|
|
||||||
|
|
||||||
if &compatible || v:version < 702 || (exists('g:loaded_emmet_vim') && g:loaded_emmet_vim)
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let g:loaded_emmet_vim = 1
|
|
||||||
|
|
||||||
let s:save_cpo = &cpoptions
|
|
||||||
set cpoptions&vim
|
|
||||||
|
|
||||||
if !exists('g:emmet_html5')
|
|
||||||
let g:emmet_html5 = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:emmet_docroot')
|
|
||||||
let g:emmet_docroot = {}
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:emmet_debug')
|
|
||||||
let g:emmet_debug = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:emmet_curl_command')
|
|
||||||
let g:emmet_curl_command = 'curl -s -L -A Mozilla/5.0'
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:user_emmet_leader_key')
|
|
||||||
let g:user_emmet_leader_key = '<c-y>'
|
|
||||||
endif
|
|
||||||
|
|
||||||
function! s:install_plugin(mode, buffer)
|
|
||||||
let buffer = a:buffer ? '<buffer>' : ''
|
|
||||||
let items = [
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(0,"")<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(3,"")<cr>'},
|
|
||||||
\ {'mode': 'v', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(2,"")<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(1,"")<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': ':call emmet#expandAbbr(1,"")<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#updateTag()<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': ':call emmet#updateTag()<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': '<esc>:call emmet#balanceTag(1)<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': ':call emmet#balanceTag(1)<cr>'},
|
|
||||||
\ {'mode': 'v', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': ':call emmet#balanceTag(2)<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': ':call emmet#balanceTag(-1)<cr>'},
|
|
||||||
\ {'mode': 'v', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': ':call emmet#balanceTag(-2)<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': '<esc>:call emmet#moveNextPrev(0)<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': ':call emmet#moveNextPrev(0)<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': '<esc>:call emmet#moveNextPrev(1)<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': ':call emmet#moveNextPrev(1)<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': '<esc>:call emmet#moveNextPrevItem(0)<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': ':call emmet#moveNextPrevItem(0)<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': '<esc>:call emmet#moveNextPrevItem(1)<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': ':call emmet#moveNextPrevItem(1)<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#imageSize()<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': ':call emmet#imageSize()<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#toggleComment()<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': ':call emmet#toggleComment()<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': '<esc>:call emmet#splitJoinTag()<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': ':call emmet#splitJoinTag()<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#removeTag()<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': ':call emmet#removeTag()<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(0)<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': ':call emmet#anchorizeURL(0)<cr>'},
|
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(1)<cr>'},
|
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': ':call emmet#anchorizeURL(1)<cr>'},
|
|
||||||
\ {'mode': 'v', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': ':call emmet#mergeLines()<cr>'},
|
|
||||||
\ {'mode': 'v', 'var': 'user_emmet_codepretty_key', 'key': 'c', 'plug': 'emmet-code-pretty', 'func': ':call emmet#codePretty()<cr>'},
|
|
||||||
\]
|
|
||||||
|
|
||||||
let only_plug = get(g:, 'emmet_install_only_plug', 0)
|
|
||||||
for item in items
|
|
||||||
if a:mode !=# 'a' && stridx(a:mode, item.mode) == -1
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
exe item.mode . 'noremap '. buffer .' <plug>(' . item.plug . ') ' . item.func
|
|
||||||
if item.var != '' && !only_plug
|
|
||||||
if exists('g:' . item.var)
|
|
||||||
let key = eval('g:' . item.var)
|
|
||||||
else
|
|
||||||
let key = g:user_emmet_leader_key . item.key
|
|
||||||
endif
|
|
||||||
if !hasmapto('<plug>(' . item.plug . ')', item.mode) && !len(maparg(key, item.mode))
|
|
||||||
exe item.mode . 'map ' . buffer . ' <unique> ' . key . ' <plug>(' . item.plug . ')'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
if exists('g:user_emmet_complete_tag') && g:user_emmet_complete_tag
|
|
||||||
if get(g:, 'user_emmet_install_global', 1)
|
|
||||||
set omnifunc=emmet#completeTag
|
|
||||||
else
|
|
||||||
setlocal omnifunc=emmet#completeTag
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command! -nargs=0 -bar EmmetInstall call <SID>install_plugin(get(g:, 'user_emmet_mode', 'a'), 1)
|
|
||||||
|
|
||||||
if get(g:, 'user_emmet_install_global', 1)
|
|
||||||
call s:install_plugin(get(g:, 'user_emmet_mode', 'a'), 0)
|
|
||||||
endif
|
|
||||||
|
|
||||||
if get(g:, 'user_emmet_install_command', 1)
|
|
||||||
command! -nargs=1 Emmet call emmet#expandAbbr(4, <q-args>)
|
|
||||||
endif
|
|
||||||
|
|
||||||
let &cpoptions = s:save_cpo
|
|
||||||
unlet s:save_cpo
|
|
||||||
|
|
||||||
" vim:set et:
|
|
|
@ -1,212 +0,0 @@
|
||||||
" Location: plugin/endwise.vim
|
|
||||||
" Author: Tim Pope <http://tpo.pe/>
|
|
||||||
" Version: 1.2
|
|
||||||
" License: Same as Vim itself. See :help license
|
|
||||||
" GetLatestVimScripts: 2386 1 :AutoInstall: endwise.vim
|
|
||||||
|
|
||||||
if exists("g:loaded_endwise") || &cp
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let g:loaded_endwise = 1
|
|
||||||
|
|
||||||
augroup endwise " {{{1
|
|
||||||
autocmd!
|
|
||||||
autocmd FileType lua
|
|
||||||
\ let b:endwise_addition = 'end' |
|
|
||||||
\ let b:endwise_words = 'function,do,then' |
|
|
||||||
\ let b:endwise_pattern = '^\s*\zs\%(\%(local\s\+\)\=function\)\>\%(.*\<end\>\)\@!\|\<\%(then\|do\)\ze\s*$' |
|
|
||||||
\ let b:endwise_syngroups = 'luaFunction,luaStatement,luaCond'
|
|
||||||
autocmd FileType elixir
|
|
||||||
\ let b:endwise_addition = 'end' |
|
|
||||||
\ let b:endwise_words = 'do,fn' |
|
|
||||||
\ let b:endwise_pattern = '.*[^.:@$]\zs\<\%(do\(:\)\@!\|fn\)\>\ze\%(.*[^.:@$]\<end\>\)\@!' |
|
|
||||||
\ let b:endwise_syngroups = 'elixirBlockDefinition'
|
|
||||||
autocmd FileType ruby
|
|
||||||
\ let b:endwise_addition = 'end' |
|
|
||||||
\ let b:endwise_words = 'module,class,def,if,unless,case,while,until,begin,do' |
|
|
||||||
\ let b:endwise_pattern = '^\(.*=\)\?\s*\%(private\s\+\|protected\s\+\|public\s\+\|module_function\s\+\)*\zs\%(module\|class\|def\|if\|unless\|case\|while\|until\|for\|\|begin\)\>\%(.*[^.:@$]\<end\>\)\@!\|\<do\ze\%(\s*|.*|\)\=\s*$' |
|
|
||||||
\ let b:endwise_syngroups = 'rubyModule,rubyClass,rubyDefine,rubyControl,rubyConditional,rubyRepeat'
|
|
||||||
autocmd FileType crystal
|
|
||||||
\ let b:endwise_addition = 'end' |
|
|
||||||
\ let b:endwise_words = 'module,class,lib,macro,struct,union,enum,def,if,unless,ifdef,case,while,until,for,begin,do' |
|
|
||||||
\ let b:endwise_pattern = '^\(.*=\)\?\s*\%(private\s\+\|protected\s\+\|public\s\+\|abstract\s\+\)*\zs\%(module\|class\|lib\|macro\|struct\|union\|enum\|def\|if\|unless\|ifdef\|case\|while\|until\|for\|begin\)\>\%(.*[^.:@$]\<end\>\)\@!\|\<do\ze\%(\s*|.*|\)\=\s*$' |
|
|
||||||
\ let b:endwise_syngroups = 'crystalModule,crystalClass,crystalLib,crystalMacro,crystalStruct,crystalEnum,crystalDefine,crystalConditional,crystalRepeat,crystalControl'
|
|
||||||
autocmd FileType sh,zsh
|
|
||||||
\ let b:endwise_addition = '\=submatch(0)=="then" ? "fi" : submatch(0)=="case" ? "esac" : "done"' |
|
|
||||||
\ let b:endwise_words = 'then,case,do' |
|
|
||||||
\ let b:endwise_pattern = '\%(^\s*\zscase\>\ze\|\zs\<\%(do\|then\)\ze\s*$\)' |
|
|
||||||
\ let b:endwise_syngroups = 'shConditional,shLoop,shIf,shFor,shRepeat,shCaseEsac,zshConditional,zshRepeat,zshDelimiter'
|
|
||||||
autocmd FileType vb,vbnet,aspvbs
|
|
||||||
\ let b:endwise_addition = 'End &' |
|
|
||||||
\ let b:endwise_words = 'Function,Sub,Class,Module,Enum,Namespace' |
|
|
||||||
\ let b:endwise_pattern = '\%(\<End\>.*\)\@<!\<&\>' |
|
|
||||||
\ let b:endwise_syngroups = 'vbStatement,vbnetStorage,vbnetProcedure,vbnet.*Words,AspVBSStatement'
|
|
||||||
autocmd FileType vim
|
|
||||||
\ let b:endwise_addition = '\=submatch(0)=~"aug\\%[roup]" ? submatch(0) . " END" : "end" . submatch(0)' |
|
|
||||||
\ let b:endwise_words = 'fu\%[nction],wh\%[ile],if,for,try,aug\%[roup]\%(\s\+\cEND\)\@!' |
|
|
||||||
\ let b:endwise_end_pattern = '\%(end\%(fu\%[nction]\|wh\%[hile]\|if\|for\|try\)\)\|aug\%[roup]\%(\s\+\cEND\)' |
|
|
||||||
\ let b:endwise_syngroups = 'vimFuncKey,vimNotFunc,vimCommand,vimAugroupKey,vimAugroup,vimAugroupError'
|
|
||||||
autocmd FileType c,cpp,xdefaults,haskell
|
|
||||||
\ let b:endwise_addition = '#endif' |
|
|
||||||
\ let b:endwise_words = 'if,ifdef,ifndef' |
|
|
||||||
\ let b:endwise_pattern = '^\s*#\%(if\|ifdef\|ifndef\)\>' |
|
|
||||||
\ let b:endwise_syngroups = 'cPreCondit,cPreConditMatch,cCppInWrapper,xdefaultsPreProc'
|
|
||||||
autocmd FileType objc
|
|
||||||
\ let b:endwise_addition = '@end' |
|
|
||||||
\ let b:endwise_words = 'interface,implementation' |
|
|
||||||
\ let b:endwise_pattern = '^\s*@\%(interface\|implementation\)\>' |
|
|
||||||
\ let b:endwise_syngroups = 'objcObjDef'
|
|
||||||
autocmd FileType make
|
|
||||||
\ let b:endwise_addition = '\="end" . submatch(0)' |
|
|
||||||
\ let b:endwise_words = 'ifdef,ifndef,ifeq,ifneq,define' |
|
|
||||||
\ let b:endwise_pattern = '^\s*\(d\zsef\zeine\|\zsif\zen\=\(def\|eq\)\)\>' |
|
|
||||||
\ let b:endwise_syngroups = 'makePreCondit,makeDefine'
|
|
||||||
autocmd FileType verilog
|
|
||||||
\ let b:endwise_addition = '\="end" . submatch(0)' |
|
|
||||||
\ let b:endwise_words = 'begin,module,case,function,primitive,specify,task' |
|
|
||||||
\ let b:endwise_pattern = '\<\%(\zs\zebegin\|module\|case\|function\|primitive\|specify\|task\)\>.*$' |
|
|
||||||
\ let b:endwise_syngroups = 'verilogConditional,verilogLabel,verilogStatement'
|
|
||||||
autocmd FileType matlab
|
|
||||||
\ let b:endwise_addition = 'end' |
|
|
||||||
\ let b:endwise_words = 'function,if,for' |
|
|
||||||
\ let b:endwise_syngroups = 'matlabStatement,matlabFunction,matlabConditional,matlabRepeat'
|
|
||||||
autocmd FileType htmldjango
|
|
||||||
\ let b:endwise_addition = '{% end& %}' |
|
|
||||||
\ let b:endwise_words = 'autoescape,block,blocktrans,cache,comment,filter,for,if,ifchanged,ifequal,ifnotequal,language,spaceless,verbatim,with' |
|
|
||||||
\ let b:endwise_syngroups = 'djangoTagBlock,djangoStatement'
|
|
||||||
autocmd FileType htmljinja,jinja.html
|
|
||||||
\ let b:endwise_addition = '{% end& %}' |
|
|
||||||
\ let b:endwise_words = 'autoescape,block,cache,call,filter,for,if,macro,raw,set,trans,with' |
|
|
||||||
\ let b:endwise_syngroups = 'jinjaTagBlock,jinjaStatement'
|
|
||||||
autocmd FileType snippets
|
|
||||||
\ let b:endwise_addition = 'endsnippet' |
|
|
||||||
\ let b:endwise_words = 'snippet' |
|
|
||||||
\ let b:endwise_syngroups = 'snipSnippet,snipSnippetHeader,snipSnippetHeaderKeyword'
|
|
||||||
autocmd FileType * call s:abbrev()
|
|
||||||
augroup END " }}}1
|
|
||||||
|
|
||||||
function! s:abbrev()
|
|
||||||
if exists('g:endwise_abbreviations')
|
|
||||||
for word in split(get(b:, 'endwise_words', ''), ',')
|
|
||||||
execute 'iabbrev <buffer><script>' word word.'<CR><SID>DiscretionaryEnd<Space><C-U><BS>'
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:teardownMappings()
|
|
||||||
inoremap <buffer> <C-X><CR> <C-X><CR>
|
|
||||||
inoremap <buffer> <CR> <CR>
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Functions {{{1
|
|
||||||
|
|
||||||
function! EndwiseDiscretionary()
|
|
||||||
return <SID>crend(0)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! EndwiseAlways()
|
|
||||||
return <SID>crend(1)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}1
|
|
||||||
|
|
||||||
" Maps {{{1
|
|
||||||
|
|
||||||
if empty(maparg("<Plug>DiscretionaryEnd"))
|
|
||||||
inoremap <silent> <SID>DiscretionaryEnd <C-R>=<SID>crend(0)<CR>
|
|
||||||
inoremap <silent> <SID>AlwaysEnd <C-R>=<SID>crend(1)<CR>
|
|
||||||
imap <script> <Plug>DiscretionaryEnd <SID>DiscretionaryEnd
|
|
||||||
imap <script> <Plug>AlwaysEnd <SID>AlwaysEnd
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:endwise_no_mappings')
|
|
||||||
if maparg('<CR>','i') =~# '<C-R>=.*crend(.)<CR>\|<\%(Plug\|SNR\|SID\)>.*End'
|
|
||||||
" Already mapped
|
|
||||||
elseif maparg('<CR>','i') =~? '<cr>'
|
|
||||||
exe "imap <script> <C-X><CR> ".maparg('<CR>','i')."<SID>AlwaysEnd"
|
|
||||||
exe "imap <silent> <script> <CR> ".maparg('<CR>','i')."<SID>DiscretionaryEnd"
|
|
||||||
elseif maparg('<CR>','i') =~# '<Plug>\w\+CR'
|
|
||||||
exe "imap <C-X><CR> ".maparg('<CR>', 'i')."<Plug>AlwaysEnd"
|
|
||||||
exe "imap <silent> <CR> ".maparg('<CR>', 'i')."<Plug>DiscretionaryEnd"
|
|
||||||
else
|
|
||||||
imap <script> <C-X><CR> <CR><SID>AlwaysEnd
|
|
||||||
imap <CR> <CR><Plug>DiscretionaryEnd
|
|
||||||
endif
|
|
||||||
autocmd endwise CmdwinEnter * call s:teardownMappings()
|
|
||||||
endif
|
|
||||||
|
|
||||||
" }}}1
|
|
||||||
|
|
||||||
" Code {{{1
|
|
||||||
|
|
||||||
function! s:mysearchpair(beginpat,endpat,synidpat)
|
|
||||||
let s:lastline = line('.')
|
|
||||||
call s:synid()
|
|
||||||
let line = searchpair(a:beginpat,'',a:endpat,'Wn','<SID>synid() !~# "^'.substitute(a:synidpat,'\\','\\\\','g').'$"',line('.')+50)
|
|
||||||
return line
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:crend(always)
|
|
||||||
let n = ""
|
|
||||||
if !exists("b:endwise_addition") || !exists("b:endwise_words") || !exists("b:endwise_syngroups")
|
|
||||||
return n
|
|
||||||
endif
|
|
||||||
let synids = join(map(split(b:endwise_syngroups, ','), 'hlID(v:val)'), ',')
|
|
||||||
let wordchoice = '\%('.substitute(b:endwise_words,',','\\|','g').'\)'
|
|
||||||
if exists("b:endwise_pattern")
|
|
||||||
let beginpat = substitute(b:endwise_pattern,'&',substitute(wordchoice,'\\','\\&','g'),'g')
|
|
||||||
else
|
|
||||||
let beginpat = '\<'.wordchoice.'\>'
|
|
||||||
endif
|
|
||||||
let lnum = line('.') - 1
|
|
||||||
let space = matchstr(getline(lnum),'^\s*')
|
|
||||||
let col = match(getline(lnum),beginpat) + 1
|
|
||||||
let word = matchstr(getline(lnum),beginpat)
|
|
||||||
let endword = substitute(word,'.*',b:endwise_addition,'')
|
|
||||||
let y = n.endword."\<C-O>O"
|
|
||||||
if exists("b:endwise_end_pattern")
|
|
||||||
let endpat = '\w\@<!'.substitute(word, '.*', substitute(b:endwise_end_pattern, '\\', '\\\\', 'g'), '').'\w\@!'
|
|
||||||
elseif b:endwise_addition[0:1] ==# '\='
|
|
||||||
let endpat = '\w\@<!'.endword.'\w\@!'
|
|
||||||
else
|
|
||||||
let endpat = '\w\@<!'.substitute('\w\+', '.*', b:endwise_addition, '').'\w\@!'
|
|
||||||
endif
|
|
||||||
let synidpat = '\%('.substitute(synids,',','\\|','g').'\)'
|
|
||||||
if a:always
|
|
||||||
return y
|
|
||||||
elseif col <= 0 || synID(lnum,col,1) !~ '^'.synidpat.'$'
|
|
||||||
return n
|
|
||||||
elseif getline('.') !~# '^\s*#\=$'
|
|
||||||
return n
|
|
||||||
endif
|
|
||||||
let line = s:mysearchpair(beginpat,endpat,synidpat)
|
|
||||||
" even is false if no end was found, or if the end found was less
|
|
||||||
" indented than the current line
|
|
||||||
let even = strlen(matchstr(getline(line),'^\s*')) >= strlen(space)
|
|
||||||
if line == 0
|
|
||||||
let even = 0
|
|
||||||
endif
|
|
||||||
if !even && line == line('.') + 1
|
|
||||||
return y
|
|
||||||
endif
|
|
||||||
if even
|
|
||||||
return n
|
|
||||||
endif
|
|
||||||
return y
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:synid()
|
|
||||||
" Checking this helps to force things to stay in sync
|
|
||||||
while s:lastline < line('.')
|
|
||||||
let s = synID(s:lastline,indent(s:lastline)+1,1)
|
|
||||||
let s:lastline = nextnonblank(s:lastline + 1)
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
let s = synID(line('.'),col('.'),1)
|
|
||||||
let s:lastline = line('.')
|
|
||||||
return s
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}1
|
|
||||||
|
|
||||||
" vim:set sw=2 sts=2:
|
|
|
@ -1,571 +0,0 @@
|
||||||
" ragtag.vim - Ghetto XML/HTML mappings (formerly allml.vim)
|
|
||||||
" Author: Tim Pope <http://tpo.pe/>
|
|
||||||
" Version: 2.0
|
|
||||||
" GetLatestVimScripts: 1896 1 :AutoInstall: ragtag.vim
|
|
||||||
|
|
||||||
if exists("g:loaded_ragtag") || &cp || v:version < 700
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let g:loaded_ragtag = 1
|
|
||||||
|
|
||||||
if !exists('g:html_indent_inctags')
|
|
||||||
let g:html_indent_inctags = 'body,head,html,tbody,p,li,dt,dd'
|
|
||||||
endif
|
|
||||||
if !exists('g:html_indent_autotags')
|
|
||||||
let g:html_indent_autotags = 'wbr'
|
|
||||||
endif
|
|
||||||
if !exists('g:html_indent_script1')
|
|
||||||
let g:html_indent_script1 = 'inc'
|
|
||||||
endif
|
|
||||||
if !exists('g:html_indent_style1')
|
|
||||||
let g:html_indent_style1 = 'inc'
|
|
||||||
endif
|
|
||||||
|
|
||||||
augroup ragtag
|
|
||||||
autocmd!
|
|
||||||
autocmd BufReadPost * if ! did_filetype() && getline(1)." ".getline(2).
|
|
||||||
\ " ".getline(3) =~? '<\%(!DOCTYPE \)\=html\>' | setf html | endif
|
|
||||||
autocmd FileType *html*,wml,jsp,gsp,mustache,smarty call s:Init()
|
|
||||||
autocmd FileType php,asp*,cf,mason,eruby,liquid,jst,eelixir call s:Init()
|
|
||||||
autocmd FileType xml,xslt,xsd,docbk call s:Init()
|
|
||||||
autocmd FileType javascript.jsx,jsx,javascriptreact,handlebars call s:Init()
|
|
||||||
autocmd FileType typescript.tsx,tsx,typescriptreact call s:Init()
|
|
||||||
autocmd InsertLeave * call s:Leave()
|
|
||||||
autocmd CursorHold * if exists("b:loaded_ragtag") | call s:Leave() | endif
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
inoremap <silent> <Plug>ragtagHtmlComplete <C-R>=<SID>htmlEn()<CR><C-X><C-O><C-P><C-R>=<SID>htmlDis()<CR><C-N>
|
|
||||||
|
|
||||||
" Public interface, for if you have your own filetypes to activate on
|
|
||||||
function! RagtagInit()
|
|
||||||
call s:Init()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! AllmlInit()
|
|
||||||
call s:Init()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:isFiletype(ft)
|
|
||||||
return index(split(&filetype, '\.'), a:ft) >= 0
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:Init()
|
|
||||||
let b:loaded_ragtag = 1
|
|
||||||
if s:subtype() == "xml"
|
|
||||||
imap <script> <buffer> <C-X>! <?xml version="1.0" encoding="<C-R>=toupper(<SID>charset())<CR>"?>
|
|
||||||
elseif s:subtype() == "xhtml"
|
|
||||||
imap <script> <buffer> <C-X>! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
else
|
|
||||||
imap <script> <buffer> <C-X>! <!DOCTYPE html>
|
|
||||||
endif
|
|
||||||
|
|
||||||
if empty(&l:define)
|
|
||||||
let &l:define = '\<id=["'']\='
|
|
||||||
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setl def='
|
|
||||||
endif
|
|
||||||
|
|
||||||
imap <silent> <buffer> <C-X># <C-R>=<SID>charsetTag()<CR>
|
|
||||||
inoremap <silent> <buffer> <SID>HtmlComplete <C-R>=<SID>htmlEn()<CR><C-X><C-O><C-P><C-R>=<SID>htmlDis()<CR><C-N>
|
|
||||||
imap <buffer> <C-X>H <SID>HtmlComplete
|
|
||||||
inoremap <silent> <buffer> <C-X>$ <C-R>=<SID>javascriptIncludeTag()<CR>
|
|
||||||
inoremap <silent> <buffer> <C-X>@ <C-R>=<SID>stylesheetTag()<CR>
|
|
||||||
inoremap <silent> <buffer> <C-X><Space> <Esc>ciW<Lt><C-R>"<C-R>=<SID>tagextras()<CR>></<C-R>"><Esc>F<i
|
|
||||||
inoremap <silent> <buffer> <C-X><CR> <Esc>ciW<Lt><C-R>"<C-R>=<SID>tagextras()<CR>><CR></<C-R>"><Esc>O
|
|
||||||
if exists("&omnifunc")
|
|
||||||
inoremap <silent> <buffer> <C-X>/ <Lt>/<C-R>=<SID>htmlEn()<CR><C-X><C-O><C-R>=<SID>htmlDis()<CR><C-R>=<SID>reindent()<CR>
|
|
||||||
if exists(":XMLns")
|
|
||||||
XMLns xhtml10s
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
inoremap <silent> <buffer> <C-X>/ <Lt>/><Left>
|
|
||||||
endif
|
|
||||||
let b:surround_{char2nr("p")} = "<p>\n\t\r\n</p>"
|
|
||||||
let b:surround_{char2nr("d")} = "<div\1div: \r^[^ ]\r &\1>\n\t\r\n</div>"
|
|
||||||
imap <buffer> <C-X><C-_> <C-X>/
|
|
||||||
imap <buffer> <SID>ragtagOopen <C-X><Lt><Space>
|
|
||||||
imap <buffer> <SID>ragtagOclose <Space><C-X>><Left><Left>
|
|
||||||
if s:isFiletype('php')
|
|
||||||
inoremap <buffer> <C-X><Lt> <?php
|
|
||||||
inoremap <buffer> <C-X>> ?>
|
|
||||||
inoremap <buffer> <SID>ragtagOopen <?php<Space>echo<Space>
|
|
||||||
let b:surround_45 = "<?php \r ?>"
|
|
||||||
let b:surround_61 = "<?php echo \r ?>"
|
|
||||||
elseif s:isFiletype('htmltt') || s:isFiletype('tt2html')
|
|
||||||
inoremap <buffer> <C-X><Lt> [%
|
|
||||||
inoremap <buffer> <C-X>> %]
|
|
||||||
let b:surround_45 = "[% \r %]"
|
|
||||||
let b:surround_61 = "[% \r %]"
|
|
||||||
if !exists("b:surround_101")
|
|
||||||
let b:surround_101 = "[% \r %]\n[% END %]"
|
|
||||||
endif
|
|
||||||
elseif s:isFiletype('mustache')
|
|
||||||
inoremap <buffer> <SID>ragtagOopen {{<Space>
|
|
||||||
inoremap <buffer> <SID>ragtagOclose <Space>}}<Left><Left>
|
|
||||||
inoremap <buffer> <C-X><Lt> {{
|
|
||||||
inoremap <buffer> <C-X>> }}
|
|
||||||
let b:surround_45 = "{{ \r }}"
|
|
||||||
let b:surround_61 = "{{ \r }}"
|
|
||||||
elseif s:isFiletype('django') || s:isFiletype('htmldjango') || s:isFiletype('liquid') || s:isFiletype('htmljinja')
|
|
||||||
inoremap <buffer> <SID>ragtagOopen {{<Space>
|
|
||||||
inoremap <buffer> <SID>ragtagOclose <Space>}}<Left><Left>
|
|
||||||
inoremap <buffer> <C-X><Lt> {%
|
|
||||||
inoremap <buffer> <C-X>> %}
|
|
||||||
let b:surround_45 = "{% \r %}"
|
|
||||||
let b:surround_61 = "{{ \r }}"
|
|
||||||
elseif s:isFiletype('mason')
|
|
||||||
inoremap <buffer> <SID>ragtagOopen <&<Space>
|
|
||||||
inoremap <buffer> <SID>ragtagOclose <Space>&><Left><Left>
|
|
||||||
inoremap <buffer> <C-X><Lt> <%
|
|
||||||
inoremap <buffer> <C-X>> %>
|
|
||||||
let b:surround_45 = "<% \r %>"
|
|
||||||
let b:surround_61 = "<& \r &>"
|
|
||||||
elseif s:isFiletype('cf')
|
|
||||||
inoremap <buffer> <SID>ragtagOopen <cfoutput>
|
|
||||||
inoremap <buffer> <SID>ragtagOclose </cfoutput><Left><C-Left><Left>
|
|
||||||
inoremap <buffer> <C-X><Lt> <cf
|
|
||||||
inoremap <buffer> <C-X>> >
|
|
||||||
let b:surround_45 = "<cf\r>"
|
|
||||||
let b:surround_61 = "<cfoutput>\r</cfoutput>"
|
|
||||||
elseif s:isFiletype('smarty')
|
|
||||||
inoremap <buffer> <SID>ragtagOopen {
|
|
||||||
inoremap <buffer> <SID>ragtagOclose }
|
|
||||||
inoremap <buffer> <C-X><Lt> {
|
|
||||||
inoremap <buffer> <C-X>> }
|
|
||||||
let b:surround_45 = "{\r}"
|
|
||||||
let b:surround_61 = "{\r}"
|
|
||||||
elseif s:isFiletype('handlebars')
|
|
||||||
inoremap <buffer> <SID>ragtagOopen {{
|
|
||||||
inoremap <buffer> <SID>ragtagOclose }}
|
|
||||||
inoremap <buffer> <C-X><Lt> {{
|
|
||||||
inoremap <buffer> <C-X>> }}
|
|
||||||
let b:surround_45 = "{{\r}}"
|
|
||||||
let b:surround_61 = "{{\r}}"
|
|
||||||
elseif &filetype ==# 'html'
|
|
||||||
inoremap <buffer> <SID>ragtagOopen <!--#echo var=
|
|
||||||
inoremap <buffer> <C-X><Lt> <!--#
|
|
||||||
inoremap <buffer> <C-X>> -->
|
|
||||||
let b:surround_45 = "<!--#\r -->"
|
|
||||||
let b:surround_61 = "<!--#echo var=\r -->"
|
|
||||||
else
|
|
||||||
inoremap <buffer> <SID>ragtagOopen <%=<Space>
|
|
||||||
inoremap <buffer> <C-X><Lt> <%
|
|
||||||
inoremap <buffer> <C-X>> %>
|
|
||||||
let b:surround_45 = "<% \r %>"
|
|
||||||
let b:surround_61 = "<%= \r %>"
|
|
||||||
endif
|
|
||||||
imap <script> <buffer> <C-X>= <SID>ragtagOopen<SID>ragtagOclose<Left>
|
|
||||||
imap <script> <buffer> <C-X>+ <C-V><NL><Esc>I<SID>ragtagOopen<Esc>A<SID>ragtagOclose<Esc>F<NL>s
|
|
||||||
" <%\n\n%>
|
|
||||||
if s:isFiletype('cf')
|
|
||||||
inoremap <buffer> <C-X>] <cfscript><CR></cfscript><Esc>O
|
|
||||||
elseif s:isFiletype('mason')
|
|
||||||
inoremap <buffer> <C-X>] <%perl><CR></%perl><Esc>O
|
|
||||||
elseif &filetype ==# 'html' || &filetype ==# 'xml' || &filetype ==# 'xhtml'
|
|
||||||
imap <buffer> <C-X>] <script<C-R>=<SID>javascriptType()<CR>><CR></script><Esc>O
|
|
||||||
else
|
|
||||||
imap <buffer> <C-X>] <C-X><Lt><CR><C-X>><Esc>O
|
|
||||||
endif
|
|
||||||
" <% %>
|
|
||||||
if s:isFiletype('eruby') || s:isFiletype('jst')
|
|
||||||
inoremap <buffer> <C-X>- <%<Space><Space>%><Esc>2hi
|
|
||||||
inoremap <buffer> <C-X>_ <C-V><NL><Esc>I<%<Space><Esc>A<Space>%><Esc>F<NL>s
|
|
||||||
elseif s:isFiletype('cf')
|
|
||||||
inoremap <buffer> <C-X>- <cf><Left>
|
|
||||||
inoremap <buffer> <C-X>_ <cfset ><Left>
|
|
||||||
elseif s:isFiletype('smarty')
|
|
||||||
imap <buffer> <C-X>- <C-X><Lt><C-X>><Esc>i
|
|
||||||
imap <buffer> <C-X>_ <C-V><NL><Esc>I<C-X><Lt><Esc>A<C-X>><Esc>F<NL>s
|
|
||||||
else
|
|
||||||
imap <buffer> <C-X>- <C-X><Lt><Space><Space><C-X>><Esc>2hi
|
|
||||||
imap <buffer> <C-X>_ <C-V><NL><Esc>I<C-X><Lt><Space><Esc>A<Space><C-X>><Esc>F<NL>s
|
|
||||||
endif
|
|
||||||
" Comments
|
|
||||||
if s:isFiletype('aspperl') || s:isFiletype('aspvbs')
|
|
||||||
imap <buffer> <C-X>' <C-X><Lt>'<Space><Space><C-X>><Esc>2hi
|
|
||||||
imap <buffer> <C-X>" <C-V><NL><Esc>I<C-X><Lt>'<Space><Esc>A<Space><C-X>><Esc>F<NL>s
|
|
||||||
let b:surround_35 = maparg("<C-X><Lt>","i")."' \r ".maparg("<C-X>>","i")
|
|
||||||
elseif s:isFiletype('jsp') || s:isFiletype('gsp')
|
|
||||||
inoremap <buffer> <C-X>' <Lt>%--<Space><Space>--%><Esc>4hi
|
|
||||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<%--<Space><Esc>A<Space>--%><Esc>F<NL>s
|
|
||||||
let b:surround_35 = "<%-- \r --%>"
|
|
||||||
elseif s:isFiletype('cf')
|
|
||||||
inoremap <buffer> <C-X>' <Lt>!---<Space><Space>---><Esc>4hi
|
|
||||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<!---<Space><Esc>A<Space>---><Esc>F<NL>s
|
|
||||||
setlocal commentstring=<!---%s--->
|
|
||||||
let b:surround_35 = "<!--- \r --->"
|
|
||||||
elseif &filetype ==# 'html' || &filetype ==# 'xml' || &filetype ==# 'xhtml'
|
|
||||||
inoremap <buffer> <C-X>' <Lt>!--<Space><Space>--><Esc>3hi
|
|
||||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<!--<Space><Esc>A<Space>--><Esc>F<NL>s
|
|
||||||
let b:surround_35 = "<!-- \r -->"
|
|
||||||
elseif s:isFiletype('django') || s:isFiletype('htmldjango') || s:isFiletype('htmljinja')
|
|
||||||
inoremap <buffer> <C-X>' {#<Space><Space>#}<Esc>2hi
|
|
||||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<C-X>{#<Space><Esc>A<Space>#}<Esc>F<NL>s
|
|
||||||
let b:surround_35 = "{# \r #}"
|
|
||||||
elseif s:isFiletype('liquid')
|
|
||||||
inoremap <buffer> <C-X>' {%<Space>comment<Space>%}{%<Space>endcomment<Space>%}<Esc>15hi
|
|
||||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<C-X>{%<Space>comment<Space>%}<Esc>A{%<Space>endcomment<Space>%}<Esc>F<NL>s
|
|
||||||
let b:surround_35 = "{% comment %}\r{% endcomment %}"
|
|
||||||
elseif s:isFiletype('smarty')
|
|
||||||
inoremap <buffer> <C-X>' {*<Space><Space>*}<Esc>2hi
|
|
||||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<C-X>{*<Space><Esc>A<Space>*}<Esc>F<NL>s
|
|
||||||
let b:surround_35 = "{* \r *}"
|
|
||||||
elseif s:isFiletype('handlebars')
|
|
||||||
imap <script> <buffer> <C-X>= <SID>ragtagOopen<SID>ragtagOclose<Left><Left>
|
|
||||||
inoremap <buffer> <C-X>_ <Esc>ciW{{#<C-R>"}}<CR>{{/<C-R>"}}<Esc>khi
|
|
||||||
inoremap <buffer> <C-X>' {{!}}<Esc>hi
|
|
||||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I{{!<Esc>A}}<Esc>F<NL>s
|
|
||||||
else
|
|
||||||
imap <buffer> <C-X>' <C-X><Lt>#<Space><Space><C-X>><Esc>2hi
|
|
||||||
imap <buffer> <C-X>" <C-V><NL><Esc>I<C-X><Lt>#<Space><Esc>A<Space><C-X>><Esc>F<NL>s
|
|
||||||
let b:surround_35 = maparg("<C-X><Lt>","i")."# \r ".maparg("<C-X>>","i")
|
|
||||||
endif
|
|
||||||
imap <buffer> <C-X>% <Plug>ragtagUrlEncode
|
|
||||||
imap <buffer> <C-X>& <Plug>ragtagXmlEncode
|
|
||||||
imap <buffer> <C-V>% <Plug>ragtagUrlV
|
|
||||||
imap <buffer> <C-V>& <Plug>ragtagXmlV
|
|
||||||
if !exists("b:did_indent")
|
|
||||||
if s:subtype() == "xml"
|
|
||||||
runtime! indent/xml.vim
|
|
||||||
else
|
|
||||||
runtime! indent/html.vim
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if exists("g:html_indent_tags") && g:html_indent_tags !~ '\\|p\>'
|
|
||||||
let g:html_indent_tags = g:html_indent_tags.'\|p\|li\|dt\|dd'
|
|
||||||
let g:html_indent_tags = g:html_indent_tags.'\|article\|aside\|audio\|bdi\|canvas\|command\|datalist\|details\|figcaption\|figure\|footer\|header\|hgroup\|mark\|meter\|nav\|output\|progress\|rp\|rt\|ruby\|section\|summary\|time\|video'
|
|
||||||
endif
|
|
||||||
set indentkeys+=!^F
|
|
||||||
let b:surround_indent = 1
|
|
||||||
silent doautocmd User Ragtag
|
|
||||||
silent doautocmd User ragtag
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:Leave()
|
|
||||||
call s:disableescape()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:length(str)
|
|
||||||
return strlen(substitute(a:str,'.','.','g'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:repeat(str,cnt)
|
|
||||||
let cnt = a:cnt
|
|
||||||
let str = ""
|
|
||||||
while cnt > 0
|
|
||||||
let str = str . a:str
|
|
||||||
let cnt = cnt - 1
|
|
||||||
endwhile
|
|
||||||
return str
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:reindent()
|
|
||||||
if (len(&indentexpr) || &cindent)
|
|
||||||
return "\<C-F>"
|
|
||||||
endif
|
|
||||||
return ""
|
|
||||||
endfun
|
|
||||||
|
|
||||||
function! s:stylesheetType()
|
|
||||||
if s:subtype() == 'html5'
|
|
||||||
return ''
|
|
||||||
else
|
|
||||||
return ' type="text/css"'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:stylesheetTag()
|
|
||||||
if !exists("b:ragtag_stylesheet_link_tag")
|
|
||||||
if exists("b:allml_stylesheet_link_tag")
|
|
||||||
let b:ragtag_stylesheet_link_tag = b:allml_stylesheet_link_tag
|
|
||||||
else
|
|
||||||
let b:ragtag_stylesheet_link_tag = '<link rel="stylesheet"'.s:stylesheetType()." href=\"/stylesheets/\r.css\" />"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
return s:insertTag(b:ragtag_stylesheet_link_tag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:javascriptType()
|
|
||||||
if s:subtype() == 'html5'
|
|
||||||
return ''
|
|
||||||
else
|
|
||||||
return ' type="text/javascript"'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:javascriptIncludeTag()
|
|
||||||
if !exists("b:ragtag_javascript_include_tag")
|
|
||||||
if exists("b:allml_javascript_include_tag")
|
|
||||||
let b:ragtag_javascript_include_tag = b:allml_javascript_include_tag
|
|
||||||
else
|
|
||||||
let b:ragtag_javascript_include_tag = '<script'.s:javascriptType()." src=\"/javascripts/\r.js\"></script>"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
return s:insertTag(b:ragtag_javascript_include_tag)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:insertTag(tag)
|
|
||||||
let tag = a:tag
|
|
||||||
if s:subtype() == "html"
|
|
||||||
let tag = substitute(a:tag,'\s*/>','>','g')
|
|
||||||
endif
|
|
||||||
let before = matchstr(tag,'^.\{-\}\ze\r')
|
|
||||||
let after = matchstr(tag,'\r\zs\%(.*\r\)\@!.\{-\}$')
|
|
||||||
" middle isn't currently used
|
|
||||||
let middle = matchstr(tag,'\r\zs.\{-\}\ze\r')
|
|
||||||
return before.after.s:repeat("\<Left>",s:length(after))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:htmlEn()
|
|
||||||
let b:ragtag_omni = &l:omnifunc
|
|
||||||
let b:ragtag_isk = &l:isk
|
|
||||||
let b:ragtag_completeopt = &l:completeopt
|
|
||||||
" : is for namespaced xml attributes
|
|
||||||
setlocal omnifunc=htmlcomplete#CompleteTags isk+=: completeopt=
|
|
||||||
return ""
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:htmlDis()
|
|
||||||
if exists("b:ragtag_omni")
|
|
||||||
let &l:omnifunc = b:ragtag_omni
|
|
||||||
unlet b:ragtag_omni
|
|
||||||
endif
|
|
||||||
if exists("b:ragtag_isk")
|
|
||||||
let &l:isk = b:ragtag_isk
|
|
||||||
unlet b:ragtag_isk
|
|
||||||
endif
|
|
||||||
if exists("b:ragtag_completeopt")
|
|
||||||
let &l:completeopt = b:ragtag_completeopt
|
|
||||||
unlet b:ragtag_completeopt
|
|
||||||
endif
|
|
||||||
return ""
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:subtype()
|
|
||||||
let top = getline(1)."\n".getline(2)
|
|
||||||
if (top =~ '<?xml\>' && &ft !~? 'html') || &ft =~? '^\%(xml\|xsd\|xslt\|docbk\)$'
|
|
||||||
return "xml"
|
|
||||||
elseif top =~? '\<xhtml\>'
|
|
||||||
return 'xhtml'
|
|
||||||
elseif top =~? '<!DOCTYPE html>'
|
|
||||||
return 'html5'
|
|
||||||
elseif top =~? '[^<]\<html\>'
|
|
||||||
return "html"
|
|
||||||
elseif s:isFiletype('xhtml')
|
|
||||||
return "xhtml"
|
|
||||||
elseif exists("b:loaded_ragtag")
|
|
||||||
return "html5"
|
|
||||||
else
|
|
||||||
return ""
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:closetagback()
|
|
||||||
if s:subtype() == "html"
|
|
||||||
return ">\<Left>"
|
|
||||||
else
|
|
||||||
return " />\<Left>\<Left>\<Left>"
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:closetag()
|
|
||||||
if s:subtype() == "html"
|
|
||||||
return ">"
|
|
||||||
else
|
|
||||||
return " />"
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:charset()
|
|
||||||
let enc = &fileencoding
|
|
||||||
if enc == ""
|
|
||||||
let enc = &encoding
|
|
||||||
endif
|
|
||||||
if enc == "latin1"
|
|
||||||
return "ISO-8859-1"
|
|
||||||
elseif enc == ""
|
|
||||||
return "US-ASCII"
|
|
||||||
else
|
|
||||||
return enc
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:charsetTag()
|
|
||||||
if s:subtype() == 'html5'
|
|
||||||
return '<meta charset="'.s:charset().'"'.s:closetag()
|
|
||||||
else
|
|
||||||
return '<meta http-equiv="Content-Type" content="text/html; charset='.s:charset().'"'.s:closetag()
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:tagextras()
|
|
||||||
if s:subtype() == "xml"
|
|
||||||
return ""
|
|
||||||
elseif @" == 'html' && s:subtype() == 'xhtml'
|
|
||||||
let lang = "en"
|
|
||||||
if exists("$LANG") && $LANG =~ '^..'
|
|
||||||
let lang = strpart($LANG,0,2)
|
|
||||||
endif
|
|
||||||
return ' xmlns="http://www.w3.org/1999/xhtml" lang="'.lang.'" xml:lang="'.lang.'"'
|
|
||||||
elseif @" == 'style'
|
|
||||||
return s:stylesheetType()
|
|
||||||
elseif @" == 'script'
|
|
||||||
return s:javascriptType()
|
|
||||||
elseif @" == 'table'
|
|
||||||
return ' cellspacing="0"'
|
|
||||||
else
|
|
||||||
return ""
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
inoremap <silent> <SID>urlspace <C-R>=<SID>getinput()=~?'\%([?&]\<Bar>&\)[%a-z0-9._~+-]*=[%a-z0-9._~+-]*$'?'+':'%20'<CR>
|
|
||||||
|
|
||||||
function! s:urltab(htmlesc)
|
|
||||||
let line = s:getinput()
|
|
||||||
let g:line = line
|
|
||||||
if line =~ '[^ <>"'."'".']\@<!\w\+$'
|
|
||||||
return ":"
|
|
||||||
elseif line =~ '[^ <>"'."'".']\@<!\w\+:/\=/\=[%a-z0-9._~+-]*$'
|
|
||||||
return "/"
|
|
||||||
elseif line =~? '\%([?&]\|&\)[%a-z0-9._~+-]*$'
|
|
||||||
return "="
|
|
||||||
elseif line =~? '\%([?&]\|&\)[%a-z0-9._~+-]*=[%a-z0-9._~+-]*$'
|
|
||||||
if a:htmlesc || synIDattr(synID(line('.'),col('.')-1,1),"name") =~ 'mlString$'
|
|
||||||
return "&"
|
|
||||||
else
|
|
||||||
return "&"
|
|
||||||
endif
|
|
||||||
elseif line =~ '/$\|\.\w\+$'
|
|
||||||
return "?"
|
|
||||||
else
|
|
||||||
return "/"
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:toggleurlescape()
|
|
||||||
let htmllayer = 0
|
|
||||||
if exists("b:ragtag_escape_mode")
|
|
||||||
if b:ragtag_escape_mode == "url"
|
|
||||||
call s:disableescape()
|
|
||||||
return ""
|
|
||||||
elseif b:ragtag_escape_mode == "xml"
|
|
||||||
let htmllayer = 1
|
|
||||||
endif
|
|
||||||
call s:disableescape()
|
|
||||||
endif
|
|
||||||
let b:ragtag_escape_mode = "url"
|
|
||||||
imap <buffer> <BS> <Plug>ragtagBSUrl
|
|
||||||
inoremap <buffer> <CR> %0A
|
|
||||||
imap <script> <buffer> <Space> <SID>urlspace
|
|
||||||
inoremap <buffer> <Tab> &
|
|
||||||
inoremap <buffer> <Bar> %7C
|
|
||||||
if htmllayer
|
|
||||||
inoremap <silent> <buffer> <Tab> <C-R>=<SID>urltab(1)<CR>
|
|
||||||
else
|
|
||||||
inoremap <silent> <buffer> <Tab> <C-R>=<SID>urltab(0)<CR>
|
|
||||||
endif
|
|
||||||
let i = 33
|
|
||||||
while i < 127
|
|
||||||
" RFC3986: reserved = :/?#[]@ !$&'()*+,;=
|
|
||||||
if nr2char(i) =~# '[|=A-Za-z0-9_.~-]'
|
|
||||||
else
|
|
||||||
call s:urlmap(nr2char(i))
|
|
||||||
endif
|
|
||||||
let i = i + 1
|
|
||||||
endwhile
|
|
||||||
return ""
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:urlencode(char)
|
|
||||||
let i = 0
|
|
||||||
let repl = ""
|
|
||||||
while i < strlen(a:char)
|
|
||||||
let repl = repl . printf("%%%02X",char2nr(strpart(a:char,i,1)))
|
|
||||||
let i = i + 1
|
|
||||||
endwhile
|
|
||||||
return repl
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:urlmap(char)
|
|
||||||
let repl = s:urlencode(a:char)
|
|
||||||
exe "inoremap <buffer> ".a:char." ".repl
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:urlv()
|
|
||||||
return s:urlencode(nr2char(getchar()))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:togglexmlescape()
|
|
||||||
if exists("b:ragtag_escape_mode")
|
|
||||||
if b:ragtag_escape_mode == "xml"
|
|
||||||
call s:disableescape()
|
|
||||||
return ""
|
|
||||||
endif
|
|
||||||
call s:disableescape()
|
|
||||||
endif
|
|
||||||
let b:ragtag_escape_mode = "xml"
|
|
||||||
imap <buffer> <BS> <Plug>ragtagBSXml
|
|
||||||
inoremap <buffer> <Lt> <
|
|
||||||
inoremap <buffer> > >
|
|
||||||
inoremap <buffer> & &
|
|
||||||
inoremap <buffer> " "
|
|
||||||
return ""
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:disableescape()
|
|
||||||
if exists("b:ragtag_escape_mode")
|
|
||||||
if b:ragtag_escape_mode == "xml"
|
|
||||||
silent! iunmap <buffer> <BS>
|
|
||||||
silent! iunmap <buffer> <Lt>
|
|
||||||
silent! iunmap <buffer> >
|
|
||||||
silent! iunmap <buffer> &
|
|
||||||
silent! iunmap <buffer> "
|
|
||||||
elseif b:ragtag_escape_mode == "url"
|
|
||||||
silent! iunmap <buffer> <BS>
|
|
||||||
silent! iunmap <buffer> <Tab>
|
|
||||||
silent! iunmap <buffer> <CR>
|
|
||||||
silent! iunmap <buffer> <Space>
|
|
||||||
silent! iunmap <buffer> <Bar>
|
|
||||||
let i = 33
|
|
||||||
while i < 127
|
|
||||||
if nr2char(i) =~# '[|A-Za-z0-9_.~-]'
|
|
||||||
else
|
|
||||||
exe "silent! iunmap <buffer> ".nr2char(i)
|
|
||||||
endif
|
|
||||||
let i = i + 1
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
unlet b:ragtag_escape_mode
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:getinput()
|
|
||||||
return strpart(getline('.'),0,col('.')-1)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:bspattern(pattern)
|
|
||||||
let start = s:getinput()
|
|
||||||
let match = matchstr(start,'\%('.a:pattern.'\)$')
|
|
||||||
if match == ""
|
|
||||||
return "\<BS>"
|
|
||||||
else
|
|
||||||
return s:repeat("\<BS>",strlen(match))
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
inoremap <silent> <Plug>ragtagBSUrl <C-R>=<SID>bspattern('%\x\x\=\<Bar>&')<CR>
|
|
||||||
inoremap <silent> <Plug>ragtagBSXml <C-R>=<SID>bspattern('&#\=\w*;\<Bar><[^><]*>\=')<CR>
|
|
||||||
inoremap <silent> <SID>ragtagUrlEncode <C-R>=<SID>toggleurlescape()<CR>
|
|
||||||
inoremap <silent> <SID>ragtagXmlEncode <C-R>=<SID>togglexmlescape()<CR>
|
|
||||||
inoremap <silent> <Plug>ragtagUrlEncode <C-R>=<SID>toggleurlescape()<CR>
|
|
||||||
inoremap <silent> <Plug>ragtagXmlEncode <C-R>=<SID>togglexmlescape()<CR>
|
|
||||||
inoremap <silent> <Plug>ragtagUrlV <C-R>=<SID>urlv()<CR>
|
|
||||||
inoremap <silent> <Plug>ragtagXmlV <C-R>="&#".getchar().";"<CR>
|
|
||||||
|
|
||||||
if exists("g:ragtag_global_maps")
|
|
||||||
imap <C-X>H <Plug>ragtagHtmlComplete
|
|
||||||
imap <C-X>/ </<Plug>ragtagHtmlComplete
|
|
||||||
imap <C-X>% <Plug>ragtagUrlEncode
|
|
||||||
imap <C-X>& <Plug>ragtagXmlEncode
|
|
||||||
imap <C-V>% <Plug>ragtagUrlV
|
|
||||||
imap <C-V>& <Plug>ragtagXmlV
|
|
||||||
endif
|
|
|
@ -1,163 +0,0 @@
|
||||||
"==============================================================================
|
|
||||||
"Script Title: rainbow parentheses improved
|
|
||||||
"Script Version: 2.52
|
|
||||||
"Author: luochen1990, Francisco Lopes
|
|
||||||
"Last Edited: 2013 Sep 12
|
|
||||||
|
|
||||||
" By default, use rainbow colors copied from gruvbox colorscheme (https://github.com/morhetz/gruvbox).
|
|
||||||
" They are generally good for both light and dark colorschemes.
|
|
||||||
let s:guifgs = exists('g:rainbow_guifgs')? g:rainbow_guifgs : [
|
|
||||||
\ '#458588',
|
|
||||||
\ '#b16286',
|
|
||||||
\ '#cc241d',
|
|
||||||
\ '#d65d0e',
|
|
||||||
\ '#458588',
|
|
||||||
\ '#b16286',
|
|
||||||
\ '#cc241d',
|
|
||||||
\ '#d65d0e',
|
|
||||||
\ '#458588',
|
|
||||||
\ '#b16286',
|
|
||||||
\ '#cc241d',
|
|
||||||
\ '#d65d0e',
|
|
||||||
\ '#458588',
|
|
||||||
\ '#b16286',
|
|
||||||
\ '#cc241d',
|
|
||||||
\ '#d65d0e',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
let s:ctermfgs = exists('g:rainbow_ctermfgs')? g:rainbow_ctermfgs : [
|
|
||||||
\ 'brown',
|
|
||||||
\ 'Darkblue',
|
|
||||||
\ 'darkgray',
|
|
||||||
\ 'darkgreen',
|
|
||||||
\ 'darkcyan',
|
|
||||||
\ 'darkred',
|
|
||||||
\ 'darkmagenta',
|
|
||||||
\ 'brown',
|
|
||||||
\ 'gray',
|
|
||||||
\ 'black',
|
|
||||||
\ 'darkmagenta',
|
|
||||||
\ 'Darkblue',
|
|
||||||
\ 'darkgreen',
|
|
||||||
\ 'darkcyan',
|
|
||||||
\ 'darkred',
|
|
||||||
\ 'red',
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
let s:max = has('gui_running')? len(s:guifgs) : len(s:ctermfgs)
|
|
||||||
|
|
||||||
func! rainbow#load(...)
|
|
||||||
if exists('b:loaded')
|
|
||||||
cal rainbow#clear()
|
|
||||||
endif
|
|
||||||
|
|
||||||
if a:0 >= 1
|
|
||||||
let b:loaded = a:1
|
|
||||||
elseif &ft == 'cpp'
|
|
||||||
let b:loaded = [
|
|
||||||
\ ['(', ')'],
|
|
||||||
\ ['\[', '\]'],
|
|
||||||
\ ['{', '}'],
|
|
||||||
\ ['\v%(<operator\_s*)@<!%(%(\i|^\_s*|template\_s*)@<=\<[<#=]@!|\<@<!\<[[:space:]<#=]@!)', '\v%(-)@<!\>']
|
|
||||||
\ ]
|
|
||||||
elseif &ft == 'rust' || &ft == 'cs' || &ft == 'java'
|
|
||||||
let b:loaded = [
|
|
||||||
\ ['(', ')'],
|
|
||||||
\ ['\[', '\]'],
|
|
||||||
\ ['{', '}'],
|
|
||||||
\ ['\v%(\i|^\_s*)@<=\<[<#=]@!|\<@<!\<[[:space:]<#=]@!', '\v%(-)@<!\>']
|
|
||||||
\ ]
|
|
||||||
else
|
|
||||||
let b:loaded = [ ['(', ')'], ['\[', '\]'], ['{', '}'] ]
|
|
||||||
endif
|
|
||||||
|
|
||||||
let b:operators = (a:0 < 2) ? '"\v[{\[(<_"''`#*/>)\]}]@![[:punct:]]|\*/@!|/[/*]@!|\<#@!|#@<!\>"' : a:2
|
|
||||||
|
|
||||||
if b:operators != ''
|
|
||||||
exe 'syn match op_lv0 '.b:operators
|
|
||||||
let cmd = 'syn match %s %s containedin=%s contained'
|
|
||||||
for [left , right] in b:loaded
|
|
||||||
for each in range(1, s:max)
|
|
||||||
exe printf(cmd, 'op_lv'.each, b:operators, 'lv'.each)
|
|
||||||
endfor
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
let str = 'TOP'
|
|
||||||
for each in range(1, s:max)
|
|
||||||
let str .= ',lv'.each
|
|
||||||
endfor
|
|
||||||
|
|
||||||
let cmd = 'syn region %s matchgroup=%s start=+%s+ end=+%s+ containedin=%s contains=%s,%s,@Spell fold'
|
|
||||||
for [left , right] in b:loaded
|
|
||||||
for each in range(1, s:max)
|
|
||||||
exe printf(cmd, 'lv'.each, 'lv'.each.'c', left, right, 'lv'.(each % s:max + 1), str, 'op_lv'.each)
|
|
||||||
endfor
|
|
||||||
endfor
|
|
||||||
|
|
||||||
cal rainbow#activate()
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func! rainbow#clear()
|
|
||||||
if exists('b:loaded')
|
|
||||||
unlet b:loaded
|
|
||||||
exe 'syn clear op_lv0'
|
|
||||||
for each in range(1 , s:max)
|
|
||||||
exe 'syn clear lv'.each
|
|
||||||
exe 'syn clear op_lv'.each
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func! rainbow#activate()
|
|
||||||
if !exists('b:loaded')
|
|
||||||
cal rainbow#load()
|
|
||||||
endif
|
|
||||||
exe 'hi default op_lv0 ctermfg='.s:ctermfgs[-1].' guifg='.s:guifgs[-1]
|
|
||||||
for id in range(1 , s:max)
|
|
||||||
let ctermfg = s:ctermfgs[(s:max - id) % len(s:ctermfgs)]
|
|
||||||
let guifg = s:guifgs[(s:max - id) % len(s:guifgs)]
|
|
||||||
exe 'hi default lv'.id.'c ctermfg='.ctermfg.' guifg='.guifg
|
|
||||||
exe 'hi default op_lv'.id.' ctermfg='.ctermfg.' guifg='.guifg
|
|
||||||
endfor
|
|
||||||
exe 'syn sync fromstart'
|
|
||||||
let b:active = 'active'
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func! rainbow#inactivate()
|
|
||||||
if exists('b:active')
|
|
||||||
exe 'hi clear op_lv0'
|
|
||||||
for each in range(1, s:max)
|
|
||||||
exe 'hi clear lv'.each.'c'
|
|
||||||
exe 'hi clear op_lv'.each.''
|
|
||||||
endfor
|
|
||||||
exe 'syn sync fromstart'
|
|
||||||
unlet b:active
|
|
||||||
endif
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func! rainbow#toggle()
|
|
||||||
if exists('b:active')
|
|
||||||
cal rainbow#inactivate()
|
|
||||||
else
|
|
||||||
cal rainbow#activate()
|
|
||||||
endif
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
if exists('g:rainbow_active') && g:rainbow_active
|
|
||||||
if exists('g:rainbow_load_separately')
|
|
||||||
let ps = g:rainbow_load_separately
|
|
||||||
for i in range(len(ps))
|
|
||||||
if len(ps[i]) < 3
|
|
||||||
exe printf('au syntax,colorscheme %s call rainbow#load(ps[%d][1])' , ps[i][0] , i)
|
|
||||||
else
|
|
||||||
exe printf('au syntax,colorscheme %s call rainbow#load(ps[%d][1] , ps[%d][2])' , ps[i][0] , i , i)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
else
|
|
||||||
au syntax,colorscheme * call rainbow#load()
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
command! RainbowToggle call rainbow#toggle()
|
|
||||||
command! RainbowLoad call rainbow#load()
|
|
|
@ -1,12 +0,0 @@
|
||||||
" Copyright 2013 LuoChen (luochen1990@gmail.com). Licensed under the Apache License 2.0.
|
|
||||||
|
|
||||||
if exists('s:loaded') || !(exists('g:rainbow_active') || exists('g:rainbow_conf')) | finish | endif | let s:loaded = 1
|
|
||||||
|
|
||||||
command! RainbowToggle call rainbow_main#toggle()
|
|
||||||
command! RainbowToggleOn call rainbow_main#load()
|
|
||||||
command! RainbowToggleOff call rainbow_main#clear()
|
|
||||||
|
|
||||||
if (exists('g:rainbow_active') && g:rainbow_active)
|
|
||||||
auto syntax * call rainbow_main#load()
|
|
||||||
auto colorscheme * call rainbow_main#load()
|
|
||||||
endif
|
|
Reference in a new issue