@@ -74,15 +74,10 @@ function s:Trimline(ln)
74
74
endfunction
75
75
76
76
" 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\)\=\)' ) . ' $'
86
81
87
82
function s: OneScope (lnum,text)
88
83
return cursor (a: lnum , match (' ' . a: text , ' \%(\<else\|\<do\|=>\)$' )) + 1 ||
@@ -188,9 +183,7 @@ function GetJavascriptIndent()
188
183
try
189
184
let save_magic = &magic
190
185
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 ])
194
187
" Get the current line.
195
188
let l: line = getline (v: lnum )
196
189
let syns = synIDattr (synID (v: lnum , 1 , 0 ), ' name' )
@@ -261,7 +254,7 @@ function GetJavascriptIndent()
261
254
\ float2nr (str2float (matchstr (&cino ,' .*:\zs[-0-9.]*' )) * (&cino = ~# ' .*:[^,]*s' ? s: W : 1 ))
262
255
263
256
" 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
265
258
let bL = s: iscontOne (l: lnum ,num,isOp)
266
259
let bL -= (bL && l: line = ~ ' ^{' ) * s: W
267
260
if isOp && (! num || bchar && cursor (b: js_cache [1 ],b: js_cache [2 ])+ 1 && s: IsBlock ())
0 commit comments