mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2026-11-01 18:12:19 +08:00
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 [].
This commit is contained in:
5 files changed
+36
-3
No files matched your search
@@ -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`
|
||||
|
||||
|
||||
+7
-1
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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('<div>', 'template', 'html', 'htmlTemplateBlock')
|
||||
call ExpectBlock('let count', 'script', 'typescript', 'typescriptScriptBlock')
|
||||
call ExpectBlock('color: red', 'style', 'css', 'cssStyleBlock')
|
||||
endfunction
|
||||
@@ -0,0 +1,13 @@
|
||||
<template>
|
||||
<div>{{ count }}</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
let count: number = 0
|
||||
</script>
|
||||
|
||||
<style>
|
||||
p {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user