43
43
44
44
let s: line_pre = ' ^\s*\%(\/\*.*\*\/\s*\)*'
45
45
let s: js_keywords = s: line_pre . ' \%(break\|import\|export\|catch\|const\|continue\|debugger\|delete\|do\|else\|finally\|for\|function\|if\|in\|instanceof\|let\|new\|return\|switch\|this\|throw\|try\|typeof\|var\|void\|while\|with\)\>\C'
46
- let s: expr_case = s: line_pre . ' \%(case\s\+[^\:]*\ |default\)\s*:\s* \C'
46
+ let s: expr_case = s: line_pre . ' \%(\%( case\>.*\)\ |default\)\s*:\C'
47
47
" Regex of syntax group names that are or delimit string or are comments.
48
48
let s: syng_strcom = ' \%(string\|regex\|special\|doc\|comment\|template\)\c'
49
49
@@ -337,7 +337,7 @@ function GetJavascriptIndent()
337
337
endif
338
338
339
339
" single opening bracket will assume you want a c style of indenting
340
- if s: Match ( v: lnum , s: line_pre . ' {' . s: line_term) && ! s: Match (lnum,s: block_regex ) &&
340
+ if line = ~ s: line_pre . ' {' . s: line_term && ! s: Match (lnum,s: block_regex ) &&
341
341
\ ! s: Match (lnum,s: comma_last )
342
342
return cindent (v: lnum )
343
343
endif
@@ -353,7 +353,7 @@ function GetJavascriptIndent()
353
353
354
354
" If we got a closing bracket on an empty line, find its match and indent
355
355
" according to it.
356
- let col = s: Match ( v: lnum , s: line_pre . ' []})]' )
356
+ let col = line = ~ s: line_pre . ' []})]'
357
357
if col > 0
358
358
let parlnum = v: lnum
359
359
while col
@@ -395,12 +395,12 @@ function GetJavascriptIndent()
395
395
end
396
396
397
397
" If previous line starts with an operator...
398
- elseif (s: Match (lnum, s: operator_first ) && ! s: Match (lnum,s: continuation_regex ))|| getline (lnum) = ~ ' ) ;\=' . s: line_term
398
+ elseif (s: Match (lnum, s: operator_first ) && ! s: Match (lnum,s: continuation_regex ))|| getline (lnum) = ~ ' []})] ;\=' . s: line_term
399
399
let counts = s: LineHasOpeningBrackets (lnum)
400
- if counts[ 0 ] == ' 2' && ! s: Match (lnum, s: operator_first )
400
+ if counts = ~ ' 2' && ! s: Match (lnum, s: operator_first )
401
401
call cursor (lnum, 1 )
402
402
" Search for the opening tag
403
- let mnum = s: lookForParens (' (' , ' )' , ' nbW' , 0 )
403
+ let mnum = s: lookForParens (' (\|{\|\[ ' , ' )\|}\|\] ' , ' nbW' , 0 )
404
404
if mnum > 0 && s: Match (mnum, s: operator_first )
405
405
return indent (mnum) - s: sw ()
406
406
end
@@ -434,16 +434,6 @@ function GetJavascriptIndent()
434
434
return 0
435
435
endif
436
436
437
- " foo('foo',
438
- " bar('bar', function() {
439
- " hi();
440
- " })
441
- " );
442
-
443
- " function (a, b, c, d,
444
- " e, f, g) {
445
- " console.log('inner');
446
- " }
447
437
" If the previous line ended with a block opening, add a level of indent.
448
438
if s: Match (lnum, s: block_regex )
449
439
return s: InMultiVarStatement (lnum, 0 , 0 ) || s: LineHasOpeningBrackets (lnum) !~ ' 2' ?
@@ -463,7 +453,8 @@ function GetJavascriptIndent()
463
453
call cursor (lnum, matchend (s: RemoveTrailingComments (strpart (line ,0 ,col (' .' ))), ' .*\zs[])}]' ))
464
454
endwhile
465
455
let cur = line (' .' )
466
- if cur < lnum && ! s: InMultiVarStatement (cur,0 ,0 )
456
+ if cur < lnum && ! s: InMultiVarStatement (cur,0 ,0 ) &&
457
+ \ ! s: Onescope (s: PrevNonBlankNonString (cur - 1 ))
467
458
return indent (s: GetMSL (cur, 0 ))
468
459
end
469
460
elseif counts = ~ ' 1' || s: Onescope (lnum)
0 commit comments