Skip to content

Commit ad8d72a

Browse files
authored
cleaning indent
1 parent bf7d4b6 commit ad8d72a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

indent/javascript.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ let s:syng_strcom = '\%(string\|regex\|special\|doc\|comment\|template\)\c'
4444
let s:syng_comment = '\%(comment\|doc\)\c'
4545

4646
" Expression used to check whether we should skip a match with searchpair().
47-
let s:skip_expr = "s:IsInStringOrComment(line('.'),col('.'))"
47+
let s:skip_expr = "s:IsSyn(line('.'),col('.'),0)"
4848

4949
func s:lookForParens(start,end,flags,time)
5050
try
@@ -83,15 +83,15 @@ endfunction
8383
" ======================
8484

8585
" Check if the character at lnum:col is inside a string, comment, or is ascii.
86-
function s:IsInStringOrComment(lnum, col)
87-
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_strcom
86+
function s:IsSyn(lnum, col, reg)
87+
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~? (a:reg ? a:reg : s:syng_strcom)
8888
endfunction
8989

9090
" Find line above 'lnum' that isn't empty, in a comment, or in a string.
9191
function s:PrevNonBlankNonString(lnum)
9292
let lnum = prevnonblank(a:lnum)
9393
while lnum > 0
94-
if !s:IsInStringOrComment(lnum, matchend(getline(lnum), '^\s*[^''"]'))
94+
if !s:IsSyn(lnum, matchend(getline(lnum), '^\s*[^''"]'),0)
9595
break
9696
endif
9797
let lnum = prevnonblank(lnum - 1)
@@ -108,7 +108,7 @@ function s:LineHasOpeningBrackets(lnum)
108108
let pos = match(line, '[][(){}]', 0)
109109
let last = 0
110110
while pos != -1
111-
if !s:IsInStringOrComment(a:lnum, pos + 1)
111+
if !s:IsSyn(a:lnum, pos + 1, 0)
112112
let idx = stridx('(){}[]', line[pos])
113113
if idx % 2 == 0
114114
let open_{idx} = open_{idx} + 1
@@ -141,8 +141,8 @@ function GetJavascriptIndent()
141141
endif
142142

143143
" start with strings,comments,etc.{{{2
144-
if (line !~ '^[''"`]' && synIDattr(synID(v:lnum, 1, 1), 'name') =~? 'string\|template') ||
145-
\ (line !~ '^\s*[/*]' && synIDattr(synID(v:lnum, 1, 1), 'name') =~? s:syng_comment)
144+
if (line !~ '^[''"`]' && s:IsSyn(v:lnum,1,'string\|template')) ||
145+
\ (line !~ '^\s*[/*]' && s:IsSyn(v:lnum,1,s:syng_comment))
146146
return -1
147147
endif
148148
if line !~ '^\%(\/\*\|\s*\/\/\)' && synIDattr(synID(v:lnum, 1, 1), 'name') =~? s:syng_comment)

0 commit comments

Comments
 (0)