@@ -17,7 +17,7 @@ setlocal nosmartindent
17
17
setlocal indentexpr = GetJavascriptIndent ()
18
18
setlocal formatexpr = Fixedgq (v: lnum ,v: count )
19
19
setlocal indentkeys = 0 {,0 },0 ),0 ],0 \, :,! ^F,o ,O,e
20
-
20
+ setl cino += b0
21
21
" Only define the function once.
22
22
if exists (" *GetJavascriptIndent" )
23
23
finish
41
41
" ============
42
42
43
43
let s: js_keywords = ' ^\s*\(break\|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\)'
44
- let s: expr_case = ' ^\s*\(case\s\+[^\:]*\|default\)\s*:\s*'
44
+ let s: expr_case = ' ^\s*\(case\s\+[^\:]*\|default\)\s*:\s*\|^\s*break\> '
45
45
" Regex of syntax group names that are or delimit string or are comments.
46
46
let s: syng_strcom = ' \%(\%(template\)\@<!string\|regex\|comment\)\c'
47
47
@@ -81,18 +81,8 @@ let s:var_stmt = '^\s*\%(const\|let\|var\)'
81
81
let s: comma_first = ' ^\s*,'
82
82
let s: comma_last = ' ,\s*$'
83
83
84
- let s: case_indent = s: sw ()
85
- let s: case_indent_after = s: sw ()
86
- let s: m = matchlist (&cinoptions , ' :\(.\)' )
87
- if (len (s: m ) > 2 )
88
- let s: case_indent = s: m [1 ]
89
- endif
90
- let s: m = matchlist (&cinoptions , ' =\(.\)' )
91
- if (len (s: m ) > 2 )
92
- let s: case_indent_after = s: m [1 ]
93
- endif
94
- " 2. Auxiliary Functions {{{1
95
- " ======================
84
+ " " 2. Auxiliary Functions {{{1
85
+ " " ======================
96
86
97
87
" Check if the character at lnum:col is inside a string, comment, or is ascii.
98
88
function s: IsInStringOrComment (lnum, col )
@@ -342,12 +332,10 @@ function GetJavascriptIndent()
342
332
343
333
if (line = ~ s: expr_case )
344
334
if (getline (prevline) = ~ s: expr_case )
345
- return indent (prevline )
335
+ return cindent ( line )
346
336
else
347
- if (getline (prevline) = ~ s: block_regex )
348
- return indent (prevline) + s: case_indent
349
- else
350
- return indent (prevline) - s: case_indent_after
337
+ if (getline (prevline) !~ s: block_regex )
338
+ return cindent (line )
351
339
endif
352
340
endif
353
341
endif
@@ -394,7 +382,7 @@ function GetJavascriptIndent()
394
382
return indent (prevline) - s: sw ()
395
383
endif
396
384
if (getline (prevline) = ~ s: expr_case )
397
- return indent (prevline) + s: case_indent_after
385
+ return cindent ( line )
398
386
endif
399
387
400
388
" If line starts with an operator...
@@ -475,11 +463,7 @@ function GetJavascriptIndent()
475
463
476
464
" If the previous line ended with a block opening, add a level of indent.
477
465
if s: Match (lnum, s: block_regex )
478
- if (line = ~ s: expr_case )
479
- return indent (s: GetMSL (lnum, 0 )) + s: sw ()/2
480
- else
481
466
return indent (s: GetMSL (lnum, 0 )) + s: sw ()
482
- endif
483
467
endif
484
468
485
469
" Set up variables for current line.
0 commit comments