coc-angular does not support 'htmlangular' filetype
Result from CocInfo
versions
vim version: NVIM v0.11.0-dev node version: v22.9.0 coc.nvim version: 0.0.82-aacbbcad 2024-11-23 13:34:02 +0800 coc.nvim directory: /home/joeri/.local/share/nvim/lazy/coc.nvim term: xterm-kitty platform: linux
Log of coc.nvim
2024-11-25T10:49:38.862 INFO (pid:199579) [plugin] - coc.nvim initialized with node: v22.9.0 after 235 2024-11-25T10:49:39.001 INFO (pid:199579) [core-watchman] - watchman watching project: /home/joeri/Projects/lab/my-angular-app
Describe the bug
As indicated here Neovim is now detecting file-types for angular and sets a filetype of htmlangular. Currently coc-angular looks for html or typescript, hence the plugins is not activated.
Reproduce the bug
- Use "the nightly neovim built (or release 0.11.x)"
- Open an angular project
- Attempt to use the coc-angular functionalities in a component template
- Notice the functionality does not work in the template, but works in the typescript code
I've created a PR but for others bumping into this you can also do the following workaround:
Create an auto command that will set the filetype to html.htmlangular
local autoCommands = vim.api.nvim_create_augroup("autoCommands", { clear = true })
vim.api.nvim_create_autocmd(
{ "BufRead", "BufNewFile" },
{ group = autoCommands, pattern = "*.component.html", command = "set filetype=html" }
)
However that will leave you without the nice highlighting of treesitter (if you are using that) in which case you can:
Create an auto command that will set the filetype to html.htmlangular (which essentially sets 2 file types, html and htmlangular) and extend the treesitter language to include that filetype so you still have the highlighting.
vim.treesitter.language.register("angular", "html.htmlangular")
local autoCommands = vim.api.nvim_create_augroup("autoCommands", { clear = true })
vim.api.nvim_create_autocmd(
{ "BufRead", "BufNewFile" },
{ group = autoCommands, pattern = "*.component.html", command = "set filetype=html.htmlangular" }
)