I need Vim to ignore the .tmpl
file extension to enable syntax highlighting.
How can I rewrite this:
autocmd BufNewFile,BufRead *.lua.tmpl set filetype=lua
to be more general? I want to match the lua and use it in the filetype.
Something like this is what I want:
autocmd BufNewFile,BufRead *.\(.*\).tmpl set filetype=\1
I use Neovim and I am currently wrapping the above in vim.cmd()
. If this is somehow easier to do with vim.api.nvim_create_autocmd
, then this is fine, too.
One way would be to copy and paste for each file extension. Because I don't want to do that, I was going to make a chezmoi (dotfile manager) template that automatically finds all extensions that I need. I doubt that this will be good for performance, though. Also seems like a lot of work for something that sounds easy.
I tried to escape the pattern and somehow use \v
magic but I am unable to.
I wasn't able to find an example so I came here.