diff --git a/indent/vue.vim b/indent/vue.vim index 997872b..6cf5a81 100644 --- a/indent/vue.vim +++ b/indent/vue.vim @@ -26,13 +26,17 @@ let b:vue_js_indentexpr = &indentexpr unlet! b:did_indent runtime! indent/xml.vim +" load css indent method +unlet! b:did_indent +runtime! indent/css.vim + " load pug indent method unlet! b:did_indent runtime! indent/pug.vim -" load css indent method +" load sass indent method unlet! b:did_indent -runtime! indent/css.vim +runtime! indent/sass.vim let b:did_indent = 1 let b:did_vue_indent = 1 @@ -65,6 +69,11 @@ function! SynsCSS(syns) return first_syn =~? '\v^(vueStyle)' endfunction +function! SynsSASS(syns) + let first_syn = get(a:syns, 0) + return first_syn =~? '\v^(vueStyleSASS)' +endfunction + function! SynsVueScope(syns) let first_syn = get(a:syns, 0) return first_syn =~? '\v^(vueStyle)|(vueScript)' @@ -96,6 +105,9 @@ function! GetVueIndent() elseif SynsCSS(prevsyns) call s:LogMsg('syntax: css') let ind = GetCSSIndent() + elseif SynsSASS(prevsyns) + call s:LogMsg('syntax: sass') + let ind = GetSassIndent() else call s:LogMsg('syntax: javascript') if len(b:vue_js_indentexpr) @@ -109,12 +121,12 @@ function! GetVueIndent() call s:LogMsg('current is vue tag') let ind = 0 elseif (exists("g:vim_vue_plugin_has_init_indent") - \ && g:vim_vue_plugin_has_init_indent != 0) + \ && g:vim_vue_plugin_has_init_indent == 1) if SynsVueScope(cursyns) && ind == 0 call s:LogMsg('add initial indent') let ind = &sw endif - elseif prevline =~? s:vue_end_tag + elseif prevline =~? s:vue_tag || prevline =~? s:vue_end_tag call s:LogMsg('prev is vue tag') let ind = 0 endif diff --git a/syntax/vue.vim b/syntax/vue.vim index 08db989..e2c1322 100644 --- a/syntax/vue.vim +++ b/syntax/vue.vim @@ -7,6 +7,10 @@ " CREDITS: Inspired by mxw/vim-jsx. " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +if exists("b:current_syntax") && b:current_syntax == 'vue' + finish +endif + function! s:LoadDefaultSyntax(group, type) unlet! b:current_syntax exec 'syn include '.a:group.' $VIMRUNTIME/syntax/'.a:type.'.vim' @@ -45,19 +49,27 @@ if exists("g:vim_vue_plugin_use_pug") call s:LoadFullSyntax('@PugSyntax', 'pug') endif -" If less is enabled, load vim-pug syntax +" If less is enabled, load less syntax if exists("g:vim_vue_plugin_use_less") \ && g:vim_vue_plugin_use_less == 1 call s:LoadFullSyntax('@LessSyntax', 'less') syn clear cssDefinition - syn region lessDefinition - \ matchgroup=cssBraces - \ contains=@LessSyntax + syn region lessDefinition matchgroup=cssBraces contains=@LessSyntax \ start="{" \ end="}" endif +" If sass is enabled, load sass syntax +if exists("g:vim_vue_plugin_use_sass") + \ && g:vim_vue_plugin_use_sass == 1 + call s:LoadFullSyntax('@SassSyntax', 'sass') + syn clear cssDefinition + syn region sassDefinition matchgroup=cssBraces contains=@SassSyntax + \ start="{" + \ end="}" +endif + let b:current_syntax = 'vue' " Find tag