Skip to content

Commit f621002

Browse files
author
Mathieu Quinette
committed
Do not treat line comments with cindent.
1 parent 4ff3b73 commit f621002

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

indent/javascript.vim

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ let s:syng_string = 'regex\c'
4141
" Regex of syntax group names that are strings or documentation.
4242
let s:syng_multiline = 'comment\c'
4343

44+
" Regex of syntax group names that are line comment.
45+
let s:syng_linecom = 'linecomment'
46+
4447
" Expression used to check whether we should skip a match with searchpair().
4548
let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'"
4649

@@ -76,6 +79,11 @@ function s:IsInMultilineComment(lnum, col)
7679
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_multiline
7780
endfunction
7881

82+
" Check if the character at lnum:col is a line comment.
83+
function s:IsLineComment(lnum, col)
84+
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_linecom
85+
endfunction
86+
7987
" Find line above 'lnum' that isn't empty, in a comment, or in a string.
8088
function s:PrevNonBlankNonString(lnum)
8189
let in_block = 0
@@ -244,7 +252,7 @@ function GetJavascriptIndent()
244252
endif
245253

246254
" If we are in a multi-line comment, cindent does the right thing.
247-
if s:IsInMultilineComment(v:lnum, 1)
255+
if s:IsInMultilineComment(v:lnum, 1) && !s:IsLineComment(v:lnum, 1)
248256
return cindent(v:lnum)
249257
endif
250258

0 commit comments

Comments
 (0)