Quramy / vim-js-pretty-template

highlights JavaScript's Template Strings in other FileType syntax rule
http://www.vim.org/scripts/script.php?script_id=5222
MIT License
142 stars 11 forks source link

Does not work with yajs.vim and vim-jsx #15

Open heralden opened 6 years ago

heralden commented 6 years ago

First of all, thanks for creating this plugin. This is definitely a feature we need in vim!

Sadly this plugin doesn't seem to work when used together with yajs.vim and vim-jsx. As soon as the filetype is changed to javascript.jsx, JsPreTmpl will be unable to change the syntax highlighting of the template strings. The syntax for template strings will be left at the yajs.vim default of javascriptTemplate.

However, if you set autocmd FileType javascript.jsx syn clear javascriptTemplate JsPreTmpl will work, although you will lose the ability to highlight the template strings properly. (I am also unable to get call jspretmpl#register_tag('styled', 'scss') to work with this)

Any ideas how this can be resolved?

sheldonkwok commented 5 years ago

They seem to work when they aren't assigned to a variable.

// This works
sql`select * from users;`

// This doesn't
const str = sql`select * from users;`
moll commented 5 years ago

I wonder if we're both seeing the same root problem. I'm seeing this with Pangloss's JavaScript syntax too — https://github.com/Quramy/vim-js-pretty-template/issues/19.

jgonera commented 4 years ago

Same issue with https://github.com/HerringtonDarkholme/yats.vim bundled by https://github.com/sheerun/vim-polyglot.

I tried adding SQL tagged template highlighting with:

call jspretmpl#register_tag('sql', 'sql')

autocmd FileType javascript JsPreTmpl
autocmd FileType javascript.jsx JsPreTmpl
autocmd FileType typescript JsPreTmpl
autocmd FileType typescript syn clear foldBraces

It works for JavaScript, but not for TypeScript. It works for TypeScript if I use https://github.com/leafgarland/typescript-vim though. I tried removing autocmd FileType typescript syn clear foldBraces and adding autocmd FileType typescriptreact JsPreTmpl to no avail.

As pointed out by @sheldonkwok it does work when it's not assigned to a variable.