aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis van den Berg <dennis.vandenberg@nedap.com>2024-01-27 12:17:25 +0100
committerGitHub <noreply@github.com>2024-01-27 12:17:25 +0100
commit2fb2100fedf8988f12b1f09efe38134f831e2d99 (patch)
treefe633044d2235dc8e283dab17c9c89b5409bde4b
parentUpdate parsers: astro, bitbake, c, cpp, dtd, gnuplot, json, php, php_only, wi... (diff)
downloadnvim-treesitter-2fb2100fedf8988f12b1f09efe38134f831e2d99.tar
nvim-treesitter-2fb2100fedf8988f12b1f09efe38134f831e2d99.tar.gz
nvim-treesitter-2fb2100fedf8988f12b1f09efe38134f831e2d99.tar.bz2
nvim-treesitter-2fb2100fedf8988f12b1f09efe38134f831e2d99.tar.lz
nvim-treesitter-2fb2100fedf8988f12b1f09efe38134f831e2d99.tar.xz
nvim-treesitter-2fb2100fedf8988f12b1f09efe38134f831e2d99.tar.zst
nvim-treesitter-2fb2100fedf8988f12b1f09efe38134f831e2d99.zip
feat(angular)!: switch to parser supporting v17 (#5779)
-rw-r--r--lockfile.json2
-rw-r--r--lua/nvim-treesitter/parsers.lua7
-rw-r--r--queries/angular/folds.scm1
-rw-r--r--queries/angular/highlights.scm116
-rw-r--r--queries/angular/indents.scm1
-rw-r--r--queries/angular/injections.scm1
-rw-r--r--queries/angular/locals.scm1
-rw-r--r--queries/ecma/injections.scm62
-rw-r--r--queries/html_tags/injections.scm20
9 files changed, 159 insertions, 52 deletions
diff --git a/lockfile.json b/lockfile.json
index 24c08a40a..c4d2e5233 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -6,7 +6,7 @@
"revision": "c21c3a0f996363ed17b8ac99d827fe5a4821f217"
},
"angular": {
- "revision": "624ff108fe949727217cddb302f20e4f16997b1c"
+ "revision": "28119b4dc813d3f8267d451c44548e99124fbf9a"
},
"apex": {
"revision": "ca70b2347a79615cd749517f6c6c2352e50a7ce9"
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index af7ee2043..da83e0a22 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -95,10 +95,11 @@ list.agda = {
list.angular = {
install_info = {
- url = "https://github.com/steelsojka/tree-sitter-angular",
- files = { "src/parser.c" },
- requires_generate_from_grammar = true,
+ url = "https://github.com/dlvandenberg/tree-sitter-angular",
+ files = { "src/parser.c", "src/scanner.c" },
+ generate_requires_npm = true,
},
+ maintainers = { "@dlvandenberg" },
experimental = true,
}
diff --git a/queries/angular/folds.scm b/queries/angular/folds.scm
new file mode 100644
index 000000000..1f2129cf9
--- /dev/null
+++ b/queries/angular/folds.scm
@@ -0,0 +1 @@
+; inherits: html
diff --git a/queries/angular/highlights.scm b/queries/angular/highlights.scm
index a109dc179..eb0107e2d 100644
--- a/queries/angular/highlights.scm
+++ b/queries/angular/highlights.scm
@@ -1,7 +1,7 @@
+; inherits: html_tags
(identifier) @variable
-(pipe_sequence
- "|" @operator)
+(pipe_operator) @operator
(string) @string
@@ -15,6 +15,27 @@
(pipe_arguments
(identifier) @variable.parameter))
+(structural_directive
+ "*" @keyword
+ (identifier) @keyword)
+
+(attribute
+ (attribute_name) @variable.member
+ (#lua-match? @variable.member "#.*"))
+
+(binding_name
+ (identifier) @keyword)
+
+(event_binding
+ (binding_name
+ (identifier) @keyword))
+
+(event_binding
+ "\"" @punctuation.delimiter)
+
+(property_binding
+ "\"" @punctuation.delimiter)
+
(structural_assignment
operator: (identifier) @keyword)
@@ -29,10 +50,38 @@
((identifier) @function.builtin
(#eq? @function.builtin "$any")))
+(pair
+ key:
+ ((identifier) @variable.builtin
+ (#eq? @variable.builtin "$implicit")))
+
+((control_keyword) @keyword.repeat
+ (#any-of? @keyword.repeat "for" "empty"))
+
+((control_keyword) @keyword.conditional
+ (#any-of? @keyword.conditional "if" "else" "switch" "case" "default"))
+
+((control_keyword) @keyword.coroutine
+ (#any-of? @keyword.coroutine "defer" "placeholder" "loading"))
+
+((control_keyword) @keyword.exception
+ (#eq? @keyword.exception "error"))
+
+(special_keyword) @keyword
+
+((identifier) @boolean
+ (#any-of? @boolean "true" "false"))
+
+((identifier) @variable.builtin
+ (#any-of? @variable.builtin "this" "$event"))
+
+((identifier) @constant.builtin
+ (#eq? @constant.builtin "null"))
+
[
- "let"
- "as"
-] @keyword
+ (ternary_operator)
+ (conditional_operator)
+] @keyword.conditional.ternary
[
"("
@@ -41,36 +90,47 @@
"]"
"{"
"}"
+ "@"
+ "} @"
+ (if_end_expression)
+ (for_end_expression)
+ (switch_end_expression)
+ (case_end_expression)
+ (default_end_expression)
+ (defer_end_expression)
] @punctuation.bracket
[
+ "{{"
+ "}}"
+] @punctuation.special
+
+[
";"
"."
","
"?."
] @punctuation.delimiter
-((identifier) @boolean
- (#any-of? @boolean "true" "false"))
-
-((identifier) @variable.builtin
- (#any-of? @variable.builtin "this" "\$event" "null"))
+(concatination_expression
+ "+" @operator)
-[
- "-"
- "&&"
- "+"
- "<"
- "<="
- "="
- "=="
- "==="
- "!="
- "!=="
- ">"
- ">="
- "*"
- "/"
- "||"
- "%"
-] @operator
+(binary_expression
+ [
+ "-"
+ "&&"
+ "+"
+ "<"
+ "<="
+ "="
+ "=="
+ "==="
+ "!="
+ "!=="
+ ">"
+ ">="
+ "*"
+ "/"
+ "||"
+ "%"
+ ] @operator)
diff --git a/queries/angular/indents.scm b/queries/angular/indents.scm
new file mode 100644
index 000000000..448e94275
--- /dev/null
+++ b/queries/angular/indents.scm
@@ -0,0 +1 @@
+; inherits: html_tags
diff --git a/queries/angular/injections.scm b/queries/angular/injections.scm
new file mode 100644
index 000000000..448e94275
--- /dev/null
+++ b/queries/angular/injections.scm
@@ -0,0 +1 @@
+; inherits: html_tags
diff --git a/queries/angular/locals.scm b/queries/angular/locals.scm
new file mode 100644
index 000000000..1f2129cf9
--- /dev/null
+++ b/queries/angular/locals.scm
@@ -0,0 +1 @@
+; inherits: html
diff --git a/queries/ecma/injections.scm b/queries/ecma/injections.scm
index 51eb22a7e..d23e2fdfa 100644
--- a/queries/ecma/injections.scm
+++ b/queries/ecma/injections.scm
@@ -137,3 +137,65 @@
(string
(string_fragment) @injection.content)
(#set! injection.language "html"))
+
+;---- Angular injections -----
+; @Component({
+; template: `<html>`
+; })
+(decorator
+ (call_expression
+ function:
+ ((identifier) @_name
+ (#eq? @_name "Component"))
+ arguments:
+ (arguments
+ (object
+ (pair
+ key:
+ ((property_identifier) @_prop
+ (#eq? @_prop "template"))
+ value:
+ ((template_string) @injection.content
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "angular")))))))
+
+; @Component({
+; styles: [`<css>`]
+; })
+(decorator
+ (call_expression
+ function:
+ ((identifier) @_name
+ (#eq? @_name "Component"))
+ arguments:
+ (arguments
+ (object
+ (pair
+ key:
+ ((property_identifier) @_prop
+ (#eq? @_prop "styles"))
+ value:
+ (array
+ ((template_string) @injection.content
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "css"))))))))
+
+; @Component({
+; styles: `<css>`
+; })
+(decorator
+ (call_expression
+ function:
+ ((identifier) @_name
+ (#eq? @_name "Component"))
+ arguments:
+ (arguments
+ (object
+ (pair
+ key:
+ ((property_identifier) @_prop
+ (#eq? @_prop "styles"))
+ value:
+ ((template_string) @injection.content
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "css")))))))
diff --git a/queries/html_tags/injections.scm b/queries/html_tags/injections.scm
index 7c9c835ef..5b78e37b4 100644
--- a/queries/html_tags/injections.scm
+++ b/queries/html_tags/injections.scm
@@ -89,23 +89,3 @@
(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"))