dlvandenberg / tree-sitter-angular

Tree Sitter Grammar for Angular
MIT License
34 stars 9 forks source link

Finding common solution for file type related issues #15

Closed Ask-786 closed 5 months ago

Ask-786 commented 6 months ago

Instead of setting the file type just angular, there is a workaround.

autocmd BufRead,BufEnter *.component.html set filetype=angular.html

we can set it to angular.html so the syntax highlight and all other common package related stuffs are working. like,

VonHeikemen/lsp-zero.nvim tpope/vim-commentary L3MON4D3/LuaSnip nvimtools/none-ls.nvim

But tailwindcss-language-server still doesn't work perfect.

dlvandenberg commented 6 months ago

How does that work? Does it mark the file as html essentially, with angular being a subset or something?

Ask-786 commented 6 months ago

I think it does something like that. when we set filetype as angular, basic functionalities like jumping between opening and closing tags with % doesn't work. That's why i searched for another way. and also it's a pain to write configuration everywhere just for one specific thing.

Even if it doesn't work that way, I think we should try to make it work that way.

May be we can refer to the previous angular treesitter plugin nvim-treesitter-angular. this one was working fine out of the box.

dlvandenberg commented 6 months ago

The old plugin was injecting the parser on parts of the HTML file. That does not work with the control flow syntax of Angular. (@if (something) { } is not valid HTML and throws errors in the HTML parser). Which is why I rebuilt the plugin, but now the Angular parser is extending the HTML one.

I will test it with filetype=angular.html.

dlvandenberg commented 6 months ago

@Ask-786 it seems to work. I submitted a PR to nvim-treesitter

dlvandenberg commented 5 months ago

It can be solved by setting the filetype in a custom plugin: (PR #17) See here for the readme