diff --git a/README.md b/README.md index 47f6f47..8cd49e8 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,8 @@ let g:vim_vue_plugin_config.foldexpr = 0 Note -- `typescript` matches `lang="ts"` +- `typescript` matches `lang="ts"` and `lang="typescript"` +- `lang` can be in double or single quotes, or without quotes - `list` options can be `string` if only one - The first item of syntax list will be used if no "lang=..." - For `.wpy`, `initial_indent` defaults to `['script', 'style']` diff --git a/syntax/vue.vim b/syntax/vue.vim index 9924565..1512dbe 100644 --- a/syntax/vue.vim +++ b/syntax/vue.vim @@ -92,7 +92,7 @@ endfunction function! s:GetSyntaxLangName(syntax) let syntax = a:syntax if syntax == 'typescript' - let syntax = 'ts' + let syntax = '\(ts\|typescript\)' endif return syntax endfunction @@ -105,7 +105,8 @@ 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.'["'']' + " In double or single quotes, or without quotes + let lang = 'lang=["'']\?'.lang_name.'\>["'']\?' else let lang = '' endif diff --git a/test/cases/lang-attr.vim b/test/cases/lang-attr.vim new file mode 100644 index 0000000..ad3e008 --- /dev/null +++ b/test/cases/lang-attr.vim @@ -0,0 +1,17 @@ +" lang in double or single quotes or without quotes, and +" lang="typescript" +let g:vim_vue_plugin_config = { + \'syntax': { + \ 'template': ['html'], + \ 'script': ['javascript', 'typescript'], + \ 'style': ['css', 'scss', 'sass'], + \}, + \} + +function! Check() + call ExpectEqual(GetVueSyntax(), 'html', 'syntax at line 1') + call ExpectBlock('let a', 'script', 'typescript', 'typescriptScriptBlock') + call ExpectBlock('let b', 'script', 'typescript', 'typescriptScriptBlock') + call ExpectBlock('$c', 'style', 'scss', 'cssScssStyleBlock') + call ExpectBlock('color: red', 'style', 'sass', 'sassStyleBlock') +endfunction diff --git a/test/cases/lang-attr.vue b/test/cases/lang-attr.vue new file mode 100644 index 0000000..88abba8 --- /dev/null +++ b/test/cases/lang-attr.vue @@ -0,0 +1,20 @@ + + + + + + + + +