mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-10 12:33:51 -05:00
Update (periodic rebuild)
I originally meant to run this before adding haproxy, but accidentally
pushed that into my branch. If you'd like to see that content, it's at
414ad25c3a.
This commit is contained in:
@@ -89,22 +89,22 @@ function s:SynAt(l,c)
|
||||
endfunction
|
||||
|
||||
function s:ParseCino(f)
|
||||
let [divider, n, cstr] = [0] + matchlist(&cino,
|
||||
\ '\%(.*,\)\=\%(\%d'.char2nr(a:f).'\(-\)\=\([.s0-9]*\)\)\=')[1:2]
|
||||
for c in split(cstr,'\zs')
|
||||
if c == '.' && !divider
|
||||
let [s, n, divider] = [strridx(&cino, a:f)+1, '', 0]
|
||||
while s && &cino[ s ] =~ '[^,]'
|
||||
if &cino[ s ] == '.'
|
||||
let divider = 1
|
||||
elseif c ==# 's'
|
||||
elseif &cino[ s ] ==# 's'
|
||||
if n !~ '\d'
|
||||
return n . s:sw() + 0
|
||||
endif
|
||||
let n = str2nr(n) * s:sw()
|
||||
break
|
||||
else
|
||||
let [n, divider] .= [c, 0]
|
||||
let [n, divider] .= [&cino[ s ], 0]
|
||||
endif
|
||||
endfor
|
||||
return str2nr(n) / max([str2nr(divider),1])
|
||||
let s += 1
|
||||
endwhile
|
||||
return str2nr(n) / max([divider, 1])
|
||||
endfunction
|
||||
|
||||
" Optimized {skip} expr, only callable from the search loop which
|
||||
@@ -208,18 +208,15 @@ function s:ExprCol()
|
||||
let bal = 0
|
||||
while s:SearchLoop('[{}?:]','bW',s:skip_expr)
|
||||
if s:LookingAt() == ':'
|
||||
if getline('.')[col('.')-2] == ':'
|
||||
call cursor(0,col('.')-1)
|
||||
continue
|
||||
endif
|
||||
let bal -= 1
|
||||
let bal -= !search('\m:\%#','bW')
|
||||
elseif s:LookingAt() == '?'
|
||||
if getline('.')[col('.'):col('.')+1] =~ '^\.\d\@!'
|
||||
continue
|
||||
" ?. conditional chain, not ternary start
|
||||
elseif !bal
|
||||
return 1
|
||||
else
|
||||
let bal += 1
|
||||
endif
|
||||
let bal += 1
|
||||
elseif s:LookingAt() == '{'
|
||||
return !s:IsBlock()
|
||||
elseif !s:GetPair('{','}','bW',s:skip_expr)
|
||||
@@ -316,8 +313,8 @@ function s:IsContOne(cont)
|
||||
endfunction
|
||||
|
||||
function s:IsSwitch()
|
||||
return search('\m\C\%'.join(b:js_cache[1:],'l\%').
|
||||
\ 'c{\_s*\%(\%(\/\/.*\_$\|\/\*\_.\{-}\*\/\)\@>\_s*\)*\%(case\|default\)\>','nW'.s:z)
|
||||
return search(printf('\m\C\%%%dl\%%%dc%s',b:js_cache[1],b:js_cache[2],
|
||||
\ '{\_s*\%(\%(\/\/.*\_$\|\/\*\_.\{-}\*\/\)\@>\_s*\)*\%(case\|default\)\>'),'nW'.s:z)
|
||||
endfunction
|
||||
|
||||
" https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader
|
||||
@@ -367,8 +364,8 @@ function GetJavascriptIndent()
|
||||
return -1
|
||||
endif
|
||||
|
||||
let s:l1 = max([0,prevnonblank(v:lnum) - (s:rel ? 2000 : 1000),
|
||||
\ get(get(b:,'hi_indent',{}),'blocklnr')])
|
||||
let nest = get(get(b:,'hi_indent',{}),'blocklnr')
|
||||
let s:l1 = max([0, prevnonblank(v:lnum) - (s:rel ? 2000 : 1000), nest])
|
||||
call cursor(v:lnum,1)
|
||||
if s:PreviousToken() is ''
|
||||
return
|
||||
@@ -376,7 +373,7 @@ function GetJavascriptIndent()
|
||||
let [l:lnum, lcol, pline] = getpos('.')[1:2] + [getline('.')[:col('.')-1]]
|
||||
|
||||
let l:line = substitute(l:line,'^\s*','','')
|
||||
let l:line_raw = l:line
|
||||
let l:line_s = l:line[0]
|
||||
if l:line[:1] == '/*'
|
||||
let l:line = substitute(l:line,'^\%(\/\*.\{-}\*\/\s*\)*','','')
|
||||
endif
|
||||
@@ -450,7 +447,7 @@ function GetJavascriptIndent()
|
||||
let pval = s:ParseCino('(')
|
||||
if !pval
|
||||
let [Wval, vcol] = [s:ParseCino('W'), virtcol('.')]
|
||||
if search('\m\S','W',num)
|
||||
if search('\m'.get(g:,'javascript_indent_W_pat','\S'),'W',num)
|
||||
return s:ParseCino('w') ? vcol : virtcol('.')-1
|
||||
endif
|
||||
return Wval ? s:Nat(num_ind + Wval) : vcol
|
||||
@@ -460,7 +457,7 @@ function GetJavascriptIndent()
|
||||
|
||||
" main return
|
||||
if l:line =~ '^[])}]\|^|}'
|
||||
if l:line_raw[0] == ')'
|
||||
if l:line_s == ')'
|
||||
if s:ParseCino('M')
|
||||
return indent(l:lnum)
|
||||
elseif num && &cino =~# 'm' && !s:ParseCino('m')
|
||||
@@ -470,10 +467,8 @@ function GetJavascriptIndent()
|
||||
return num_ind
|
||||
elseif num
|
||||
return s:Nat(num_ind + get(l:,'case_offset',s:sw()) + l:switch_offset + b_l + is_op)
|
||||
endif
|
||||
let nest = get(get(b:,'hi_indent',{}),'blocklnr')
|
||||
if nest
|
||||
return indent(nest) + s:sw() + b_l + is_op
|
||||
elseif nest
|
||||
return indent(nextnonblank(nest+1)) + b_l + is_op
|
||||
endif
|
||||
return b_l + is_op
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user