aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Isekeev2023-08-09 14:26:58 +0000
committerGitHub2023-08-09 14:26:58 +0000
commit57f093d83641642ad5d4ba42ae59f03272efcfcc (patch)
tree5fcbd500afd62f807723f2b0cd5836394df682ad
parentc0eae84073ccbf09955f546cbad889e7c1487984 (diff)
Jinja language family syntax support (#7233)
* feat: add jinja language support * feat: add nunjucks language support * feat: add to lang support book jinja and nunjucks languages
-rw-r--r--book/src/generated/lang-support.md2
-rw-r--r--languages.toml22
-rw-r--r--runtime/queries/jinja/highlights.scm7
-rw-r--r--runtime/queries/jinja/injections.scm4
-rw-r--r--runtime/queries/nunjucks/highlights.scm1
-rw-r--r--runtime/queries/nunjucks/injections.scm1
6 files changed, 37 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 572654bd..297f67af 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -71,6 +71,7 @@
| ini | ✓ | | | |
| java | ✓ | ✓ | ✓ | `jdtls` |
| javascript | ✓ | ✓ | ✓ | `typescript-language-server` |
+| jinja | ✓ | | | |
| jsdoc | ✓ | | | |
| json | ✓ | | ✓ | `vscode-json-language-server` |
| jsonnet | ✓ | | | `jsonnet-language-server` |
@@ -100,6 +101,7 @@
| nim | ✓ | ✓ | ✓ | `nimlangserver` |
| nix | ✓ | | | `nil` |
| nu | ✓ | | | |
+| nunjucks | ✓ | | | |
| ocaml | ✓ | | ✓ | `ocamllsp` |
| ocaml-interface | ✓ | | | `ocamllsp` |
| odin | ✓ | | ✓ | `ols` |
diff --git a/languages.toml b/languages.toml
index 20be5495..0e217842 100644
--- a/languages.toml
+++ b/languages.toml
@@ -2702,6 +2702,28 @@ roots = []
indent = { tab-width = 2, unit = " " }
grammar = "html"
+[[language]]
+name = "nunjucks"
+scope = "text.html.nunjucks"
+injection-regex = "nunjucks"
+file-types = ["njk"]
+roots = []
+indent = { tab-width = 2, unit = " " }
+grammar = "jinja2"
+
+[[language]]
+name = "jinja"
+scope = "text.html.jinja"
+injection-regex = "jinja"
+file-types = ["jinja", "jinja2", "j2"]
+roots = []
+indent = { tab-width = 2, unit = " " }
+grammar = "jinja2"
+
+[[grammar]]
+name = "jinja2"
+source = { git = "https://github.com/varpeti/tree-sitter-jinja2", rev = "a533cd3c33aea6acb0f9bf9a56f35dcfe6a8eb53" }
+
[[grammar]]
name = "wren"
source = { git = "https://git.sr.ht/~jummit/tree-sitter-wren", rev = "793d58266924e6efcc40e411663393e9d72bec87"}
diff --git a/runtime/queries/jinja/highlights.scm b/runtime/queries/jinja/highlights.scm
new file mode 100644
index 00000000..3166ccbd
--- /dev/null
+++ b/runtime/queries/jinja/highlights.scm
@@ -0,0 +1,7 @@
+(expression) @string
+(statement) @variable.builtin
+(keyword) @keyword
+(comment) @comment
+(identifier) @variable.parameter
+(operator) @operator
+(string) @string \ No newline at end of file
diff --git a/runtime/queries/jinja/injections.scm b/runtime/queries/jinja/injections.scm
new file mode 100644
index 00000000..8599722e
--- /dev/null
+++ b/runtime/queries/jinja/injections.scm
@@ -0,0 +1,4 @@
+((source_file) @injection.content
+ (#set! injection.combined)
+ (#set! injection.include-children)
+ (#set! injection.language "html")) \ No newline at end of file
diff --git a/runtime/queries/nunjucks/highlights.scm b/runtime/queries/nunjucks/highlights.scm
new file mode 100644
index 00000000..d6bbc197
--- /dev/null
+++ b/runtime/queries/nunjucks/highlights.scm
@@ -0,0 +1 @@
+; inherits: jinja \ No newline at end of file
diff --git a/runtime/queries/nunjucks/injections.scm b/runtime/queries/nunjucks/injections.scm
new file mode 100644
index 00000000..d6bbc197
--- /dev/null
+++ b/runtime/queries/nunjucks/injections.scm
@@ -0,0 +1 @@
+; inherits: jinja \ No newline at end of file