tree-sitter-angular

Crates.iotree-sitter-angular
lib.rstree-sitter-angular
version0.6.4
created_at2024-05-07 14:01:54.349427+00
updated_at2025-07-23 08:15:14.270389+00
descriptionAngular grammar for tree-sitter
homepage
repositoryhttps://github.com/tree-sitter/tree-sitter-angular
max_upload_size
id1232207
size790,110
Dennis van den Berg (dlvandenberg)

documentation

README

✨ Tree Sitter Grammar for Angular ✨

GitHub Workflow Status (with event) Angular Tree-sitter CLI version

Specification

This 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.

Supported Features

  • Structural Directives
  • Property binding
  • Event binding
  • String interpolation
  • If-statements (v17)
  • For-statements (v17)
  • Switch-statements (v17)
  • Defer-statements (v17)
  • Let-expression (v18.1)
  • ICU message format
  • Untagged Template Literals (v19.2)
  • Exponentiation (**) and in operators (v20)
  • Binary assignment (+=, *=, etc) operators (v20.1)

Requirements

  • Neovim v 0.11.x required (as it includes the filetype detection of Angular Templates)

Filetype

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.

Older versions

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:

vim.filetype.add({
  pattern = {
    [".*%.component%.html"] = "htmlangular", -- Sets the filetype to `htmlangular` if it matches the pattern
  },
})

Next, create a ftplugin for htmlangular that does the following:

runtime! ftplugin/html.vim!

Or, in lua:

vim.cmd('runtime! ftplugin/html.vim!')

LSP's or other plugins

You may need to include this new filetype (htmlangular) for other plugins, like LSP for example:

require('lspconfig').angularls.setup {
  filetypes = { 'typescript', 'html', 'typescriptreact', 'typescript.tsx', 'htmlangular' }
}

Issues

If you experience any issues, please feel free to open an issue with the code that's causing problems.

Commit count: 0

cargo fmt