mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-20 12:20:02 -04:00
feat(jinja): add parser and queries (#7573)
Signed-off-by: loongtao.zhang <loongtao.zhang@outlook.com> Co-authored-by: Riley Bruins <ribru17@hotmail.com>
This commit is contained in:
parent
e8ccc339a3
commit
cbd48fac13
6 changed files with 204 additions and 0 deletions
|
|
@ -380,6 +380,9 @@
|
||||||
"javascript": {
|
"javascript": {
|
||||||
"revision": "6fbef40512dcd9f0a61ce03a4c9ae7597b36ab5c"
|
"revision": "6fbef40512dcd9f0a61ce03a4c9ae7597b36ab5c"
|
||||||
},
|
},
|
||||||
|
"jinja": {
|
||||||
|
"revision": "cea7dd379d343e84a6e42793d9055a807957f40f"
|
||||||
|
},
|
||||||
"jq": {
|
"jq": {
|
||||||
"revision": "13990f530e8e6709b7978503da9bc8701d366791"
|
"revision": "13990f530e8e6709b7978503da9bc8701d366791"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1127,6 +1127,24 @@ list.javascript = {
|
||||||
maintainers = { "@steelsojka" },
|
maintainers = { "@steelsojka" },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.jinja = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/cathaysia/tree-sitter-jinja",
|
||||||
|
location = "tree-sitter-jinja",
|
||||||
|
files = { "src/parser.c", "src/scanner.c" },
|
||||||
|
},
|
||||||
|
maintainers = { "@cathaysia" },
|
||||||
|
}
|
||||||
|
|
||||||
|
list.jinja_inline = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/cathaysia/tree-sitter-jinja",
|
||||||
|
location = "tree-sitter-jinja_inline",
|
||||||
|
files = { "src/parser.c", "src/scanner.c" },
|
||||||
|
},
|
||||||
|
maintainers = { "@cathaysia" },
|
||||||
|
}
|
||||||
|
|
||||||
list.jq = {
|
list.jq = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/flurie/tree-sitter-jq",
|
url = "https://github.com/flurie/tree-sitter-jq",
|
||||||
|
|
|
||||||
19
queries/jinja/highlights.scm
Normal file
19
queries/jinja/highlights.scm
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
; inherits: jinja_inline
|
||||||
|
|
||||||
|
[
|
||||||
|
"{{"
|
||||||
|
"{{-"
|
||||||
|
"{{+"
|
||||||
|
"+}}"
|
||||||
|
"-}}"
|
||||||
|
"}}"
|
||||||
|
"{%"
|
||||||
|
"{%-"
|
||||||
|
"{%+"
|
||||||
|
"+%}"
|
||||||
|
"-%}"
|
||||||
|
"%}"
|
||||||
|
] @keyword.directive
|
||||||
|
|
||||||
|
; TODO: only match raw
|
||||||
|
(raw_start) @keyword
|
||||||
5
queries/jinja/injections.scm
Normal file
5
queries/jinja/injections.scm
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
((inline) @injection.content
|
||||||
|
(#set! injection.language "jinja_inline"))
|
||||||
|
|
||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
157
queries/jinja_inline/highlights.scm
Normal file
157
queries/jinja_inline/highlights.scm
Normal file
|
|
@ -0,0 +1,157 @@
|
||||||
|
"#" @keyword.directive
|
||||||
|
|
||||||
|
(string_literal) @string
|
||||||
|
|
||||||
|
(number_literal) @number
|
||||||
|
|
||||||
|
(float_literal) @number.float
|
||||||
|
|
||||||
|
(boolean_literal) @boolean
|
||||||
|
|
||||||
|
(null_literal) @constant
|
||||||
|
|
||||||
|
"defined" @constant
|
||||||
|
|
||||||
|
(comment) @comment @spell
|
||||||
|
|
||||||
|
[
|
||||||
|
","
|
||||||
|
"."
|
||||||
|
":"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
[
|
||||||
|
(attribute_ignore)
|
||||||
|
(attribute_context)
|
||||||
|
"recursive"
|
||||||
|
] @attribute.builtin
|
||||||
|
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
(binary_operator) @operator
|
||||||
|
|
||||||
|
[
|
||||||
|
"block"
|
||||||
|
"with"
|
||||||
|
"filter"
|
||||||
|
"macro"
|
||||||
|
"set"
|
||||||
|
"trans"
|
||||||
|
"pluralize"
|
||||||
|
"autoescape"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
[
|
||||||
|
"endtrans"
|
||||||
|
"endblock"
|
||||||
|
"endwith"
|
||||||
|
"endfilter"
|
||||||
|
"endmacro"
|
||||||
|
"endcall"
|
||||||
|
"endset"
|
||||||
|
"endtrans"
|
||||||
|
"endautoescape"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
(do_statement
|
||||||
|
"do" @keyword)
|
||||||
|
|
||||||
|
[
|
||||||
|
"include"
|
||||||
|
"import"
|
||||||
|
"from"
|
||||||
|
"extends"
|
||||||
|
"as"
|
||||||
|
] @keyword.import
|
||||||
|
|
||||||
|
(import_statement
|
||||||
|
(identifier) @variable)
|
||||||
|
|
||||||
|
(import_as
|
||||||
|
(identifier) @variable)
|
||||||
|
|
||||||
|
[
|
||||||
|
"if"
|
||||||
|
"else"
|
||||||
|
"endif"
|
||||||
|
"elif"
|
||||||
|
] @keyword.conditional
|
||||||
|
|
||||||
|
[
|
||||||
|
"for"
|
||||||
|
"in"
|
||||||
|
"continue"
|
||||||
|
"break"
|
||||||
|
"endfor"
|
||||||
|
] @keyword.repeat
|
||||||
|
|
||||||
|
"call" @function.call
|
||||||
|
|
||||||
|
(function_call
|
||||||
|
(identifier) @function.call)
|
||||||
|
|
||||||
|
(arg
|
||||||
|
(identifier) @variable.parameter)
|
||||||
|
|
||||||
|
(arg
|
||||||
|
(expression
|
||||||
|
(binary_expression
|
||||||
|
(unary_expression
|
||||||
|
(primary_expression
|
||||||
|
(identifier) @variable.parameter)))))
|
||||||
|
|
||||||
|
(expression
|
||||||
|
"."
|
||||||
|
(expression)+ @variable.member)
|
||||||
|
|
||||||
|
(assignment_expression
|
||||||
|
"."
|
||||||
|
(identifier)+ @variable.member)
|
||||||
|
|
||||||
|
(inline_trans
|
||||||
|
"_" @function.builtin)
|
||||||
|
|
||||||
|
"debug" @function.builtin
|
||||||
|
|
||||||
|
(raw_end) @keyword
|
||||||
|
|
||||||
|
(raw_body) @markup.raw.block @nospell
|
||||||
|
|
||||||
|
(builtin_test
|
||||||
|
[
|
||||||
|
"boolean"
|
||||||
|
"even"
|
||||||
|
"in"
|
||||||
|
"mapping"
|
||||||
|
"sequence"
|
||||||
|
"callable"
|
||||||
|
"integer"
|
||||||
|
"ne"
|
||||||
|
"string"
|
||||||
|
"defined"
|
||||||
|
"filter"
|
||||||
|
"iterable"
|
||||||
|
"none"
|
||||||
|
"test"
|
||||||
|
"divisibleby"
|
||||||
|
"float"
|
||||||
|
"le"
|
||||||
|
"number"
|
||||||
|
"eq"
|
||||||
|
"ge"
|
||||||
|
"lower"
|
||||||
|
"odd"
|
||||||
|
"undefined"
|
||||||
|
"escaped"
|
||||||
|
"gt"
|
||||||
|
"lt"
|
||||||
|
"sameas"
|
||||||
|
"upper"
|
||||||
|
] @keyword.operator)
|
||||||
2
queries/jinja_inline/injections.scm
Normal file
2
queries/jinja_inline/injections.scm
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue