Open tvdab opened 2 years ago
open an issue or pr for nvim-treesitter with this injection query
open an issue or pr for nvim-treesitter with this injection query
I would prefer to see a more general solution where injected languages get detected automatically. Not sure how that should/could work though.
I found it difficult to make syntax highlighting and snippet completion work for pieces of code that are written in a different language than the language of the file they are embedded in. I found a hacky solution to cover my situation, but I would like to see a better and more easy way to achieve this.
By default a snippet of html-code inside a javascript file looks like this:
So by default there is no syntax highlighting nor html-snippets available in this case.
These are the steps needed to make syntax highlighting and html-snippets work for this case:
I added this query inside ~/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/ecma/injections.scm which probably isn't the best idea. This will probably be deleted when doing a packer clean update?
Now syntax highlighting is working:
But still no html-snippet expansion...
Now syntax highlighting and html-snippets are working:
All sugestions to improve on this are welcome!