Tree-sitter grammar for the Angular framework
npm install tree-sitter-angularThis parser is a complete rewrite of steelsojka's tree-sitter-angular.
This parser extends tree-sitter-html because the new _Control Flow_ syntax is not valid HTML code.
- [x] Structural Directives
- [x] Property binding
- [x] Event binding
- [x] String interpolation
- [x] If-statements (v17)
- [x] For-statements (v17)
- [x] Switch-statements (v17)
- [x] Defer-statements (v17)
- [x] Let-expression (v18.1)
- [x] ICU message format
- [x] Untagged Template Literals (v19.2)
- [x] Exponentiation (**) and in operators (v20)
- [x] Binary assignment (+=, *=, etc) operators (v20.1)
- [x] Regular expressions (/\d+/i) (v21)
- Neovim v 0.11.x required (as it includes the filetype detection of Angular Templates)
Since neovim release 0.11.x, the filetype detection for Angular templates is included. It will detect Angular HTML templates, based on it's contents, and set the filetype to htmlangular.
If you are using an older version, you must set the filetype yourself.
E.g. mark the file as htmlangular if it matches the pattern *.component.html:
Create a plugin in ~/.config/nvim/plugin/angular.lua with the following:
``luahtmlangular
vim.filetype.add({
pattern = {
[".*%.component%.html"] = "htmlangular", -- Sets the filetype to if it matches the pattern`
},
})
Next, create a ftplugin for htmlangular that does the following:
`vim`
runtime! ftplugin/html.vim!
Or, in lua:
`lua`
vim.cmd('runtime! ftplugin/html.vim!')
You may need to include this new filetype (htmlangular) for other plugins, like LSP for example:
`lua``
require('lspconfig').angularls.setup {
filetypes = { 'typescript', 'html', 'typescriptreact', 'typescript.tsx', 'htmlangular' }
}
If you experience any issues, please feel free to open an issue with the code that's causing problems.