forked from VimPlug/emmet-vim
Fixes against errors/warnings in vint
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
function! emmet#lang#haml#findTokens(str)
|
||||
function! emmet#lang#haml#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#parseIntoTree(abbr, type)
|
||||
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)
|
||||
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
|
||||
@@ -16,7 +16,7 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite
|
||||
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 str = ''
|
||||
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
@@ -31,49 +31,49 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite
|
||||
endif
|
||||
let Val = current.attr[attr]
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
if attribute_style == 'hash'
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ' :' . attr . ' => true'
|
||||
elseif attribute_style == 'html'
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= attr . '=true'
|
||||
end
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~ '\$\([^#{]\|$\)'
|
||||
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
|
||||
if attr ==# 'id' && len(valtmp) > 0
|
||||
let str .= '#' . Val
|
||||
elseif attr == 'class' && len(valtmp) > 0
|
||||
elseif attr ==# 'class' && len(valtmp) > 0
|
||||
let str .= '.' . substitute(Val, ' ', '.', 'g')
|
||||
else
|
||||
if len(tmp) > 0
|
||||
if attribute_style == 'hash'
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ','
|
||||
elseif attribute_style == 'html'
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= ' '
|
||||
endif
|
||||
endif
|
||||
let Val = substitute(Val, '\${cursor}', '', '')
|
||||
if attribute_style == 'hash'
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ' :' . attr . ' => "' . Val . '"'
|
||||
elseif attribute_style == 'html'
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= attr . '="' . Val . '"'
|
||||
end
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if len(tmp)
|
||||
if attribute_style == 'hash'
|
||||
if attribute_style ==# 'hash'
|
||||
let str .= '{' . tmp . ' }'
|
||||
elseif attribute_style == 'html'
|
||||
elseif attribute_style ==# 'html'
|
||||
let str .= '(' . tmp . ')'
|
||||
end
|
||||
endif
|
||||
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0
|
||||
let str .= "/"
|
||||
let str .= '/'
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
@@ -87,10 +87,10 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= " " . text
|
||||
let str .= ' ' . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . " |"
|
||||
let str .= "\n" . indent . line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) == 0
|
||||
@@ -105,10 +105,10 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= " " . text
|
||||
let str .= ' ' . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . " |"
|
||||
let str .= "\n" . indent . line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) > 0
|
||||
@@ -116,7 +116,7 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite
|
||||
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 inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= "\n" . indent . inner
|
||||
endif
|
||||
else
|
||||
@@ -131,16 +131,16 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#imageSize()
|
||||
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*$'
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~ '^\(/\|http\)'
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
@@ -153,13 +153,13 @@ function! emmet#lang#haml#imageSize()
|
||||
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"))
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#encodeImage()
|
||||
function! emmet#lang#haml#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#parseTag(tag)
|
||||
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)
|
||||
@@ -168,7 +168,7 @@ function! emmet#lang#haml#parseTag(tag)
|
||||
let mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) == 0
|
||||
if len(match) ==# 0
|
||||
break
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
@@ -181,17 +181,17 @@ function! emmet#lang#haml#parseTag(tag)
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#toggleComment()
|
||||
function! emmet#lang#haml#toggleComment() abort
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~ '^\s*-#'
|
||||
if line =~# '^\s*-#'
|
||||
call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*'))
|
||||
elseif line =~ '^\s*%[a-z]'
|
||||
elseif line =~# '^\s*%[a-z]'
|
||||
call setline('.', space . '-# ' . line[len(space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#balanceTag(flag) range
|
||||
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]
|
||||
@@ -256,11 +256,11 @@ function! emmet#lang#haml#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#moveNextPrevItem(flag)
|
||||
function! emmet#lang#haml#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#haml#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#moveNextPrev(flag)
|
||||
function! emmet#lang#haml#moveNextPrev(flag) abort
|
||||
let pos = search('""', a:flag ? 'Wb' : 'W')
|
||||
if pos != 0
|
||||
silent! normal! l
|
||||
@@ -268,11 +268,11 @@ function! emmet#lang#haml#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#splitJoinTag()
|
||||
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 getline(n) =~# '^\s*\ze%[a-z]'
|
||||
if len(matchstr(getline(n), '^\s*%[a-z]')) < sml
|
||||
break
|
||||
endif
|
||||
@@ -287,7 +287,7 @@ function! emmet#lang#haml#splitJoinTag()
|
||||
if l <= ml
|
||||
break
|
||||
endif
|
||||
exe n "delete"
|
||||
exe n 'delete'
|
||||
endwhile
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
@@ -308,11 +308,11 @@ function! emmet#lang#haml#splitJoinTag()
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#removeTag()
|
||||
function! emmet#lang#haml#removeTag() abort
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze[a-z]'
|
||||
if getline(n) =~# '^\s*\ze[a-z]'
|
||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
break
|
||||
endif
|
||||
@@ -328,8 +328,8 @@ function! emmet#lang#haml#removeTag()
|
||||
let n += 1
|
||||
endwhile
|
||||
if sn == n
|
||||
exe "delete"
|
||||
exe 'delete'
|
||||
else
|
||||
exe sn "," (n-1) "delete"
|
||||
exe sn ',' (n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -12,7 +12,7 @@ let s:mx = '\([+>]\|[<^]\+\)\{-}\s*'
|
||||
\ .'\%(\(@-\{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)
|
||||
function! emmet#lang#html#findTokens(str) abort
|
||||
let str = a:str
|
||||
let [pos, last_pos] = [0, 0]
|
||||
while 1
|
||||
@@ -25,23 +25,23 @@ function! emmet#lang#html#findTokens(str)
|
||||
let last_pos = pos
|
||||
while len(str) > 0
|
||||
let token = matchstr(str, s:mx, pos)
|
||||
if token == ''
|
||||
if token ==# ''
|
||||
break
|
||||
endif
|
||||
if token =~ '^\s'
|
||||
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\+="[^"]*$'
|
||||
if str =~# '^\w\+="[^"]*$'
|
||||
return ''
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
|
||||
@@ -82,23 +82,23 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
if len(str) == 0
|
||||
break
|
||||
endif
|
||||
if tag_name =~ '^#'
|
||||
if tag_name =~# '^#'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
if tag_name =~ '[^!]!$'
|
||||
if tag_name =~# '[^!]!$'
|
||||
let tag_name = tag_name[:-2]
|
||||
let important = 1
|
||||
endif
|
||||
if tag_name =~ '^\.'
|
||||
if tag_name =~# '^\.'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
if tag_name =~ '^\[.*\]$'
|
||||
if tag_name =~# '^\[.*\]$'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
let basedirect = basevalue[1] == '-' ? -1 : 1
|
||||
let basedirect = basevalue[1] ==# '-' ? -1 : 1
|
||||
let basevalue = 0 + abs(basevalue[1:])
|
||||
if multiplier <= 0 | let multiplier = 1 | endif
|
||||
|
||||
@@ -140,7 +140,7 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
let custom_expands = settings['custom_expands']
|
||||
endif
|
||||
for k in keys(custom_expands)
|
||||
if tag_name =~ k
|
||||
if tag_name =~# k
|
||||
let current.snippet = '${' . tag_name . '}'
|
||||
let current.name = ''
|
||||
break
|
||||
@@ -192,20 +192,20 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
while len(attr)
|
||||
let item = matchstr(attr, '\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[\%("[^"]*"\|[^"\]]*\)\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)*\)\)')
|
||||
if g:emmet_debug > 1
|
||||
echomsg "attr=" . item
|
||||
echomsg 'attr=' . item
|
||||
endif
|
||||
if len(item) == 0
|
||||
break
|
||||
endif
|
||||
if item[0] == '#'
|
||||
if item[0] ==# '#'
|
||||
let current.attr.id = item[1:]
|
||||
endif
|
||||
if item[0] == '.'
|
||||
if item[0] ==# '.'
|
||||
let current.attr.class = substitute(item[1:], '\.', ' ', 'g')
|
||||
endif
|
||||
if item[0] == '['
|
||||
if item[0] ==# '['
|
||||
let atts = item[1:-2]
|
||||
if matchstr(atts, '^\s*\zs[0-9a-zA-Z-:]\+\(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\)') == ''
|
||||
if matchstr(atts, '^\s*\zs[0-9a-zA-Z-:]\+\(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\)') ==# ''
|
||||
let ks = []
|
||||
if has_key(default_attributes, current.name)
|
||||
let dfa = default_attributes[current.name]
|
||||
@@ -217,7 +217,7 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
if len(ks) > 0
|
||||
let current.attr[ks[0]] = atts
|
||||
else
|
||||
let current.attr[atts] = ""
|
||||
let current.attr[atts] = ''
|
||||
endif
|
||||
else
|
||||
while len(atts)
|
||||
@@ -227,11 +227,11 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
endif
|
||||
let key = split(amat, '=')[0]
|
||||
let Val = amat[len(key)+1:]
|
||||
if key =~ '\.$' && Val == ''
|
||||
if key =~# '\.$' && Val ==# ''
|
||||
let key = key[:-2]
|
||||
unlet Val
|
||||
let Val = function('emmet#types#true')
|
||||
elseif Val =~ '^["'']'
|
||||
elseif Val =~# '^["'']'
|
||||
let Val = Val[1:-2]
|
||||
endif
|
||||
let current.attr[key] = Val
|
||||
@@ -248,7 +248,7 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
endif
|
||||
|
||||
" parse text
|
||||
if tag_name =~ '^{.*}$'
|
||||
if tag_name =~# '^{.*}$'
|
||||
let current.name = ''
|
||||
let current.value = tag_name
|
||||
else
|
||||
@@ -260,7 +260,7 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
|
||||
" parse step inside/outside
|
||||
if !empty(last)
|
||||
if operator =~ '>'
|
||||
if operator =~# '>'
|
||||
unlet! parent
|
||||
let parent = last
|
||||
let current.parent = last
|
||||
@@ -273,7 +273,7 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
let current.parent = parent
|
||||
let current.pos = 1
|
||||
endif
|
||||
if operator =~ '[<^]'
|
||||
if operator =~# '[<^]'
|
||||
for c in range(len(operator))
|
||||
let tmp = parent.parent
|
||||
if empty(tmp)
|
||||
@@ -288,17 +288,17 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
let last = current
|
||||
|
||||
" parse block
|
||||
if block_start =~ '('
|
||||
if operator =~ '>'
|
||||
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 =~ ')'
|
||||
if block_end =~# ')'
|
||||
for n in split(substitute(substitute(block_end, ' ', '', 'g'), ')', ',),', 'g'), ',')
|
||||
if n == ')'
|
||||
if n ==# ')'
|
||||
if len(pos) > 0 && last.pos >= pos[-1]
|
||||
for c in range(last.pos - pos[-1])
|
||||
let tmp = parent.parent
|
||||
@@ -333,24 +333,24 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
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 "---"
|
||||
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)
|
||||
function! s:dollar_add(base,no) abort
|
||||
if a:base > 0
|
||||
return a:base + a:no - 1
|
||||
elseif a:base < 0
|
||||
@@ -360,7 +360,7 @@ function! s:dollar_add(base,no)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
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
|
||||
@@ -418,12 +418,12 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
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
|
||||
if attr ==# 'id' | let comment .= '#' . Val | endif
|
||||
if attr ==# 'class' | let comment .= '.' . Val | endif
|
||||
endif
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~ '\$\([^#{]\|$\)'
|
||||
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')
|
||||
@@ -433,7 +433,7 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
if attr == 'class' && emmet#useFilter(filters, 'bem')
|
||||
if attr ==# 'class' && emmet#useFilter(filters, 'bem')
|
||||
let vals = split(Val, '\s\+')
|
||||
let Val = ''
|
||||
let lead = ''
|
||||
@@ -441,10 +441,10 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
if len(Val) > 0
|
||||
let Val .= ' '
|
||||
endif
|
||||
if _val =~ '^\a_'
|
||||
if _val =~# '^\a_'
|
||||
let lead = _val[0]
|
||||
let Val .= lead . ' ' . _val
|
||||
elseif _val =~ '^_'
|
||||
elseif _val =~# '^_'
|
||||
if len(lead) == 0
|
||||
let pattr = current.parent.attr
|
||||
if has_key(pattr, 'class')
|
||||
@@ -459,19 +459,19 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
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
|
||||
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
|
||||
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 str .= '>'
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
" TODO: regexp engine specified
|
||||
@@ -504,7 +504,7 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
endif
|
||||
endif
|
||||
let inner = emmet#toString(child, type, 0, filters, itemno, indent)
|
||||
let inner = substitute(inner, "^\n", "", 'g')
|
||||
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
|
||||
@@ -515,13 +515,13 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
if dr
|
||||
let str .= "\n"
|
||||
endif
|
||||
let str .= "</" . current_name . ">"
|
||||
let str .= '</' . current_name . '>'
|
||||
endif
|
||||
if len(comment) > 0
|
||||
if ct == "lastonly"
|
||||
let str .= "<!-- " . comment . " -->"
|
||||
if ct ==# 'lastonly'
|
||||
let str .= '<!-- ' . comment . ' -->'
|
||||
else
|
||||
let str .= "\n<!-- /" . comment . " -->"
|
||||
let str .= "\n<!-- /" . comment . ' -->'
|
||||
endif
|
||||
endif
|
||||
if len(current_name) > 0 && current.multiplier > 0 || stridx(','.settings.html.block_elements.',', ','.current_name.',') != -1
|
||||
@@ -530,13 +530,13 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#imageSize()
|
||||
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[^><]\+>$'
|
||||
if content !~# '^<img[^><]\+>$'
|
||||
return
|
||||
endif
|
||||
let current = emmet#lang#html#parseTag(content)
|
||||
@@ -544,9 +544,9 @@ function! emmet#lang#html#imageSize()
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~ '^\s*$'
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~ '^\(/\|http\)'
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
@@ -562,13 +562,13 @@ function! emmet#lang#html#imageSize()
|
||||
call emmet#util#setContent(img_region, html)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#encodeImage()
|
||||
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[^><]\+>$'
|
||||
if content !~# '^<img[^><]\+>$'
|
||||
return
|
||||
endif
|
||||
let current = emmet#lang#html#parseTag(content)
|
||||
@@ -576,7 +576,7 @@ function! emmet#lang#html#encodeImage()
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn !~ '^\(/\|http\)'
|
||||
if fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
@@ -590,7 +590,7 @@ function! emmet#lang#html#encodeImage()
|
||||
call emmet#util#setContent(img_region, html)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#parseTag(tag)
|
||||
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)
|
||||
@@ -612,7 +612,7 @@ function! emmet#lang#html#parseTag(tag)
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#toggleComment()
|
||||
function! emmet#lang#html#toggleComment() abort
|
||||
let orgpos = emmet#util#getcurpos()
|
||||
let curpos = emmet#util#getcurpos()
|
||||
let mx = '<\%#[^>]*>'
|
||||
@@ -639,12 +639,12 @@ function! emmet#lang#html#toggleComment()
|
||||
let pos2 = block[1]
|
||||
let content = emmet#util#getContent(block)
|
||||
let tag_name = matchstr(content, '^<\zs/\{0,1}[^ \r\n>]\+')
|
||||
if tag_name[0] == '/'
|
||||
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 =~ '/$'
|
||||
elseif tag_name =~# '/$'
|
||||
if !emmet#util#pointInRegion(orgpos[1:2], block)
|
||||
" it's broken tree
|
||||
call setpos('.', orgpos)
|
||||
@@ -678,7 +678,7 @@ function! emmet#lang#html#toggleComment()
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#balanceTag(flag) range
|
||||
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]
|
||||
@@ -743,13 +743,13 @@ function! emmet#lang#html#balanceTag(flag) range
|
||||
endwhile
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe "normal! gv"
|
||||
silent! exe 'normal! gv'
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#moveNextPrevItem(flag)
|
||||
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', '')
|
||||
@@ -758,7 +758,7 @@ function! emmet#lang#html#moveNextPrevItem(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#moveNextPrev(flag)
|
||||
function! emmet#lang#html#moveNextPrev(flag) abort
|
||||
let pos = search('\%(</\w\+\)\@<!\zs><\/\|\(""\)\|^\(\s*\)$', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 3
|
||||
startinsert!
|
||||
@@ -768,7 +768,7 @@ function! emmet#lang#html#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#splitJoinTag()
|
||||
function! emmet#lang#html#splitJoinTag() abort
|
||||
let curpos = emmet#util#getcurpos()
|
||||
while 1
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
@@ -776,13 +776,13 @@ function! emmet#lang#html#splitJoinTag()
|
||||
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 . '>'
|
||||
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] == '/'
|
||||
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')
|
||||
@@ -791,7 +791,7 @@ function! emmet#lang#html#splitJoinTag()
|
||||
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]*[^>]*>'
|
||||
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])
|
||||
@@ -808,7 +808,7 @@ function! emmet#lang#html#splitJoinTag()
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#removeTag()
|
||||
function! emmet#lang#html#removeTag() abort
|
||||
let curpos = emmet#util#getcurpos()
|
||||
while 1
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*'
|
||||
@@ -816,12 +816,12 @@ function! emmet#lang#html#removeTag()
|
||||
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)
|
||||
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] == '/'
|
||||
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')
|
||||
@@ -830,7 +830,7 @@ function! emmet#lang#html#removeTag()
|
||||
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]'
|
||||
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
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
function! emmet#lang#less#findTokens(str)
|
||||
function! emmet#lang#less#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#parseIntoTree(abbr, type)
|
||||
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)
|
||||
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()
|
||||
function! emmet#lang#less#imageSize() abort
|
||||
call emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#encodeImage()
|
||||
function! emmet#lang#less#encodeImage() abort
|
||||
return emmet#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#parseTag(tag)
|
||||
function! emmet#lang#less#parseTag(tag) abort
|
||||
return emmet#lang#css#parseTag(a:tag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#toggleComment()
|
||||
function! emmet#lang#less#toggleComment() abort
|
||||
call emmet#lang#css#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#balanceTag(flag) range
|
||||
function! emmet#lang#less#balanceTag(flag) range abort
|
||||
call emmet#lang#scss#balanceTag(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#moveNextPrevItem(flag)
|
||||
function! emmet#lang#less#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#less#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#moveNextPrev(flag)
|
||||
function! emmet#lang#less#moveNextPrev(flag) abort
|
||||
call emmet#lang#scss#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#splitJoinTag()
|
||||
function! emmet#lang#less#splitJoinTag() abort
|
||||
call emmet#lang#css#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#removeTag()
|
||||
function! emmet#lang#less#removeTag() abort
|
||||
call emmet#lang#css#removeTag()
|
||||
endfunction
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
function! emmet#lang#sass#findTokens(str)
|
||||
function! emmet#lang#sass#findTokens(str) abort
|
||||
return emmet#lang#css#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#parseIntoTree(abbr, type)
|
||||
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)
|
||||
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
|
||||
@@ -14,7 +14,7 @@ function! emmet#lang#sass#toString(settings, current, type, inline, filters, ite
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let str = ""
|
||||
let str = ''
|
||||
|
||||
let current_name = current.name
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
@@ -23,13 +23,13 @@ function! emmet#lang#sass#toString(settings, current, type, inline, filters, ite
|
||||
let tmp = ''
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
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'
|
||||
if attr ==# 'id'
|
||||
let str .= '#' . val
|
||||
elseif attr == 'class'
|
||||
elseif attr ==# 'class'
|
||||
let str .= '.' . val
|
||||
else
|
||||
let tmp .= attr . ': ' . val
|
||||
@@ -62,19 +62,19 @@ function! emmet#lang#sass#toString(settings, current, type, inline, filters, ite
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#imageSize()
|
||||
function! emmet#lang#sass#imageSize() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#encodeImage()
|
||||
function! emmet#lang#sass#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#parseTag(tag)
|
||||
function! emmet#lang#sass#parseTag(tag) abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#toggleComment()
|
||||
function! emmet#lang#sass#toggleComment() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#balanceTag(flag) range
|
||||
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]
|
||||
@@ -139,11 +139,11 @@ function! emmet#lang#sass#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#moveNextPrevItem(flag)
|
||||
function! emmet#lang#sass#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#sass#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#moveNextPrev(flag)
|
||||
function! emmet#lang#sass#moveNextPrev(flag) abort
|
||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
@@ -153,8 +153,8 @@ function! emmet#lang#sass#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#splitJoinTag()
|
||||
function! emmet#lang#sass#splitJoinTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#removeTag()
|
||||
function! emmet#lang#sass#removeTag() abort
|
||||
endfunction
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
function! emmet#lang#scss#findTokens(str)
|
||||
function! emmet#lang#scss#findTokens(str) abort
|
||||
return emmet#lang#css#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#parseIntoTree(abbr, type)
|
||||
if a:abbr =~ '>'
|
||||
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)
|
||||
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
|
||||
@@ -18,7 +18,7 @@ function! emmet#lang#scss#toString(settings, current, type, inline, filters, ite
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let str = ""
|
||||
let str = ''
|
||||
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
if len(current.name) > 0
|
||||
@@ -26,13 +26,13 @@ function! emmet#lang#scss#toString(settings, current, type, inline, filters, ite
|
||||
let tmp = ''
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
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'
|
||||
if attr ==# 'id'
|
||||
let str .= '#' . val
|
||||
elseif attr == 'class'
|
||||
elseif attr ==# 'class'
|
||||
let str .= '.' . val
|
||||
else
|
||||
let tmp .= attr . ': ' . val . ';'
|
||||
@@ -52,7 +52,7 @@ function! emmet#lang#scss#toString(settings, current, type, inline, filters, ite
|
||||
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 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)
|
||||
@@ -60,23 +60,23 @@ function! emmet#lang#scss#toString(settings, current, type, inline, filters, ite
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#imageSize()
|
||||
function! emmet#lang#scss#imageSize() abort
|
||||
call emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#encodeImage()
|
||||
function! emmet#lang#scss#encodeImage() abort
|
||||
return emmet#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#parseTag(tag)
|
||||
function! emmet#lang#scss#parseTag(tag) abort
|
||||
return emmet#lang#css#parseTag(a:tag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#toggleComment()
|
||||
function! emmet#lang#scss#toggleComment() abort
|
||||
call emmet#lang#css#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#balanceTag(flag) range
|
||||
function! emmet#lang#scss#balanceTag(flag) range abort
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
call setpos('.', curpos)
|
||||
@@ -102,24 +102,24 @@ function! emmet#lang#scss#balanceTag(flag) range
|
||||
endif
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe "normal! gv"
|
||||
silent! exe 'normal! gv'
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#moveNextPrevItem(flag)
|
||||
function! emmet#lang#scss#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#scss#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#moveNextPrev(flag)
|
||||
function! emmet#lang#scss#moveNextPrev(flag) abort
|
||||
call emmet#lang#css#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#splitJoinTag()
|
||||
function! emmet#lang#scss#splitJoinTag() abort
|
||||
call emmet#lang#css#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#removeTag()
|
||||
function! emmet#lang#scss#removeTag() abort
|
||||
call emmet#lang#css#removeTag()
|
||||
endfunction
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
function! emmet#lang#slim#findTokens(str)
|
||||
function! emmet#lang#slim#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#parseIntoTree(abbr, type)
|
||||
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)
|
||||
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
|
||||
@@ -14,7 +14,7 @@ function! emmet#lang#slim#toString(settings, current, type, inline, filters, ite
|
||||
let itemno = a:itemno
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let str = ""
|
||||
let str = ''
|
||||
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
@@ -31,7 +31,7 @@ function! emmet#lang#slim#toString(settings, current, type, inline, filters, ite
|
||||
let str .= ' ' . attr . '=true'
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~ '\$\([^#{]\|$\)'
|
||||
while Val =~# '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
endif
|
||||
@@ -51,7 +51,7 @@ function! emmet#lang#slim#toString(settings, current, type, inline, filters, ite
|
||||
let str = substitute(str, '\$#', text, 'g')
|
||||
endif
|
||||
for line in split(text, "\n")
|
||||
let str .= indent . "| " . line . "\n"
|
||||
let str .= indent . '| ' . line . "\n"
|
||||
endfor
|
||||
elseif len(current.child) == 0
|
||||
let str .= '${cursor}'
|
||||
@@ -65,14 +65,14 @@ function! emmet#lang#slim#toString(settings, current, type, inline, filters, ite
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
for line in split(text, "\n")
|
||||
let str .= indent . "| " . line . "\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 inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= "\n" . indent . inner
|
||||
endif
|
||||
else
|
||||
@@ -83,22 +83,22 @@ function! emmet#lang#slim#toString(settings, current, type, inline, filters, ite
|
||||
let str = substitute(str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
if str !~ "\n$"
|
||||
if str !~# "\n$"
|
||||
let str .= "\n"
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#imageSize()
|
||||
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*$'
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~ '^\(/\|http\)'
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
@@ -111,13 +111,13 @@ function! emmet#lang#slim#imageSize()
|
||||
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"))
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#encodeImage()
|
||||
function! emmet#lang#slim#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#parseTag(tag)
|
||||
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)
|
||||
@@ -139,17 +139,17 @@ function! emmet#lang#slim#parseTag(tag)
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#toggleComment()
|
||||
function! emmet#lang#slim#toggleComment() abort
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~ '^\s*/'
|
||||
if line =~# '^\s*/'
|
||||
call setline('.', space . line[len(space)+1:])
|
||||
elseif line =~ '^\s*[a-z]'
|
||||
elseif line =~# '^\s*[a-z]'
|
||||
call setline('.', space . '/' . line[len(space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#balanceTag(flag) range
|
||||
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]
|
||||
@@ -214,11 +214,11 @@ function! emmet#lang#slim#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#moveNextPrevItem(flag)
|
||||
function! emmet#lang#slim#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#slim#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#moveNextPrev(flag)
|
||||
function! emmet#lang#slim#moveNextPrev(flag) abort
|
||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
@@ -228,18 +228,18 @@ function! emmet#lang#slim#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#splitJoinTag()
|
||||
function! emmet#lang#slim#splitJoinTag() abort
|
||||
let n = line('.')
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze[a-z]'
|
||||
if getline(n) =~# '^\s*\ze[a-z]'
|
||||
let sn = n
|
||||
let n += 1
|
||||
if getline(n) =~ '^\s*|'
|
||||
if getline(n) =~# '^\s*|'
|
||||
while n <= line('$')
|
||||
if getline(n) !~ '^\s*|'
|
||||
if getline(n) !~# '^\s*|'
|
||||
break
|
||||
endif
|
||||
exe n "delete"
|
||||
exe n 'delete'
|
||||
endwhile
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
@@ -254,11 +254,11 @@ function! emmet#lang#slim#splitJoinTag()
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#removeTag()
|
||||
function! emmet#lang#slim#removeTag() abort
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze[a-z]'
|
||||
if getline(n) =~# '^\s*\ze[a-z]'
|
||||
let ml = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
break
|
||||
endif
|
||||
@@ -274,8 +274,8 @@ function! emmet#lang#slim#removeTag()
|
||||
let n += 1
|
||||
endwhile
|
||||
if sn == n
|
||||
exe "delete"
|
||||
exe 'delete'
|
||||
else
|
||||
exe sn "," (n-1) "delete"
|
||||
exe sn ',' (n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user