aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Rischmann <vincent@rischmann.fr>2023-11-16 22:12:55 +0100
committerGitHub <noreply@github.com>2023-11-16 16:12:55 -0500
commitda6646c3e51cf10b8da1cb89be9aaf60ab41c6a3 (patch)
treeb621f027c9aeaf500f8aa7a90f42913e8a5d011c
parentUpdate parsers: cpp, wing (diff)
downloadnvim-treesitter-da6646c3e51cf10b8da1cb89be9aaf60ab41c6a3.tar
nvim-treesitter-da6646c3e51cf10b8da1cb89be9aaf60ab41c6a3.tar.gz
nvim-treesitter-da6646c3e51cf10b8da1cb89be9aaf60ab41c6a3.tar.bz2
nvim-treesitter-da6646c3e51cf10b8da1cb89be9aaf60ab41c6a3.tar.lz
nvim-treesitter-da6646c3e51cf10b8da1cb89be9aaf60ab41c6a3.tar.xz
nvim-treesitter-da6646c3e51cf10b8da1cb89be9aaf60ab41c6a3.tar.zst
nvim-treesitter-da6646c3e51cf10b8da1cb89be9aaf60ab41c6a3.zip
feat: add templ
--------- Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/templ/highlights.scm47
-rw-r--r--queries/templ/injections.scm8
4 files changed, 66 insertions, 0 deletions
diff --git a/lockfile.json b/lockfile.json
index 82429e8eb..9a89d29e6 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -715,5 +715,8 @@
},
"zig": {
"revision": "0d08703e4c3f426ec61695d7617415fff97029bd"
+ },
+ "templ": {
+ "revision": "94ea27668915ef8f084c9fd7174cfd384ac9a275"
}
}
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 9bd3521ef..9077bc8d4 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -2095,6 +2095,14 @@ list.zig = {
maintainers = { "@maxxnino" },
}
+list.templ = {
+ install_info = {
+ url = "https://github.com/vrischmann/tree-sitter-templ",
+ files = { "src/parser.c", "src/scanner.c" },
+ },
+ maintainers = { "@vrischmann" },
+}
+
local M = {
list = list,
filetype_to_parsername = filetype_to_parsername,
diff --git a/queries/templ/highlights.scm b/queries/templ/highlights.scm
new file mode 100644
index 000000000..a7a0718e6
--- /dev/null
+++ b/queries/templ/highlights.scm
@@ -0,0 +1,47 @@
+; inherits: go
+
+(component_declaration
+ name: (component_identifier) @function)
+
+[
+ (tag_start)
+ (tag_end)
+ (self_closing_tag)
+ (style_element)
+] @tag
+
+(attribute
+ name: (attribute_name) @tag.attribute)
+(attribute
+ value: (quoted_attribute_value) @string)
+
+[
+ (element_text)
+ (style_element_text)
+] @string.special
+
+(css_identifier) @function
+(css_property
+ name: (css_property_name) @attribute)
+(css_property
+ value: (css_property_value) @attribute)
+
+[
+ (expression)
+ (dynamic_class_attribute_value)
+] @method
+
+(component_import
+ name: (component_identifier) @function)
+
+(component_render) @function.call
+
+(element_comment) @comment @spell
+
+"@" @operator
+
+[
+ "templ"
+ "css"
+ "script"
+] @keyword
diff --git a/queries/templ/injections.scm b/queries/templ/injections.scm
new file mode 100644
index 000000000..54e8d6f68
--- /dev/null
+++ b/queries/templ/injections.scm
@@ -0,0 +1,8 @@
+; inherits: go
+
+((element_comment) @injection.content (#set! injection.language "comment"))
+
+((script_block_text) @injection.content (#set! injection.language "javascript"))
+((script_element_text) @injection.content (#set! injection.language "javascript"))
+
+((style_element_text) @injection.content (#set! injection.language "css"))