diff options
| author | qvalentin <valentin.theodor@web.de> | 2024-02-04 11:23:23 +0100 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2024-03-03 13:09:20 +0100 |
| commit | 9e1f3c336940e77adee81ca340e1bf0635e655f3 (patch) | |
| tree | 3c783bccab8ef3e024d8fb6b5ab7c1536e0853ed /queries/gotmpl | |
| parent | bot(lockfile): update arduino, gpg, sourcepawn, ssh_config, vue, wing (diff) | |
| download | nvim-treesitter-9e1f3c336940e77adee81ca340e1bf0635e655f3.tar nvim-treesitter-9e1f3c336940e77adee81ca340e1bf0635e655f3.tar.gz nvim-treesitter-9e1f3c336940e77adee81ca340e1bf0635e655f3.tar.bz2 nvim-treesitter-9e1f3c336940e77adee81ca340e1bf0635e655f3.tar.lz nvim-treesitter-9e1f3c336940e77adee81ca340e1bf0635e655f3.tar.xz nvim-treesitter-9e1f3c336940e77adee81ca340e1bf0635e655f3.tar.zst nvim-treesitter-9e1f3c336940e77adee81ca340e1bf0635e655f3.zip | |
feat: add gotemplate and helm parser support
Diffstat (limited to 'queries/gotmpl')
| -rw-r--r-- | queries/gotmpl/highlights.scm | 108 | ||||
| -rw-r--r-- | queries/gotmpl/injections.scm | 34 |
2 files changed, 142 insertions, 0 deletions
diff --git a/queries/gotmpl/highlights.scm b/queries/gotmpl/highlights.scm new file mode 100644 index 000000000..e1629f816 --- /dev/null +++ b/queries/gotmpl/highlights.scm @@ -0,0 +1,108 @@ +; Identifiers +[ + (field) + (field_identifier) +] @variable.member + +(variable) @variable + +; Function calls +(function_call + function: (identifier) @function) + +(method_call + method: + (selector_expression + field: (field_identifier) @function)) + +; Builtin functions +(function_call + function: (identifier) @function.builtin + (#any-of? @function.builtin + "and" "call" "html" "index" "slice" "js" "len" "not" "or" "print" "printf" "println" "urlquery" + "eq" "ne" "lt" "ge" "gt" "ge")) + +; Operators +[ + "|" + ":=" +] @operator + +; Delimiters +[ + "." + "," +] @punctuation.delimiter + +[ + "{{" + "}}" + "{{-" + "-}}" + ")" + "(" +] @punctuation.bracket + +; Actions +(if_action + [ + "if" + "else" + "else if" + "end" + ] @keyword.conditional) + +(range_action + [ + "range" + "else" + "end" + ] @keyword.repeat) + +(template_action + "template" @function.builtin) + +(block_action + [ + "block" + "end" + ] @keyword.directive) + +(define_action + [ + "define" + "end" + ] @keyword.directive.define) + +(with_action + [ + "with" + "else" + "end" + ] @keyword.conditional) + +; Literals +[ + (interpreted_string_literal) + (raw_string_literal) +] @string + +(rune_literal) @string.special.symbol + +(escape_sequence) @string.escape + +[ + (int_literal) + (imaginary_literal) +] @number + +(float_literal) @number.float + +[ + (true) + (false) +] @boolean + +(nil) @constant.builtin + +(comment) @comment @spell diff --git a/queries/gotmpl/injections.scm b/queries/gotmpl/injections.scm new file mode 100644 index 000000000..787ca9925 --- /dev/null +++ b/queries/gotmpl/injections.scm @@ -0,0 +1,34 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; {{"put" | printf "%s%s" "out" | printf "%q"}} +(function_call + function: (identifier) @_function + arguments: + (argument_list + . + (interpreted_string_literal) @injection.content) + (#eq? @_function "printf") + (#set! injection.language "printf")) + +; {{ js "var a = 1 + 1" }} +(function_call + function: (identifier) @_function + arguments: + (argument_list + . + (interpreted_string_literal) @injection.content) + (#eq? @_function "js") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "javascript")) + +; {{ html "<h1>hello</h1>" }} +(function_call + function: (identifier) @_function + arguments: + (argument_list + . + (interpreted_string_literal) @injection.content) + (#eq? @_function "html") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "html")) |
