Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,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']`
Expand Down
5 changes: 3 additions & 2 deletions syntax/vue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 17 additions & 0 deletions test/cases/lang-attr.vim
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions test/cases/lang-attr.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template lang=html>
<div>x</div>
</template>

<script lang=ts>
let a: number = 1
</script>

<script lang="typescript">
let b: number = 2
</script>

<style lang='scss'>
$c: 1px;
</style>

<style lang=sass>
p
color: red
</style>
Loading