mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2025-12-08 21:54:46 +08:00
fix: indentation error inside html comments
This commit is contained in:
@@ -58,9 +58,6 @@ let b:javascript_indentexpr = &indentexpr
|
|||||||
unlet! b:did_indent
|
unlet! b:did_indent
|
||||||
runtime! indent/xml.vim
|
runtime! indent/xml.vim
|
||||||
|
|
||||||
unlet! b:did_indent
|
|
||||||
runtime! indent/html.vim
|
|
||||||
|
|
||||||
unlet! b:did_indent
|
unlet! b:did_indent
|
||||||
runtime! indent/css.vim
|
runtime! indent/css.vim
|
||||||
|
|
||||||
@@ -104,19 +101,14 @@ function! GetVueIndent()
|
|||||||
let cursyn = get(cursyns, 0)
|
let cursyn = get(cursyns, 0)
|
||||||
|
|
||||||
if s:SynPug(prevsyn)
|
if s:SynPug(prevsyn)
|
||||||
call LogMsg('syntax: pug')
|
call s:Log('syntax: pug')
|
||||||
let ind = GetPugIndent()
|
let ind = GetPugIndent()
|
||||||
elseif s:SynHTML(prevsyn)
|
elseif s:SynHTML(prevsyn)
|
||||||
|
call s:Log('syntax: xml')
|
||||||
|
let ind = XmlIndentGet(v:lnum, 0)
|
||||||
if prevline =~? s:empty_tag
|
if prevline =~? s:empty_tag
|
||||||
call LogMsg('syntax: html')
|
call s:Log('prev line is empty tag')
|
||||||
if exists("*HtmlIndentGet")
|
let ind = ind - &sw
|
||||||
let ind = HtmlIndentGet(v:lnum)
|
|
||||||
elseif exists("*HtmlIndent")
|
|
||||||
let ind = HtmlIndent()
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
call LogMsg('syntax: xml')
|
|
||||||
let ind = XmlIndentGet(v:lnum, 0)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Align '/>' and '>' with '<' for multiline tags.
|
" Align '/>' and '>' with '<' for multiline tags.
|
||||||
@@ -128,13 +120,13 @@ function! GetVueIndent()
|
|||||||
let ind = ind + &sw
|
let ind = ind + &sw
|
||||||
endif
|
endif
|
||||||
elseif s:SynSASS(prevsyn)
|
elseif s:SynSASS(prevsyn)
|
||||||
call LogMsg('syntax: sass')
|
call s:Log('syntax: sass')
|
||||||
let ind = GetSassIndent()
|
let ind = GetSassIndent()
|
||||||
elseif s:SynCSS(prevsyn)
|
elseif s:SynCSS(prevsyn)
|
||||||
call LogMsg('syntax: css')
|
call s:Log('syntax: css')
|
||||||
let ind = GetCSSIndent()
|
let ind = GetCSSIndent()
|
||||||
else
|
else
|
||||||
call LogMsg('syntax: javascript')
|
call s:Log('syntax: javascript')
|
||||||
if len(b:javascript_indentexpr)
|
if len(b:javascript_indentexpr)
|
||||||
let ind = eval(b:javascript_indentexpr)
|
let ind = eval(b:javascript_indentexpr)
|
||||||
else
|
else
|
||||||
@@ -144,19 +136,19 @@ function! GetVueIndent()
|
|||||||
|
|
||||||
if curline =~? s:vue_tag || curline =~? s:vue_end_tag
|
if curline =~? s:vue_tag || curline =~? s:vue_end_tag
|
||||||
\|| prevline =~? s:vue_end_tag
|
\|| prevline =~? s:vue_end_tag
|
||||||
call LogMsg('current line is vue tag or prev line is svelte end tag')
|
call s:Log('current line is vue tag or prev line is vue end tag')
|
||||||
let ind = 0
|
let ind = 0
|
||||||
elseif s:has_init_indent
|
elseif s:has_init_indent
|
||||||
if s:SynVueScope(cursyn) && ind == 0
|
if s:SynVueScope(cursyn) && ind == 0
|
||||||
call LogMsg('add initial indent')
|
call s:Log('add initial indent')
|
||||||
let ind = &sw
|
let ind = &sw
|
||||||
endif
|
endif
|
||||||
elseif prevline =~? s:vue_tag
|
elseif prevline =~? s:vue_tag
|
||||||
call LogMsg('prev line is vue tag')
|
call s:Log('prev line is vue tag')
|
||||||
let ind = 0
|
let ind = 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call LogMsg('indent: '.ind)
|
call s:Log('indent: '.ind)
|
||||||
return ind
|
return ind
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -204,7 +196,7 @@ function! GetVueTag()
|
|||||||
return tag
|
return tag
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! LogMsg(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
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user