Combining jinja2 and salt syntax highlighting in NeoVim

Viewed 592

I would like to ask if there is a way to properly combine these two syntaxes, and usually, in salt, the jinja is templating it. And the problem is that (Neo)Vim will show one or another highlighting, not both at once. I kind of solved it by using SyntaxRange, but that is not working anymore on NeoVim for some reason - it is doing nothing, not even error message.

Does somebody know how to deal with this, please?

Thank you!

2 Answers

So I have found the solution for my problem. So I am posting this here, if there is somebody with the similar problem. You can chain syntaxes after each other in vim using dot:

augroup salt_syn
  au BufNewFile,BufRead *.sls set filetype=sls.yaml
augroup END

For some reason, this combination is highlighting jinja2 parts too, along with yaml, and other salt parts. When I set just sls, it was not recognizing keywords inside {% %}. When I had it the other way around (yaml.sls) it wasn't working either.

Cheers

You probably want the salt-vim plugin, and possibly also vim-yaml (optional, for speed). It will properly highlight both the jinja and yaml parts of an sls file.

Related