iamcco / coc-angular

Angular Language Service coc extension for (neo)vim
147 stars 18 forks source link

coc-angular does not support 'htmlangular' filetype #78

Open joerideg opened 8 hours ago

joerideg commented 8 hours ago

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

joerideg commented 8 hours ago

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" }
)