0

I am having trouble fixing a syntax plugin for Vim. I've found a bug in a plugin that has not been touched in a fair amount of time. I want to address it myself but I believe I am lacking in a lot of knowledge surrounding the built in syntax rules in vim/neovim. The plugin's job is to syntax highlight a javascript tagged template literal with another filetype syntax. What I want to fix is the plugin's behavior inside a Typescript file.

Essentially there is a piece of syntax that works in Javascript but not in Typescript. Ive used the great plugin SyntaxAttr.vim to see if any other syntaxes override the region in question, but the tagged template literal (the sql word) has no syntax group attached to it.

The syntax in a Javascript file:

screenshot(207)

and the borked syntax in a identical Typescript file:

screenshot(206)

I've tried messing with the syntax region command (which essentially boils down to):

syntax region taggedTemplateStringSQL matchgroup=taggedTemplateTicks start=+sql`+ skip="\(\\`\|\${[^}]*`\|\(\<\K\k*\ze`[^`]*\)\)" end=+`+ keepend contains=@taggedTemplateContentSQL containedin=@jsExpression extend

but I've had no luck. There's just something different about the Typescript file syntax that I don't see.

here is the init.vim file I am using to debug:

call plug#begin('~/.config/nvim/plugged')
Plug 'cdata/vim-tagged-template'
Plug 'vim-scripts/SyntaxAttr.vim'
call plug#end()

let g:taggedtemplate#tagSyntaxMap = {
  \ "sql": "sql" }

autocmd FileType javascript,typescript : call taggedtemplate#applySyntaxMap()

running neovim:

NVIM v0.4.2
Build type: Release
LuaJIT 2.0.5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.