mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 19:00:02 -04:00
feat(tera): add parser and queries
This commit is contained in:
parent
59573f9616
commit
f840ab9f72
4 changed files with 171 additions and 0 deletions
|
|
@ -806,6 +806,9 @@
|
||||||
"templ": {
|
"templ": {
|
||||||
"revision": "def9849184de71a797c4e2b2837df85abeccf92c"
|
"revision": "def9849184de71a797c4e2b2837df85abeccf92c"
|
||||||
},
|
},
|
||||||
|
"tera": {
|
||||||
|
"revision": "ae37c8f0e55b3b969caf5433940553374c87430c"
|
||||||
|
},
|
||||||
"terraform": {
|
"terraform": {
|
||||||
"revision": "9e3ec9848f28d26845ba300fd73c740459b83e9b"
|
"revision": "9e3ec9848f28d26845ba300fd73c740459b83e9b"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -2325,6 +2325,14 @@ list.tcl = {
|
||||||
maintainers = { "@lewis6991" },
|
maintainers = { "@lewis6991" },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.tera = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/uncenter/tree-sitter-tera",
|
||||||
|
files = { "src/parser.c", "src/scanner.c" },
|
||||||
|
},
|
||||||
|
maintainers = { "@uncenter" },
|
||||||
|
}
|
||||||
|
|
||||||
list.terraform = {
|
list.terraform = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/MichaHoffmann/tree-sitter-hcl",
|
url = "https://github.com/MichaHoffmann/tree-sitter-hcl",
|
||||||
|
|
|
||||||
153
queries/tera/highlights.scm
Normal file
153
queries/tera/highlights.scm
Normal file
|
|
@ -0,0 +1,153 @@
|
||||||
|
; Variables
|
||||||
|
;----------
|
||||||
|
(identifier) @variable
|
||||||
|
|
||||||
|
((identifier) @variable.builtin
|
||||||
|
(#any-of? @variable.builtin "loop" "__tera_context"))
|
||||||
|
|
||||||
|
; Properties
|
||||||
|
;-----------
|
||||||
|
(member_expression
|
||||||
|
property: (identifier)? @variable.member)
|
||||||
|
|
||||||
|
; Literals
|
||||||
|
;-----------
|
||||||
|
(string) @string
|
||||||
|
|
||||||
|
(bool) @boolean
|
||||||
|
|
||||||
|
(number) @number
|
||||||
|
|
||||||
|
; Tokens
|
||||||
|
;-----------
|
||||||
|
[
|
||||||
|
"."
|
||||||
|
","
|
||||||
|
"::"
|
||||||
|
(frontmatter_delimiter)
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
[
|
||||||
|
"*"
|
||||||
|
"/"
|
||||||
|
"%"
|
||||||
|
"|"
|
||||||
|
"+"
|
||||||
|
"-"
|
||||||
|
"~"
|
||||||
|
"="
|
||||||
|
"=="
|
||||||
|
"!="
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
"<="
|
||||||
|
">="
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"{%"
|
||||||
|
"%}"
|
||||||
|
"-%}"
|
||||||
|
"{%-"
|
||||||
|
"}}"
|
||||||
|
"{{"
|
||||||
|
"-}}"
|
||||||
|
"{{-"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
; Tags
|
||||||
|
;-----------
|
||||||
|
(comment_tag) @comment @spell
|
||||||
|
|
||||||
|
; Keywords
|
||||||
|
;-----------
|
||||||
|
[
|
||||||
|
"if"
|
||||||
|
"elif"
|
||||||
|
"else"
|
||||||
|
"endif"
|
||||||
|
] @keyword.conditional
|
||||||
|
|
||||||
|
[
|
||||||
|
"for"
|
||||||
|
"endfor"
|
||||||
|
] @keyword.repeat
|
||||||
|
|
||||||
|
[
|
||||||
|
"include"
|
||||||
|
"import"
|
||||||
|
"extends"
|
||||||
|
] @keyword.import
|
||||||
|
|
||||||
|
[
|
||||||
|
"in"
|
||||||
|
"and"
|
||||||
|
"or"
|
||||||
|
"not"
|
||||||
|
"is"
|
||||||
|
] @keyword.operator
|
||||||
|
|
||||||
|
[
|
||||||
|
"break"
|
||||||
|
"continue"
|
||||||
|
] @keyword.return
|
||||||
|
|
||||||
|
[
|
||||||
|
"set"
|
||||||
|
"set_global"
|
||||||
|
"filter"
|
||||||
|
"endfilter"
|
||||||
|
"block"
|
||||||
|
"endblock"
|
||||||
|
"macro"
|
||||||
|
"endmacro"
|
||||||
|
"raw"
|
||||||
|
"endraw"
|
||||||
|
"as"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
; Functions
|
||||||
|
;-----------
|
||||||
|
(macro_statement
|
||||||
|
name: (identifier) @function
|
||||||
|
(parameter_list
|
||||||
|
parameter: (identifier) @variable.parameter
|
||||||
|
(optional_parameter
|
||||||
|
name: (identifier) @variable.parameter)))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
scope: (identifier)? @module
|
||||||
|
name: (identifier) @function.call)
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
scope: (identifier) @module.builtin
|
||||||
|
name: (identifier) @function.call
|
||||||
|
(#eq? @module.builtin "self"))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
name: (identifier) @function.builtin
|
||||||
|
(#any-of? @function.builtin
|
||||||
|
; Functions - https://keats.github.io/tera/docs/#built-in-functions
|
||||||
|
"range" "now" "throw" "get_random" "get_env"))
|
||||||
|
|
||||||
|
(test_expression
|
||||||
|
test: (identifier) @function.call)
|
||||||
|
|
||||||
|
(test_expression
|
||||||
|
test: (identifier) @function.builtin
|
||||||
|
(#any-of? @function.builtin
|
||||||
|
; Tests - https://keats.github.io/tera/docs/#built-in-tests
|
||||||
|
"defined" "undefined" "odd" "even" "string" "number" "divisibleby" "iterable" "object"
|
||||||
|
"starting_with" "ending_with" "containing" "matching"))
|
||||||
|
|
||||||
|
(filter_expression
|
||||||
|
filter: (identifier) @function.method.call)
|
||||||
|
|
||||||
|
; Namespaces
|
||||||
|
;-----------
|
||||||
|
(import_statement
|
||||||
|
scope: (identifier) @module)
|
||||||
7
queries/tera/injections.scm
Normal file
7
queries/tera/injections.scm
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
(frontmatter
|
||||||
|
(content) @injection.content
|
||||||
|
(#set! injection.language "yaml")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((comment_tag) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue