Skip to content

Commit fcc8129

Browse files
committed
Fix indentation on typing tag start '<' at new line
1 parent 2de4e9f commit fcc8129

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

indent/svelte.vim

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ let s:empty_tagname = '(area|base|br|col|embed|hr|input|img|keygen|link|meta|par
2626
let s:empty_tag = '\v\C\<'.s:empty_tagname.'[^/]*\>'
2727
let s:empty_tag_start = '\v\<'.s:empty_tagname.'[^\>]*$'
2828
let s:empty_tag_end = '\v^\s*[^\<\>\/]*\>\s*'
29+
let s:tag_start = '^<$'
2930
let s:tag_end = '\v^\s*\/?\>\s*'
3031
let s:oneline_block = '^\s*{#.*{/.*}\s*$'
3132
"}}}
@@ -170,6 +171,9 @@ function! GetSvelteIndent()
170171
elseif s:SynStyle(cursyn)
171172
call s:Log('syntax: style')
172173
let ind = GetCSSIndent()
174+
elseif s:IsTagStart(curline)
175+
call s:Log('syntax: tagstart')
176+
let ind = 0
173177
else
174178
call s:Log('syntax: javascript')
175179
if len(b:javascript_indentexpr)
@@ -199,6 +203,10 @@ function! GetSvelteIndent()
199203
return ind
200204
endfunction
201205

206+
function! s:IsTagStart(curline)
207+
return a:curline =~ s:tag_start
208+
endfunction
209+
202210
function! s:IsBlockStart(prevsyns)
203211
let prevsyn_second = get(a:prevsyns, 1, '')
204212
" Some HTML tags add an extra syntax layer

0 commit comments

Comments
 (0)