From 84fe692afe220595998d62cc012ff6788ef06093 Mon Sep 17 00:00:00 2001 From: leafOfTree Date: Wed, 21 Oct 2026 13:52:18 +0000 Subject: [PATCH 1/2] Merge syntax config per block syntax in g:vim_vue_plugin_config replaced the whole default, so {'syntax': {'script': ['javascript', 'typescript']}} removed template and style, which then had no highlight or indent. Replace the default of each key separately, like vim-svelte-plugin. A block can be removed by setting it to []. --- README.md | 1 + autoload/vue.vim | 8 +++++++- test/cases/no-css.vim | 7 +++++-- test/cases/syntax-merge.vim | 10 ++++++++++ test/cases/syntax-merge.vue | 13 +++++++++++++ 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 test/cases/syntax-merge.vim create mode 100644 test/cases/syntax-merge.vue diff --git a/README.md b/README.md index 8cd49e8..78f481c 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ It has the following options - `lang="..."` on block tag decides the effective syntax - When no valid `lang="..."` is present, the first syntax in the list will be used. - By default, only syntax files from `['$VIMRUNTIME', '$VIM/vimfiles', '$HOME/.vim']` are loaded. If none is found, then **full** syntax files, including those from plugins, will be loaded + - Each key replaces the default of the same key, so `{'syntax': {'script': ['javascript', 'typescript']}}` keeps `template` as `['html']` and `style` as `['css']`. Set a key to `[]` to remove the block - **full_syntax**: *string list*. Syntax whose **full** syntax files will always be loaded - **initial_indent**: *string list*. Tag/syntax with initial one tab indent. The format can be `tag.syntax`, `tag`, or `syntax` diff --git a/autoload/vue.vim b/autoload/vue.vim index 0f08ba6..017cc65 100644 --- a/autoload/vue.vim +++ b/autoload/vue.vim @@ -28,10 +28,16 @@ function! s:MergeUserConfigIntoDefault(user) \'debug': 0, \} + " Each key of syntax replaces the default of the same key, so blocks not in + " user config keep their default syntax let user = a:user for key in keys(default) if has_key(user, key) - let default[key] = user[key] + if key ==# 'syntax' && type(user[key]) == v:t_dict + call extend(default[key], user[key]) + else + let default[key] = user[key] + endif endif endfor diff --git a/test/cases/no-css.vim b/test/cases/no-css.vim index 394b439..7889f02 100644 --- a/test/cases/no-css.vim +++ b/test/cases/no-css.vim @@ -1,5 +1,8 @@ -" Without css syntax, like only script in config -let g:vim_vue_plugin_config = {'syntax': {'script': ['javascript']}} +" Without css syntax, like only script in config, removing template and style +" by [] +let g:vim_vue_plugin_config = { + \'syntax': {'script': ['javascript'], 'template': [], 'style': []}, + \} let g:test_flatten = 1 function! Check() diff --git a/test/cases/syntax-merge.vim b/test/cases/syntax-merge.vim new file mode 100644 index 0000000..caee50c --- /dev/null +++ b/test/cases/syntax-merge.vim @@ -0,0 +1,10 @@ +" Each key of syntax replaces the default of the same key, so template and +" style keep html and css +let g:vim_vue_plugin_config = {'syntax': {'script': ['javascript', 'typescript']}} +let g:test_flatten = 1 + +function! Check() + call ExpectBlock('
', 'template', 'html', 'htmlTemplateBlock') + call ExpectBlock('let count', 'script', 'typescript', 'typescriptScriptBlock') + call ExpectBlock('color: red', 'style', 'css', 'cssStyleBlock') +endfunction diff --git a/test/cases/syntax-merge.vue b/test/cases/syntax-merge.vue new file mode 100644 index 0000000..ec6928a --- /dev/null +++ b/test/cases/syntax-merge.vue @@ -0,0 +1,13 @@ + + + + + From 7a2f8ac5cdf608a29bb224256ee5a713e024a3c0 Mon Sep 17 00:00:00 2001 From: leafOfTree Date: Wed, 21 Oct 2026 13:52:54 +0000 Subject: [PATCH 2/2] Add help doc Add doc/vim-vue-plugin.txt for :help with the configuration and functions in README. --- .gitignore | 1 + README.md | 2 + doc/vim-vue-plugin.txt | 166 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 169 insertions(+) create mode 100644 doc/vim-vue-plugin.txt diff --git a/.gitignore b/.gitignore index 4d4d57c..7c02170 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ README.html test.vue .DS_STORE test/deps/ +doc/tags diff --git a/README.md b/README.md index 78f481c..4a77d49 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Vim syntax and indent plugin for `.vue` files. Mainly inspired by [mxw/vim-jsx][ You could install it just like other plugins. The filetype will be set to `vue`. Feel free to open an issue or a pull request if any questions +See `:help vim-vue-plugin` for the documentation in Vim. +
How to install diff --git a/doc/vim-vue-plugin.txt b/doc/vim-vue-plugin.txt new file mode 100644 index 0000000..e85f85a --- /dev/null +++ b/doc/vim-vue-plugin.txt @@ -0,0 +1,166 @@ +*vim-vue-plugin.txt* Syntax and indent for Vue files + +Author: leafOfTree +License: The Unlicense + +============================================================================== +CONTENTS *vim-vue-plugin-contents* + + 1. Introduction ............................... |vim-vue-plugin-intro| + 2. Configuration .............................. |vim-vue-plugin-config| + 3. Functions .................................. |vim-vue-plugin-functions| + 4. Avoid overload ............................. |vim-vue-plugin-overload| + +============================================================================== +1. Introduction *vim-vue-plugin-intro* + +Vim syntax and indent plugin for `.vue` files, also `.wpy` files. It loads +multiple syntax and indent files for `.vue` and enables them to work +together, with + +- Blocks, both