mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2025-12-08 13:44:46 +08:00
Fix template in pug indent error
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
if exists('b:did_indent') | finish |endif
|
||||
|
||||
let s:test = exists('g:vim_vue_plugin_test')
|
||||
|
||||
function! s:Init()
|
||||
""" Configs
|
||||
let s:config = vue#GetConfig('config', {})
|
||||
@@ -76,13 +78,14 @@ function! s:GetBlockIndent(syntax)
|
||||
return ind
|
||||
endfunction
|
||||
|
||||
function! s:GetIndentByContext()
|
||||
function! s:GetIndentByContext(syntax)
|
||||
let ind = -1
|
||||
let prevline = getline(s:PrevNonBlankNonComment(v:lnum))
|
||||
let curline = getline(v:lnum)
|
||||
|
||||
" 0 for blocks except template as it can be nested
|
||||
if curline =~ s:block_tag && curline !~ s:template_tag
|
||||
if curline =~ s:block_tag &&
|
||||
\ (curline !~ s:template_tag || a:syntax == 'pug')
|
||||
let ind = 0
|
||||
endif
|
||||
endif
|
||||
@@ -188,9 +191,9 @@ function! s:AdjustHTMLIndent(ind)
|
||||
endfunction
|
||||
|
||||
function! GetVueIndent()
|
||||
let ind = s:GetIndentByContext()
|
||||
if ind == -1
|
||||
let syntax = vue#GetBlockSyntax(v:lnum)
|
||||
let ind = s:GetIndentByContext(syntax)
|
||||
if ind == -1
|
||||
let ind = s:GetBlockIndent(syntax)
|
||||
let ind = s:AdjustBlockIndent(syntax, ind)
|
||||
call vue#LogWithLnum('syntax '.syntax.', ind '.ind)
|
||||
@@ -210,7 +213,7 @@ function! VimVuePluginIndentMain(...)
|
||||
call s:SetVueIndent()
|
||||
endfunction
|
||||
|
||||
if exists('*timer_start')
|
||||
if exists('*timer_start') && !s:test
|
||||
call timer_start(50, 'VimVuePluginIndentMain')
|
||||
else
|
||||
call VimVuePluginIndentMain()
|
||||
|
||||
@@ -9,6 +9,8 @@ endif
|
||||
" <sfile> is replaced with the file name of the sourced file
|
||||
let s:patch_path = expand('<sfile>:p:h').'/patch'
|
||||
|
||||
let s:test = exists('g:vim_vue_plugin_test')
|
||||
|
||||
function! s:Init()
|
||||
""" Configs
|
||||
let s:config = vue#GetConfig('config', {})
|
||||
@@ -165,7 +167,7 @@ function! VimVuePluginSyntaxMain(...)
|
||||
call s:HighlightVueTag()
|
||||
endfunction
|
||||
|
||||
if exists('*timer_start')
|
||||
if exists('*timer_start') && !s:test
|
||||
call timer_start(1, 'VimVuePluginSyntaxMain')
|
||||
else
|
||||
call VimVuePluginSyntaxMain()
|
||||
|
||||
Reference in New Issue
Block a user