'Neovim Treesitter highlighting HTML,JS,PHP in PHP file

I recently switched to Neovim and I tried to configure native LSP with Treesitter.

I ran into some wrong highlighting with PHP combined with HTML. Everytime when I write php in html element, closing tag is not highlighted.

enter image description here

Treesitter cfg:

local configs = require'nvim-treesitter.configs'
configs.setup {
  ensure_installed = 'maintained', --Only use parsers that are maintained
  highlight = { -- enable highlighting
    enable = true,
  },
  indent = {
    enabled = true,
  },
}

I found something about multiple lang support for one file type with language injections but I have no idea how to implement that.



Solution 1:[1]

Issue with neovim treesitter.

Issue: https://github.com/nvim-treesitter/nvim-treesitter/issues/2565

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tomz