Unnamed repository; edit this file 'description' to name the repository.
Add Django language support (#13935)
Maikel Martens 8 months ago
parent 532f241 · commit 43187f2
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml20
-rw-r--r--runtime/queries/htmldjango/highlights.scm26
-rw-r--r--runtime/queries/htmldjango/injections.scm3
4 files changed, 50 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 1544c768..cc9e0e62 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -105,6 +105,7 @@
| hoon | ✓ | | | |
| hosts | ✓ | | | |
| html | ✓ | | | `vscode-html-language-server`, `superhtml` |
+| htmldjango | ✓ | | | `djlsp`, `vscode-html-language-server`, `superhtml` |
| hurl | ✓ | ✓ | ✓ | |
| hyprlang | ✓ | | ✓ | `hyprls` |
| idris | | | | `idris2-lsp` |
diff --git a/languages.toml b/languages.toml
index 9827db8d..5c37a0b7 100644
--- a/languages.toml
+++ b/languages.toml
@@ -32,6 +32,7 @@ csharp-ls = { command = "csharp-ls" }
cuelsp = { command = "cuelsp" }
dart = { command = "dart", args = ["language-server", "--client-id=helix"] }
dhall-lsp-server = { command = "dhall-lsp-server" }
+djlsp = { command = "djlsp" }
docker-langserver = { command = "docker-langserver", args = ["--stdio"] }
docker-compose-langserver = { command = "docker-compose-langserver", args = ["--stdio"]}
dot-language-server = { command = "dot-language-server", args = ["--stdio"] }
@@ -957,6 +958,25 @@ name = "html"
source = { git = "https://github.com/tree-sitter/tree-sitter-html", rev = "cbb91a0ff3621245e890d1c50cc811bffb77a26b" }
[[language]]
+name = "htmldjango"
+scope = "source.htmldjango"
+injection-regex = "htmldjango"
+language-servers = ["djlsp", "vscode-html-language-server", "superhtml"]
+file-types = []
+
+[language.auto-pairs]
+'"' = '"'
+'(' = ')'
+'[' = ']'
+'{' = '}'
+'%' = '%'
+'<' = '>'
+
+[[grammar]]
+name = "htmldjango"
+source = { git = "https://github.com/interdependence/tree-sitter-htmldjango", rev = "3a643167ad9afac5d61e092f08ff5b054576fadf" }
+
+[[language]]
name = "python"
scope = "source.python"
injection-regex = "py(thon)?"
diff --git a/runtime/queries/htmldjango/highlights.scm b/runtime/queries/htmldjango/highlights.scm
new file mode 100644
index 00000000..c8077f94
--- /dev/null
+++ b/runtime/queries/htmldjango/highlights.scm
@@ -0,0 +1,26 @@
+[
+ (unpaired_comment)
+ (paired_comment)
+] @comment
+
+[
+ "{{"
+ "}}"
+ "{%"
+ "%}"
+ (end_paired_statement)
+] @punctuation.bracket
+
+[
+ (tag_name)
+] @function
+
+(variable_name) @variable
+(filter_name) @function
+(filter_argument) @variable.parameter
+(keyword) @keyword
+(operator) @operator
+(keyword_operator) @keyword.operator
+(number) @constant.numeric
+(boolean) @constant.builtin.boolean
+(string) @string
diff --git a/runtime/queries/htmldjango/injections.scm b/runtime/queries/htmldjango/injections.scm
new file mode 100644
index 00000000..f0822734
--- /dev/null
+++ b/runtime/queries/htmldjango/injections.scm
@@ -0,0 +1,3 @@
+((content) @injection.content
+ (#set! injection.language "html")
+ (#set! injection.combined))