From 159d879b57654e4008d28099b57361b0db340bde Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Fri, 29 Jul 2022 23:57:04 +0800 Subject: [PATCH] Add tree-sitter-htmldjango --- book/src/generated/lang-support.md | 1 + languages.toml | 12 +++++++++++ runtime/queries/htmldjango/highlights.scm | 25 ++++++++++++++++++++++ runtime/queries/htmldjango/indents.scm | 3 +++ runtime/queries/htmldjango/injections.scm | 6 ++++++ runtime/queries/htmldjango/textobjects.scm | 7 ++++++ runtime/themes/monokai_pro_spectrum.toml | 2 ++ 7 files changed, 56 insertions(+) create mode 100644 runtime/queries/htmldjango/highlights.scm create mode 100644 runtime/queries/htmldjango/indents.scm create mode 100644 runtime/queries/htmldjango/injections.scm create mode 100644 runtime/queries/htmldjango/textobjects.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 0e150a6746093..3e01f19020ec3 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -42,6 +42,7 @@ | hcl | ✓ | | ✓ | `terraform-ls` | | heex | ✓ | ✓ | | | | html | ✓ | | | `vscode-html-language-server` | +| htmldjango | ✓ | ✓ | ✓ | | | idris | | | | `idris2-lsp` | | iex | ✓ | | | | | java | ✓ | | | `jdtls` | diff --git a/languages.toml b/languages.toml index 67e607df6026c..f094cbb88ef3f 100644 --- a/languages.toml +++ b/languages.toml @@ -423,6 +423,18 @@ indent = { tab-width = 2, unit = " " } name = "html" source = { git = "https://github.com/tree-sitter/tree-sitter-html", rev = "d93af487cc75120c89257195e6be46c999c6ba18" } +[[language]] +name = "htmldjango" +scope = "source.htmldjango" +injection-regex = "htmldjango" +file-types = ["html"] +roots = ["manage.py"] +indent = { tab-width = 2, unit = " " } + +[[grammar]] +name = "htmldjango" +source = { git = "https://github.com/interdependence/tree-sitter-htmldjango", rev = "184a50456186c2ff49b9b410f7060a176e2a3080" } + [[language]] name = "python" scope = "source.python" diff --git a/runtime/queries/htmldjango/highlights.scm b/runtime/queries/htmldjango/highlights.scm new file mode 100644 index 0000000000000..3529aa9d13436 --- /dev/null +++ b/runtime/queries/htmldjango/highlights.scm @@ -0,0 +1,25 @@ +[ + (unpaired_comment) + (paired_comment) +] @comment + +[ + "{{" + "}}" + "{%" + "%}" + (end_paired_statement) +] @tag + +"end" @keyword.return + +(variable_name) @variable +(filter_name) @function.macro +(filter_argument) @variable.parameter +(tag_name) @function +(keyword) @keyword +(operator) @operator +(keyword_operator) @keyword.directive +(number) @constant.numeric +(boolean) @constant.builtin.boolean +(string) @string diff --git a/runtime/queries/htmldjango/indents.scm b/runtime/queries/htmldjango/indents.scm new file mode 100644 index 0000000000000..8fa0a456c9238 --- /dev/null +++ b/runtime/queries/htmldjango/indents.scm @@ -0,0 +1,3 @@ +(paired_statement) @indent +(end_paired_statement) @indent_end +(branch_statement) @branch diff --git a/runtime/queries/htmldjango/injections.scm b/runtime/queries/htmldjango/injections.scm new file mode 100644 index 0000000000000..23878ee7232f2 --- /dev/null +++ b/runtime/queries/htmldjango/injections.scm @@ -0,0 +1,6 @@ +((content) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) + +([(unpaired_comment) (paired_comment)] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/htmldjango/textobjects.scm b/runtime/queries/htmldjango/textobjects.scm new file mode 100644 index 0000000000000..abba7029ea9dc --- /dev/null +++ b/runtime/queries/htmldjango/textobjects.scm @@ -0,0 +1,7 @@ +[ + "{{" + "}}" + "{%" + "%}" + (end_paired_statement) +] @tag diff --git a/runtime/themes/monokai_pro_spectrum.toml b/runtime/themes/monokai_pro_spectrum.toml index 9f5864fccb019..ea7268b23701a 100644 --- a/runtime/themes/monokai_pro_spectrum.toml +++ b/runtime/themes/monokai_pro_spectrum.toml @@ -56,10 +56,12 @@ # operator, tags, units, punctuations "operator" = "red" "variable.other.member" = "base8" +"tag" = "yellow" # keywords, special "keyword" = { fg = "red" } "keyword.directive" = "blue" +"keyword.function" = "blue" "variable.parameter" = "#f59762" # error