mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2025-12-08 21:54:46 +08:00
Improve multiple line tag syntax and custom tag indent
This commit is contained in:
@@ -86,8 +86,8 @@ function! s:GetIndentByContext(tag, syntax)
|
||||
let prevline = getline(s:PrevNonBlankNonComment(v:lnum))
|
||||
let curline = getline(v:lnum)
|
||||
|
||||
if a:tag == 'view'
|
||||
" Support 'view' tag from mini-program
|
||||
if a:tag != 'template' && a:syntax == 'html'
|
||||
" Set indent to 0 for custom tag with 'html' syntax
|
||||
if curline =~ s:block_tag && empty(prevline)
|
||||
let ind = 0
|
||||
endif
|
||||
@@ -99,7 +99,8 @@ function! s:GetIndentByContext(tag, syntax)
|
||||
endif
|
||||
endif
|
||||
else
|
||||
" When not in <template>, set block tags indent to 0
|
||||
" When not in <template> and not 'html'
|
||||
" Set indent to 0 if current or prev line is block tag
|
||||
if curline =~ s:block_tag || prevline =~ s:block_tag
|
||||
let ind = 0
|
||||
endif
|
||||
|
||||
@@ -110,16 +110,20 @@ function! s:SetSyntax(block, syntax, has_lang)
|
||||
let name = s:GetSynatxName(block, syntax)
|
||||
if has_lang
|
||||
let lang_name = s:GetSyntaxLangName(syntax)
|
||||
let lang = 'lang=["'']'.lang_name.'["''][^>]*'
|
||||
let lang = 'lang=["'']'.lang_name.'["'']'
|
||||
else
|
||||
let lang = ''
|
||||
endif
|
||||
|
||||
let start = '^<'.block.'[^>]*'.lang.'>'
|
||||
let start = '^<'.block.'[^>]*'.lang
|
||||
let end_tag = '</'.block.'>'
|
||||
let end = '^'.end_tag
|
||||
let syntax_group = s:GetGroupNameForHighlight(syntax)
|
||||
|
||||
" Block like
|
||||
" <script lang="ts">
|
||||
" ...
|
||||
" </script>
|
||||
execute 'syntax region '.name.' fold '
|
||||
\.' start=+'.start.'+'
|
||||
\.' end=+'.end.'+'
|
||||
@@ -128,7 +132,7 @@ function! s:SetSyntax(block, syntax, has_lang)
|
||||
execute 'syntax sync match vueSync groupthere '.name.' +'.start.'+'
|
||||
execute 'syntax sync match vueSync groupthere NONE +'.end.'+'
|
||||
|
||||
" Support block like <script src="...">...</script>
|
||||
" Block like <script src="...">...</script>
|
||||
let oneline = start.'.*'.end_tag
|
||||
execute 'syntax match '.name.' fold '
|
||||
\.' +'.oneline.'+'
|
||||
|
||||
Reference in New Issue
Block a user