diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2023-06-12 09:54:30 -0600 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2025-05-12 18:43:40 +0200 |
| commit | 692b051b09935653befdb8f7ba8afdb640adf17b (patch) | |
| tree | 167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/gotmpl | |
| parent | feat(c-family): inherit injections (diff) | |
| download | nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2 nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip | |
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/gotmpl')
| -rw-r--r-- | runtime/queries/gotmpl/folds.scm | 8 | ||||
| -rw-r--r-- | runtime/queries/gotmpl/highlights.scm | 133 | ||||
| -rw-r--r-- | runtime/queries/gotmpl/injections.scm | 31 | ||||
| -rw-r--r-- | runtime/queries/gotmpl/locals.scm | 12 |
4 files changed, 184 insertions, 0 deletions
diff --git a/runtime/queries/gotmpl/folds.scm b/runtime/queries/gotmpl/folds.scm new file mode 100644 index 000000000..f3a22e90c --- /dev/null +++ b/runtime/queries/gotmpl/folds.scm @@ -0,0 +1,8 @@ +[ + (if_action) + (range_action) + (block_action) + (with_action) + (define_action) + (comment) +] @fold diff --git a/runtime/queries/gotmpl/highlights.scm b/runtime/queries/gotmpl/highlights.scm new file mode 100644 index 000000000..4ee768c28 --- /dev/null +++ b/runtime/queries/gotmpl/highlights.scm @@ -0,0 +1,133 @@ +; Priorities of the highlight queries are raised, so that they overrule the +; often surrounding and overlapping highlights from the non-gotmpl injections. +; +; Identifiers +([ + (field) + (field_identifier) +] @variable.member + (#set! priority 110)) + +((variable) @variable + (#set! priority 110)) + +; Function calls +(function_call + function: (identifier) @function + (#set! priority 110)) + +(method_call + method: (selector_expression + field: (field_identifier) @function + (#set! priority 110))) + +; Builtin functions +(function_call + function: (identifier) @function.builtin + (#set! priority 110) + (#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 + (#set! priority 110)) + +; Delimiters +([ + "." + "," +] @punctuation.delimiter + (#set! priority 110)) + +([ + "{{" + "}}" + "{{-" + "-}}" + ")" + "(" +] @punctuation.bracket + (#set! priority 110)) + +; Actions +(if_action + [ + "if" + "else" + "else if" + "end" + ] @keyword.conditional + (#set! priority 110)) + +(range_action + [ + "range" + "else" + "end" + ] @keyword.repeat + (#set! priority 110)) + +(template_action + "template" @function.builtin + (#set! priority 110)) + +(block_action + [ + "block" + "end" + ] @keyword.directive + (#set! priority 110)) + +(define_action + [ + "define" + "end" + ] @keyword.directive.define + (#set! priority 110)) + +(with_action + [ + "with" + "else" + "end" + ] @keyword.conditional + (#set! priority 110)) + +; Literals +([ + (interpreted_string_literal) + (raw_string_literal) +] @string + (#set! priority 110)) + +((rune_literal) @string.special.symbol + (#set! priority 110)) + +((escape_sequence) @string.escape + (#set! priority 110)) + +([ + (int_literal) + (imaginary_literal) +] @number + (#set! priority 110)) + +((float_literal) @number.float + (#set! priority 110)) + +([ + (true) + (false) +] @boolean + (#set! priority 110)) + +((nil) @constant.builtin + (#set! priority 110)) + +((comment) @comment @spell + (#set! priority 110)) diff --git a/runtime/queries/gotmpl/injections.scm b/runtime/queries/gotmpl/injections.scm new file mode 100644 index 000000000..3cfc26361 --- /dev/null +++ b/runtime/queries/gotmpl/injections.scm @@ -0,0 +1,31 @@ +((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")) diff --git a/runtime/queries/gotmpl/locals.scm b/runtime/queries/gotmpl/locals.scm new file mode 100644 index 000000000..528e9fabb --- /dev/null +++ b/runtime/queries/gotmpl/locals.scm @@ -0,0 +1,12 @@ +[ + (if_action) + (range_action) + (block_action) + (with_action) + (define_action) +] @local.scope + +(variable_definition + variable: (variable) @local.definition.var) + +(variable) @local.reference |
