@@ -74,15 +74,10 @@ function s:Trimline(ln)
7474endfunction
7575
7676" configurable regexes that define continuation lines, not including (, {, or [.
77- if ! exists (' g:javascript_opfirst' )
78- let g: javascript_opfirst = ' \%([<>,?^%|*&]\|\/[/*]\@!\|\([-.:+]\)\1\@!\|=>\@!\|in\%(stanceof\)\=\>\)'
79- endif
80- if ! exists (' g:javascript_continuation' )
81- let g: javascript_continuation = ' \%([<=,.?/*^%|&:]\|+\@<!+\|-\@<!-\|=\@<!>\|\<in\%(stanceof\)\=\)'
82- endif
83-
84- let g: javascript_opfirst = ' ^' . g: javascript_opfirst
85- let g: javascript_continuation .= ' $'
77+ let s: javascript_opfirst = ' ^' . get (g: ,' javascript_opfirst' ,
78+ \ ' \%([<>,?^%|*&]\|\/[/*]\@!\|\([-.:+]\)\1\@!\|=>\@!\|in\%(stanceof\)\=\>\)' )
79+ let s: javascript_continuation = get (g: ,' javascript_continuation' ,
80+ \ ' \%([<=,.?/*^%|&:]\|+\@<!+\|-\@<!-\|=\@<!>\|\<in\%(stanceof\)\=\)' ) . ' $'
8681
8782function s: OneScope (lnum,text)
8883 return cursor (a: lnum , match (' ' . a: text , ' \%(\<else\|\<do\|=>\)$' )) + 1 ||
@@ -188,9 +183,7 @@ function GetJavascriptIndent()
188183 try
189184 let save_magic = &magic
190185 set magic
191- if ! exists (' b:js_cache' )
192- let b: js_cache = [0 ,0 ,0 ]
193- endif
186+ let b: js_cache = get (b: ,' js_cache' ,[0 ,0 ,0 ])
194187 " Get the current line.
195188 let l: line = getline (v: lnum )
196189 let syns = synIDattr (synID (v: lnum , 1 , 0 ), ' name' )
@@ -261,7 +254,7 @@ function GetJavascriptIndent()
261254 \ float2nr (str2float (matchstr (&cino ,' .*:\zs[-0-9.]*' )) * (&cino = ~# ' .*:[^,]*s' ? s: W : 1 ))
262255
263256 " most significant, find the indent amount
264- let isOp = l: line = ~# g : javascript_opfirst || pline !~# s: expr_case . ' $' && pline = ~# g : javascript_continuation
257+ let isOp = l: line = ~# s : javascript_opfirst || pline !~# s: expr_case . ' $' && pline = ~# s : javascript_continuation
265258 let bL = s: iscontOne (l: lnum ,num,isOp)
266259 let bL -= (bL && l: line = ~ ' ^{' ) * s: W
267260 if isOp && (! num || bchar && cursor (b: js_cache [1 ],b: js_cache [2 ])+ 1 && s: IsBlock ())
0 commit comments