diff options
| author | uncenter <uncenter@uncenter.dev> | 2025-03-09 13:44:59 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-09 18:44:59 +0100 |
| commit | f840ab9f72f8bce3489e731b34a123cb5c25ca87 (patch) | |
| tree | 304af4a5dafebcfffb3a709f46e1be3fd1204cb3 /queries | |
| parent | bot(lockfile): update ocaml, ocaml_interface, ocamllex (diff) | |
| download | nvim-treesitter-f840ab9f72f8bce3489e731b34a123cb5c25ca87.tar nvim-treesitter-f840ab9f72f8bce3489e731b34a123cb5c25ca87.tar.gz nvim-treesitter-f840ab9f72f8bce3489e731b34a123cb5c25ca87.tar.bz2 nvim-treesitter-f840ab9f72f8bce3489e731b34a123cb5c25ca87.tar.lz nvim-treesitter-f840ab9f72f8bce3489e731b34a123cb5c25ca87.tar.xz nvim-treesitter-f840ab9f72f8bce3489e731b34a123cb5c25ca87.tar.zst nvim-treesitter-f840ab9f72f8bce3489e731b34a123cb5c25ca87.zip | |
feat(tera): add parser and queries
Diffstat (limited to 'queries')
| -rw-r--r-- | queries/tera/highlights.scm | 153 | ||||
| -rw-r--r-- | queries/tera/injections.scm | 7 |
2 files changed, 160 insertions, 0 deletions
diff --git a/queries/tera/highlights.scm b/queries/tera/highlights.scm new file mode 100644 index 000000000..f41ad826f --- /dev/null +++ b/queries/tera/highlights.scm @@ -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) diff --git a/queries/tera/injections.scm b/queries/tera/injections.scm new file mode 100644 index 000000000..394142081 --- /dev/null +++ b/queries/tera/injections.scm @@ -0,0 +1,7 @@ +(frontmatter + (content) @injection.content + (#set! injection.language "yaml") + (#set! injection.combined)) + +((comment_tag) @injection.content + (#set! injection.language "comment")) |
