mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2025-12-09 22:25:12 +08:00
fix: indentation error that is caused by comments following <script>
This commit is contained in:
@@ -153,10 +153,14 @@ function! GetVueIndent()
|
|||||||
call s:Log('add initial indent')
|
call s:Log('add initial indent')
|
||||||
let ind = &sw
|
let ind = &sw
|
||||||
endif
|
endif
|
||||||
elseif prevline =~? s:vue_tag_start
|
else
|
||||||
|
let prevlnum_noncomment = s:PrevNonBlacnkNonComment(v:lnum)
|
||||||
|
let prevline_noncomment = getline(prevlnum_noncomment)
|
||||||
|
if prevline_noncomment =~? s:vue_tag_start
|
||||||
call s:Log('prev line is vue tag')
|
call s:Log('prev line is vue tag')
|
||||||
let ind = 0
|
let ind = 0
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
call s:Log('indent: '.ind)
|
call s:Log('indent: '.ind)
|
||||||
return ind
|
return ind
|
||||||
@@ -204,6 +208,27 @@ function! s:PrevMultilineEmptyTag(lnum)
|
|||||||
endwhile
|
endwhile
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:PrevNonBlacnkNonComment(lnum)
|
||||||
|
let curline = getline(lnum)
|
||||||
|
let cursyns = s:SynsEOL(a:lnum)
|
||||||
|
let cursyn = get(cursyns, 1, '')
|
||||||
|
if cursyn =~? 'comment' && !empty(curline)
|
||||||
|
return prevnonblank(a:lnum - 1)
|
||||||
|
endif
|
||||||
|
|
||||||
|
let lnum = a:lnum - 1
|
||||||
|
let prevlnum = prevnonblank(lnum)
|
||||||
|
let prevsyns = s:SynsEOL(prevlnum)
|
||||||
|
let prevsyn = get(prevsyns, 1, '')
|
||||||
|
while prevsyn =~? 'comment' && lnum > 1
|
||||||
|
let lnum = lnum - 1
|
||||||
|
let prevlnum = prevnonblank(lnum)
|
||||||
|
let prevsyns = s:SynsEOL(prevlnum)
|
||||||
|
let prevsyn = get(prevsyns, 1, '')
|
||||||
|
endwhile
|
||||||
|
return prevlnum
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:Log(msg)
|
function! s:Log(msg)
|
||||||
if s:debug
|
if s:debug
|
||||||
echom '['.s:name.']['.v:lnum.'] '.a:msg
|
echom '['.s:name.']['.v:lnum.'] '.a:msg
|
||||||
|
|||||||
Reference in New Issue
Block a user