From 9be92aa2563698b55a9e58151de76f21a1463f2b Mon Sep 17 00:00:00 2001 From: leafOfTree Date: Wed, 12 Aug 2020 15:13:38 +0800 Subject: [PATCH] Highlight keywords with required indent --- indent/vue.vim | 12 ++---------- syntax/vue-javascript.vim | 8 +++++++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/indent/vue.vim b/indent/vue.vim index 3aabbc5..8ac5b20 100644 --- a/indent/vue.vim +++ b/indent/vue.vim @@ -40,16 +40,8 @@ let s:use_scss = vue#GetConfig("use_scss", 0) let s:use_stylus = vue#GetConfig("use_stylus", 0) let s:use_coffee = vue#GetConfig("use_coffee", 0) let s:use_typescript = vue#GetConfig("use_typescript", 0) - -let s:has_init_indent = 0 -if !exists("g:vim_vue_plugin_has_init_indent") - let ext = expand("%:e") - if ext == 'wpy' - let s:has_init_indent = 1 - endif -elseif g:vim_vue_plugin_has_init_indent == 1 - let s:has_init_indent = 1 -endif +let s:has_init_indent = vue#GetConfig("has_init_indent", + \ expand("%:e") == 'wpy' ? 1 : 0) "}}} """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/syntax/vue-javascript.vim b/syntax/vue-javascript.vim index 245514e..89bbe07 100644 --- a/syntax/vue-javascript.vim +++ b/syntax/vue-javascript.vim @@ -6,6 +6,9 @@ let s:highlight_vue_keyword = vue#GetConfig("highlight_vue_keyword", 0) if !s:highlight_vue_keyword | finish | endif + +let s:has_init_indent = vue#GetConfig("has_init_indent", + \ expand("%:e") == 'wpy' ? 1 : 0) "}}} """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -15,7 +18,10 @@ if !s:highlight_vue_keyword | finish | endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let s:vue_keywords = 'name parent functional delimiters comments components directives filters extends mixins inheritAttrs model props propsData data computed watch methods template render renderError inject provide beforeCreate created beforeMount mounted beforeUpdate updated activated deactivated beforeDestroy destroyed' -let s:vue_keywords_regexp = '\v<('.join(split(s:vue_keywords, ' '), '|').')\ze' +let s:indent = &sw * (1 + s:has_init_indent) +let s:vue_keywords_regexp = '\v^\s{'.s:indent.'}<(' + \.join(split(s:vue_keywords, ' '), '|') + \.')\ze' execute 'syntax match vueObjectKey /'.s:vue_keywords_regexp.'\s*:/' \.' containedin=jsObject,javascriptVueScript' \.' skipwhite skipempty nextgroup=jsObjectValue'