tree-sitter-angular

Crates.iotree-sitter-angular
lib.rstree-sitter-angular
version0.3.0
sourcesrc
created_at2024-05-07 14:01:54.349427
updated_at2024-05-07 14:01:54.349427
descriptionAngular grammar for tree-sitter
homepage
repositoryhttps://github.com/tree-sitter/tree-sitter-angular
max_upload_size
id1232207
size790,933
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)
  • ICU message format

Filetype

By default Angular's template files are marked as HTML and it will use the HTML parser. To use the Angular parser instead, you will need to create a plugin that sets the filetype correctly and registers the filetype for the angular parser in treesitter.

Create a plugin in ~/.config/nvim/plugin/angular.lua with the following:

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

vim.api.nvim_create_autocmd("FileType", {
  pattern = "angular.html",
  callback = function()
    vim.treesitter.language.register("angular", "angular.html") -- Register the filetype with treesitter for the `angular` language/parser
  end,
})

By setting the filetype to angular.html, other functionality of nvim or other plugins should still work.

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