aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Davis2022-04-13 01:55:30 +0000
committerBlaž Hrastnik2022-04-13 05:28:51 +0000
commit9d095e0fdc78ad42c033193dd980b6218c9484d6 (patch)
treee3ba30af229e385c63b83c41f8cc13ad7cc7dcb3
parent4ac94a5c431c8ddff38bba5061e66ed355c42747 (diff)
add tree-sitter-eex
EEx is an templating language for Elixir. Since the incremental parsing refactor we can used combined injections which allows us to add EEx support.
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml12
-rw-r--r--runtime/queries/eex/highlights.scm6
-rw-r--r--runtime/queries/eex/injections.scm9
4 files changed, 28 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index efafc3e5..a58c1595 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -9,6 +9,7 @@
| css | ✓ | | | `vscode-css-language-server` |
| dart | ✓ | | ✓ | `dart` |
| dockerfile | ✓ | | | `docker-langserver` |
+| eex | ✓ | | | |
| ejs | ✓ | | | |
| elixir | ✓ | | | `elixir-ls` |
| elm | ✓ | | | `elm-language-server` |
diff --git a/languages.toml b/languages.toml
index e7408849..79738db1 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1113,3 +1113,15 @@ grammar = "embedded-template"
[[grammar]]
name = "embedded-template"
source = { git = "https://github.com/tree-sitter/tree-sitter-embedded-template", rev = "d21df11b0ecc6fd211dbe11278e92ef67bd17e97" }
+
+[[language]]
+name = "eex"
+scope = "source.eex"
+injection-regex = "eex"
+file-types = ["eex"]
+roots = []
+indent = { tab-width = 2, unit = " " }
+
+[[grammar]]
+name = "eex"
+source = { git = "https://github.com/connorlay/tree-sitter-eex", rev = "f742f2fe327463335e8671a87c0b9b396905d1d1" }
diff --git a/runtime/queries/eex/highlights.scm b/runtime/queries/eex/highlights.scm
new file mode 100644
index 00000000..e900a43d
--- /dev/null
+++ b/runtime/queries/eex/highlights.scm
@@ -0,0 +1,6 @@
+; https://github.com/connorlay/tree-sitter-eex/blob/f742f2fe327463335e8671a87c0b9b396905d1d1/queries/highlights.scm
+
+; wrapping in (directive .. ) prevents us from highlighting '%>' in a comment as a keyword
+(directive ["<%" "<%=" "<%%" "<%%=" "%>"] @keyword)
+
+(comment) @comment
diff --git a/runtime/queries/eex/injections.scm b/runtime/queries/eex/injections.scm
new file mode 100644
index 00000000..4686bf4d
--- /dev/null
+++ b/runtime/queries/eex/injections.scm
@@ -0,0 +1,9 @@
+; https://github.com/connorlay/tree-sitter-eex/blob/f742f2fe327463335e8671a87c0b9b396905d1d1/queries/injections.scm
+
+((directive (expression) @injection.content)
+ (#set! injection.language "elixir"))
+
+((partial_expression) @injection.content
+ (#set! injection.language "elixir")
+ (#set! injection.include-children)
+ (#set! injection.combined))