From 47b54c2e5e4202d8dc9992d4aa049cd3d6bbaf81 Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 17 Dec 2014 17:26:10 +0900 Subject: [PATCH] Fixes against errors/warnings in vint --- autoload/emmet.vim | 19 ++--- autoload/emmet/lang.vim | 2 +- autoload/emmet/lang/haml.vim | 82 +++++++++--------- autoload/emmet/lang/html.vim | 160 +++++++++++++++++------------------ autoload/emmet/lang/less.vim | 24 +++--- autoload/emmet/lang/sass.vim | 32 +++---- autoload/emmet/lang/scss.vim | 38 ++++----- autoload/emmet/lang/slim.vim | 60 ++++++------- autoload/emmet/lorem/en.vim | 8 +- autoload/emmet/lorem/ja.vim | 2 +- autoload/emmet/util.vim | 80 +++++++++--------- 11 files changed, 253 insertions(+), 254 deletions(-) diff --git a/autoload/emmet.vim b/autoload/emmet.vim index 35ad936..399e7a9 100644 --- a/autoload/emmet.vim +++ b/autoload/emmet.vim @@ -44,6 +44,8 @@ function! emmet#getIndentation(...) abort endif if has_key(s:emmet_settings, type) && has_key(s:emmet_settings[type], 'indentation') let indent = s:emmet_settings[type].indentation + elseif has_key(s:emmet_settings.variables, 'indentation') + let indent = s:emmet_settings.variables.indentation elseif has_key(s:emmet_settings, 'indentation') let indent = s:emmet_settings.indentation else @@ -436,9 +438,10 @@ function! emmet#expandCursorExpr(expand, mode) abort let expand .= '${cursor}' endif endif + let expand = substitute(expand, '\${\d\+:\?\([^}]\+\)}', '$select$$cursor$\1$select$', 'g') + let expand = substitute(expand, '\${\d\+}', '$select$$cursor$$select$', 'g') let expand = substitute(expand, '\${cursor}', '$cursor$', '') let expand = substitute(expand, '\${cursor}', '', 'g') - let expand = substitute(expand, '\${\d\+:\?\([^}]\+\)}', '$select$\1$select$', 'g') let expand = substitute(expand, '\${cursor}', '', 'g') return expand endfunction @@ -668,17 +671,14 @@ function! emmet#expandAbbr(mode, abbr) range abort silent! foldopen endif let pos = emmet#util#getcurpos() - if getline('.')[col('.')-1:] =~# '^\$select' + let use_selection = emmet#getResource(type, 'use_selection', 0) + if use_selection && getline('.')[col('.')-1:] =~# '^\$select' let pos[2] += 1 silent! s/\$select\$// - if emmet#getResource(type, 'use_selection', 0) - let next = searchpos('.\ze\$select\$', 'nW') - silent! %s/\$\(cursor\|select\)\$//g - call emmet#util#selectRegion([pos[1:2], next]) - return "\gv" - endif + let next = searchpos('.\ze\$select\$', 'nW') silent! %s/\$\(cursor\|select\)\$//g - silent! call setpos('.', pos) + call emmet#util#selectRegion([pos[1:2], next]) + return "\gv" else silent! %s/\$\(cursor\|select\)\$//g silent! call setpos('.', pos) @@ -883,7 +883,6 @@ function! emmet#expandWord(abbr, type, orig) abort if a:orig ==# 0 let expand = emmet#expandDollarExpr(expand) let expand = substitute(expand, '\${cursor}', '', 'g') - let expand = substitute(expand, '\${\d\+\(:[^}]\+\|\)}', '\1', 'g') endif return expand endfunction diff --git a/autoload/emmet/lang.vim b/autoload/emmet/lang.vim index 12ee98f..c839fea 100644 --- a/autoload/emmet/lang.vim +++ b/autoload/emmet/lang.vim @@ -1,5 +1,5 @@ let s:exists = {} -function! emmet#lang#exists(type) +function! emmet#lang#exists(type) abort if len(a:type) == 0 return 0 elseif has_key(s:exists, a:type) diff --git a/autoload/emmet/lang/haml.vim b/autoload/emmet/lang/haml.vim index 30be99f..bd8d247 100644 --- a/autoload/emmet/lang/haml.vim +++ b/autoload/emmet/lang/haml.vim @@ -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 diff --git a/autoload/emmet/lang/html.vim b/autoload/emmet/lang/html.vim index a3a029c..2c81f48 100644 --- a/autoload/emmet/lang/html.vim +++ b/autoload/emmet/lang/html.vim @@ -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 = "\n" . str + if len(comment) > 0 && ct ==# 'both' + let str = '\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 .= "" + let str .= '' endif if len(comment) > 0 - if ct == "lastonly" - let str .= "" + if ct ==# 'lastonly' + let str .= '' else - let str .= "\n" + let str .= "\n' 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('') if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region) return endif let content = emmet#util#getContent(img_region) - if content !~ '^<]\+>$' + if content !~# '^<]\+>$' 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('') if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region) return endif let content = emmet#util#getContent(img_region) - if content !~ '^<]\+>$' + if content !~# '^<]\+>$' 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:] . '\>[^>]*>', '', '', '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 \" 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('\%(<\/\|\(""\)\|^\(\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] . ">' + if content[-2:] ==# '/>' && emmet#util#cursorInRegion(block) + let content = content[:-3] . '>' 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('', '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('', '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 diff --git a/autoload/emmet/lang/less.vim b/autoload/emmet/lang/less.vim index 28eb14f..25308a0 100644 --- a/autoload/emmet/lang/less.vim +++ b/autoload/emmet/lang/less.vim @@ -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 diff --git a/autoload/emmet/lang/sass.vim b/autoload/emmet/lang/sass.vim index fdca16e..10531d1 100644 --- a/autoload/emmet/lang/sass.vim +++ b/autoload/emmet/lang/sass.vim @@ -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 diff --git a/autoload/emmet/lang/scss.vim b/autoload/emmet/lang/scss.vim index 48fe918..f06ac77 100644 --- a/autoload/emmet/lang/scss.vim +++ b/autoload/emmet/lang/scss.vim @@ -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 diff --git a/autoload/emmet/lang/slim.vim b/autoload/emmet/lang/slim.vim index f493054..d57bf1f 100644 --- a/autoload/emmet/lang/slim.vim +++ b/autoload/emmet/lang/slim.vim @@ -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 diff --git a/autoload/emmet/lorem/en.vim b/autoload/emmet/lorem/en.vim index ea0e6e6..30713e4 100644 --- a/autoload/emmet/lorem/en.vim +++ b/autoload/emmet/lorem/en.vim @@ -1,4 +1,4 @@ -function! emmet#lorem#en#expand(command) +function! emmet#lorem#en#expand(command) abort let wcount = matchstr(a:command, '\(\d*\)$') let wcount = wcount > 0 ? wcount : 30 @@ -48,13 +48,13 @@ function! emmet#lorem#en#expand(command) call add(ret, word) if (sentence > 5 && emmet#util#rand() < 10000) || i == wcount - 1 if i == wcount - 1 - let endc = "?!..."[emmet#util#rand() % 5] + let endc = '?!...'[emmet#util#rand() % 5] call add(ret, endc) else - let endc = "?!,..."[emmet#util#rand() % 6] + let endc = '?!,...'[emmet#util#rand() % 6] call add(ret, endc . ' ') endif - if endc != ',' + if endc !=# ',' let sentence = 0 endif else diff --git a/autoload/emmet/lorem/ja.vim b/autoload/emmet/lorem/ja.vim index c954337..f99d8fa 100644 --- a/autoload/emmet/lorem/ja.vim +++ b/autoload/emmet/lorem/ja.vim @@ -1,6 +1,6 @@ scriptencoding utf-8 -function! emmet#lorem#ja#expand(command) +function! emmet#lorem#ja#expand(command) abort let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '') let wcount = wcount > 0 ? wcount : 30 diff --git a/autoload/emmet/util.vim b/autoload/emmet/util.vim index bd22a38..9da8f96 100644 --- a/autoload/emmet/util.vim +++ b/autoload/emmet/util.vim @@ -11,10 +11,10 @@ " -------------------- " begin::end " -------------------- -function! emmet#util#deleteContent(region) +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]) + 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 @@ -36,11 +36,11 @@ endfunction " bar " baz:end " -------------------- -function! emmet#util#setContent(region, content) +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]) + silent! exe 'delete '.(a:region[1][0] - a:region[0][0]) if len(newlines) == 0 let tmp = '' if a:region[0][1] > 1 @@ -72,7 +72,7 @@ endfunction " select_region : select region " this function make a selection of region -function! emmet#util#selectRegion(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]) @@ -80,7 +80,7 @@ endfunction " point_in_region : check point is in the region " this function return 0 or 1 -function! emmet#util#pointInRegion(point, region) +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 @@ -91,7 +91,7 @@ endfunction " cursor_in_region : check cursor is in the region " this function return 0 or 1 -function! emmet#util#cursorInRegion(region) +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) @@ -99,14 +99,14 @@ endfunction " region_is_valid : check region is valid " this function return 0 or 1 -function! emmet#util#regionIsValid(region) +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) +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')] @@ -117,7 +117,7 @@ endfunction " get_content : get content in region " this function return string in region -function! emmet#util#getContent(region) +function! emmet#util#getContent(region) abort if !emmet#util#regionIsValid(a:region) return '' endif @@ -133,7 +133,7 @@ endfunction " region_in_region : check region is in the region " this function return 0 or 1 -function! emmet#util#regionInRegion(outer, inner) +function! emmet#util#regionInRegion(outer, inner) abort if !emmet#util#regionIsValid(a:inner) || !emmet#util#regionIsValid(a:outer) return 0 endif @@ -142,16 +142,16 @@ endfunction " get_visualblock : get region of visual block " this function return region of visual block -function! emmet#util#getVisualBlock() +function! emmet#util#getVisualBlock() abort return [[line("'<"), col("'<")], [line("'>"), col("'>")]] endfunction "============================================================================== " html utils "============================================================================== -function! emmet#util#getContentFromURL(url) - 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' +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) @@ -184,7 +184,7 @@ function! emmet#util#getContentFromURL(url) return iconv(content, charset, &encoding) endfunction -function! emmet#util#getTextFromHTML(buf) +function! emmet#util#getTextFromHTML(buf) abort let threshold_len = 100 let threshold_per = 0.1 let buf = a:buf @@ -202,7 +202,7 @@ function! emmet#util#getTextFromHTML(buf) 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') @@ -221,7 +221,7 @@ function! emmet#util#getTextFromHTML(buf) return res endfunction -function! emmet#util#getImageSize(fn) +function! emmet#util#getImageSize(fn) abort let fn = a:fn if emmet#util#isImageMagickInstalled() @@ -231,7 +231,7 @@ function! emmet#util#getImageSize(fn) if filereadable(fn) let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g') else - if fn !~ '^\w\+://' + if fn !~# '^\w\+://' let path = fnamemodify(expand('%'), ':p:gs?\\?/?') if has('win32') || has('win64') | let path = tolower(path) @@ -252,29 +252,29 @@ function! emmet#util#getImageSize(fn) endif let [width, height] = [-1, -1] - if hex =~ '^89504e470d0a1a0a' + if hex =~# '^89504e470d0a1a0a' let width = eval('0x'.hex[32:39]) let height = eval('0x'.hex[40:47]) endif - if hex =~ '^ffd8' + 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' + 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]' + elseif bs =~# 'ffd[9a]' break - elseif bs =~ 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)' + 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' + if hex =~# '^47494638' let width = eval('0x'.hex[14:15].hex[12:13]) let height = eval('0x'.hex[18:19].hex[16:17]) endif @@ -282,7 +282,7 @@ function! emmet#util#getImageSize(fn) return [width, height] endfunction -function! emmet#util#imageSizeWithImageMagick(fn) +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 @@ -291,14 +291,14 @@ function! emmet#util#imageSizeWithImageMagick(fn) return img_size endfunction -function! emmet#util#isImageMagickInstalled() +function! emmet#util#isImageMagickInstalled() abort if !get(s:, 'emmet_use_identify', 1) return 0 endif return executable('identify') endfunction -function! emmet#util#unique(arr) +function! emmet#util#unique(arr) abort let m = {} let r = [] for i in a:arr @@ -311,39 +311,39 @@ function! emmet#util#unique(arr) endfunction let s:seed = localtime() -function! emmet#util#srand(seed) +function! emmet#util#srand(seed) abort let s:seed = a:seed endfunction -function! emmet#util#rand() +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, ...) - let content = get(a:000, 0, "") - let dir = expand("~/.emmet/cache") +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) + call mkdir(dir, 'p', 0700) endif - let file = dir . "/" . substitute(a:name, '\W', '_', 'g') + let file = dir . '/' . substitute(a:name, '\W', '_', 'g') if len(content) == 0 if !filereadable(file) - return "" + return '' endif return join(readfile(file), "\n") endif call writefile(split(content, "\n"), file) endfunction -function! emmet#util#getcurpos() +function! emmet#util#getcurpos() abort let pos = getpos('.') - if mode(0) == 'i' && pos[2] > 0 + if mode(0) ==# 'i' && pos[2] > 0 let pos[2] -=1 endif return pos endfunction -function! emmet#util#closePopup() - return pumvisible() ? "\" : "" +function! emmet#util#closePopup() abort + return pumvisible() ? "\" : '' endfunction