Skip to content

Commit 04e412b

Browse files
committed
removing some clutter (#434)
also added a modeline to fold away the gq code
1 parent 3ebaef3 commit 04e412b

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

indent/javascript.vim

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ let s:expr_case = '^\s*\(case\s\+[^\:]*\|default\)\s*:\s*'
4646
" Regex of syntax group names that are or delimit string or are comments.
4747
let s:syng_strcom = '\%(string\|regex\|comment\|template\)\c'
4848

49-
" Regex of syntax group names that are or delimit template strings
50-
let s:syng_template = 'template\c'
51-
5249
" Regex of syntax group names that are strings.
5350
let s:syng_string = 'regex\c'
5451

@@ -106,11 +103,6 @@ function s:IsInString(lnum, col)
106103
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string
107104
endfunction
108105

109-
" Check if the character at lnum:col is inside a template string.
110-
function s:IsInTempl(lnum, col)
111-
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_template
112-
endfunction
113-
114106
" Check if the character at lnum:col is inside a multi-line comment.
115107
function s:IsInMultilineComment(lnum, col)
116108
return !s:IsLineComment(a:lnum, a:col) && synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_multiline
@@ -137,7 +129,7 @@ function s:PrevNonBlankNonString(lnum)
137129
endif
138130
elseif !in_block && s:IsInMultilineComment(lnum, matchend(line, '\*/') - 1)
139131
let in_block = 1
140-
elseif !in_block && line !~ '^\s*\%(//\).*$' && !(s:IsInStringOrComment(lnum, 1) && !s:IsInTempl(lnum,1) && s:IsInStringOrComment(lnum, strlen(line)))
132+
elseif !in_block && line !~ '^\s*\%(//\).*$' && !(s:IsInStringOrComment(lnum, 1) && s:IsInStringOrComment(lnum, strlen(line)))
141133
break
142134
endif
143135
let lnum = prevnonblank(lnum - 1)
@@ -329,12 +321,12 @@ endfunction
329321
" =========================
330322

331323
function GetJavascriptIndent()
332-
" 3.1. Setup {{{2
324+
" 3.1. Setup {{{1
333325
" ----------
334326
" Set up variables for restoring position in file. Could use v:lnum here.
335327
let vcol = col('.')
336328

337-
" 3.2. Work on the current line {{{2
329+
" 3.2. Work on the current line {{{1
338330
" -----------------------------
339331

340332
let ind = -1
@@ -344,7 +336,7 @@ function GetJavascriptIndent()
344336
let prevline = prevnonblank(v:lnum - 1)
345337

346338
" to not change multiline string values
347-
if (synIDattr(synID(v:lnum, 1, 1), 'name') =~? 'string' || s:IsInTempl(v:lnum, 1)) && line !~ '^\s*[''"`]'
339+
if synIDattr(synID(v:lnum, 1, 1), 'name') =~? 'string\|template' && line !~ '^\s*[''"`]'
348340
return indent(v:lnum)
349341
endif
350342

@@ -453,21 +445,13 @@ function GetJavascriptIndent()
453445
end
454446
end
455447

456-
" if getline(prevline) =~ '^\s*`$' && s:IsInTempl(v:lnum, 1)
457-
" if line !~ '^\s*`$'
458-
" return indent(prevline) + s:sw()
459-
" endif
460-
" elseif line =~ '^\s*`$' && s:IsInTempl(prevline, 1)
461-
" return indent(prevline) - s:sw()
462-
" endif
463-
464448
" Check for multiple var assignments
465449
" let var_indent = s:GetVarIndent(v:lnum)
466450
" if var_indent >= 0
467451
" return var_indent
468452
" endif
469453

470-
" 3.3. Work on the previous line. {{{2
454+
" 3.3. Work on the previous line. {{{1
471455
" -------------------------------
472456

473457
" If the line is empty and the previous nonblank line was a multi-line
@@ -523,7 +507,7 @@ function GetJavascriptIndent()
523507
end
524508
end
525509

526-
" 3.4. Work on the MSL line. {{{2
510+
" 3.4. Work on the MSL line. {{{1
527511
" --------------------------
528512

529513
let ind_con = ind
@@ -550,7 +534,7 @@ endfunction
550534

551535
let &cpo = s:cpo_save
552536
unlet s:cpo_save
553-
537+
" gq{{{2
554538
function! Fixedgq(lnum, count)
555539
let l:tw = &tw ? &tw : 80;
556540

@@ -611,3 +595,5 @@ function! Fixedgq(lnum, count)
611595

612596
return 0
613597
endfunction
598+
"}}}
599+
" vim: foldmethod=marker:foldlevel=1

0 commit comments

Comments
 (0)