Allow lang without quotes and lang="typescript"

<script lang=ts> and <style lang=sass> without quotes weren't
recognized, so they used the first syntax in the config. For sass, it
also flattened the nesting when indenting. lang="typescript" wasn't
recognized either.

Languages not in the config still use the first syntax as before.
This commit is contained in:
leafOfTree committed 2026-10-21 12:13:24 +00:00
1 parent ee1a608c40
commit 063231ca9e
4 files changed
+42 -3

No files matched your search

+3 -2
View File
@@ -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