From 1e74c34b668d0bbdd14492fc220974e4fc38dc6b Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 24 Nov 2023 10:25:47 +0100 Subject: feat: add angular parser and queries --- lockfile.json | 3 ++ lua/nvim-treesitter/parsers.lua | 8 +++++ queries/angular/highlights.scm | 67 ++++++++++++++++++++++++++++++++++++++++ queries/html_tags/injections.scm | 21 +++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 queries/angular/highlights.scm diff --git a/lockfile.json b/lockfile.json index 903bbf405..01d9ad274 100644 --- a/lockfile.json +++ b/lockfile.json @@ -5,6 +5,9 @@ "agda": { "revision": "c21c3a0f996363ed17b8ac99d827fe5a4821f217" }, + "angular": { + "revision": "624ff108fe949727217cddb302f20e4f16997b1c" + }, "apex": { "revision": "82ee140f4ee7652a4915ac9e9f60c4d66f7637d7" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index b012d514a..0c83e58f0 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -93,6 +93,14 @@ list.agda = { maintainers = { "@Decodetalkers" }, } +list.angular = { + install_info = { + url = "https://github.com/steelsojka/tree-sitter-angular", + files = { "src/parser.c" }, + }, + maintainers = {"@steelsojka"} +} + list.apex = { install_info = { url = "https://github.com/aheber/tree-sitter-sfapex", diff --git a/queries/angular/highlights.scm b/queries/angular/highlights.scm new file mode 100644 index 000000000..98c6f76e9 --- /dev/null +++ b/queries/angular/highlights.scm @@ -0,0 +1,67 @@ +(identifier) @variable +(pipe_sequence "|" @operator) +(string) @string +(number) @number +(pipe_call + name: (identifier) @function) +(pipe_call + arguments: (pipe_arguments + (identifier) @parameter)) + +(structural_assignment + operator: (identifier) @keyword) + +(member_expression + property: (identifier) @property) + +(call_expression + function: (identifier) @function) + +(call_expression + function: ((identifier) @function.builtin + (#eq? @function.builtin "$any"))) + +[ +"let" +"as" +] @keyword + +[ +"(" +")" +"[" +"]" +"{" +"}" +] @punctuation.bracket + +[ +";" +"." +"," +"?." +] @punctuation.delimiter + +((identifier) @boolean + (#vim-match? @boolean "^(true|false)$")) +((identifier) @variable.builtin + (#vim-match? @variable.builtin "^(this|\$event|null)$")) + +[ + "-" + "&&" + "+" + "<" + "<=" + "=" + "==" + "===" + "!=" + "!==" + ">" + ">=" + "*" + "/" + "||" + "%" +] @operator diff --git a/queries/html_tags/injections.scm b/queries/html_tags/injections.scm index 563e7453d..cef63ad8d 100644 --- a/queries/html_tags/injections.scm +++ b/queries/html_tags/injections.scm @@ -74,3 +74,24 @@ (#lua-match? @_name "^on[a-z]+$") (quoted_attribute_value (attribute_value) @injection.content) (#set! injection.language "javascript")) + +(attribute + ((attribute_name) @_name + (#lua-match? @_name "[%[%(].*[%)%]]")) + (quoted_attribute_value + (attribute_value) @injection.content) + (#set! injection.language "angular")) + +(attribute + ((attribute_name) @_name + (#lua-match? @_name "^%*")) + (quoted_attribute_value + ((attribute_value) @injection.content)) + (#set! injection.language "angular")) + +(element + ((text) @injection.content + (#lua-match? @injection.content "%{%{.*%}%}") + (#offset! @injection.content 0 2 0 -2)) + (#set! injection.language "angular")) + -- cgit v1.2.3-70-g09d2