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/yaml | |
| 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/yaml')
| -rw-r--r-- | runtime/queries/yaml/folds.scm | 4 | ||||
| -rw-r--r-- | runtime/queries/yaml/highlights.scm | 99 | ||||
| -rw-r--r-- | runtime/queries/yaml/indents.scm | 7 | ||||
| -rw-r--r-- | runtime/queries/yaml/injections.scm | 81 | ||||
| -rw-r--r-- | runtime/queries/yaml/locals.scm | 9 |
5 files changed, 200 insertions, 0 deletions
diff --git a/runtime/queries/yaml/folds.scm b/runtime/queries/yaml/folds.scm new file mode 100644 index 000000000..c426afb87 --- /dev/null +++ b/runtime/queries/yaml/folds.scm @@ -0,0 +1,4 @@ +[ + (block_mapping_pair) + (block_sequence_item) +] @fold diff --git a/runtime/queries/yaml/highlights.scm b/runtime/queries/yaml/highlights.scm new file mode 100644 index 000000000..9aed59ce4 --- /dev/null +++ b/runtime/queries/yaml/highlights.scm @@ -0,0 +1,99 @@ +(boolean_scalar) @boolean + +(null_scalar) @constant.builtin + +(double_quote_scalar) @string + +(single_quote_scalar) @string + +((block_scalar) @string + (#set! priority 99)) + +(string_scalar) @string + +(escape_sequence) @string.escape + +(integer_scalar) @number + +(float_scalar) @number + +(comment) @comment @spell + +[ + (anchor_name) + (alias_name) +] @label + +(tag) @type + +[ + (yaml_directive) + (tag_directive) + (reserved_directive) +] @keyword.directive + +(block_mapping_pair + key: (flow_node + [ + (double_quote_scalar) + (single_quote_scalar) + ] @property)) + +(block_mapping_pair + key: (flow_node + (plain_scalar + (string_scalar) @property))) + +(flow_mapping + (_ + key: (flow_node + [ + (double_quote_scalar) + (single_quote_scalar) + ] @property))) + +(flow_mapping + (_ + key: (flow_node + (plain_scalar + (string_scalar) @property)))) + +[ + "," + "-" + ":" + ">" + "?" + "|" +] @punctuation.delimiter + +[ + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "*" + "&" + "---" + "..." +] @punctuation.special + +; help deal with for yaml's norway problem https://www.bram.us/2022/01/11/yaml-the-norway-problem/ +; only using `true` and `false`, since Treesitter parser targets YAML spec 1.2 https://github.com/nvim-treesitter/nvim-treesitter/pull/7512#issuecomment-2565397302 +(block_mapping_pair + value: (block_node + (block_sequence + (block_sequence_item + (flow_node + (plain_scalar + (string_scalar) @boolean + (#any-of? @boolean "TRUE" "FALSE" "True" "False"))))))) + +(block_mapping_pair + value: (flow_node + (plain_scalar + (string_scalar) @boolean + (#any-of? @boolean "TRUE" "FALSE" "True" "False")))) diff --git a/runtime/queries/yaml/indents.scm b/runtime/queries/yaml/indents.scm new file mode 100644 index 000000000..f7146d316 --- /dev/null +++ b/runtime/queries/yaml/indents.scm @@ -0,0 +1,7 @@ +[ + (block_mapping_pair + value: (block_node)) + (block_sequence_item) +] @indent.begin + +(ERROR) @indent.auto diff --git a/runtime/queries/yaml/injections.scm b/runtime/queries/yaml/injections.scm new file mode 100644 index 000000000..143af1924 --- /dev/null +++ b/runtime/queries/yaml/injections.scm @@ -0,0 +1,81 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; Github actions ("run") / Gitlab CI ("scripts") +; Taskfile scripts ("cmds", "cmd", "sh") +(block_mapping_pair + key: (flow_node) @_run + (#any-of? @_run "run" "script" "before_script" "after_script" "cmds" "cmd" "sh") + value: (flow_node + (plain_scalar + (string_scalar) @injection.content) + (#set! injection.language "bash"))) + +(block_mapping_pair + key: (flow_node) @_run + (#any-of? @_run "run" "script" "before_script" "after_script" "cmds" "cmd" "sh") + value: (block_node + (block_scalar) @injection.content + (#set! injection.language "bash") + (#offset! @injection.content 0 1 0 0))) + +(block_mapping_pair + key: (flow_node) @_run + (#any-of? @_run "run" "script" "before_script" "after_script" "cmds" "sh") + value: (block_node + (block_sequence + (block_sequence_item + (flow_node + (plain_scalar + (string_scalar) @injection.content)) + (#set! injection.language "bash"))))) + +(block_mapping_pair + key: (flow_node) @_run + (#any-of? @_run "script" "before_script" "after_script" "cmds" "sh") + value: (block_node + (block_sequence + (block_sequence_item + (block_node + (block_scalar) @injection.content + (#set! injection.language "bash") + (#offset! @injection.content 0 1 0 0)))))) + +; Prometheus Alertmanager ("expr") +(block_mapping_pair + key: (flow_node) @_expr + (#eq? @_expr "expr") + value: (flow_node + (plain_scalar + (string_scalar) @injection.content) + (#set! injection.language "promql"))) + +(block_mapping_pair + key: (flow_node) @_expr + (#eq? @_expr "expr") + value: (block_node + (block_scalar) @injection.content + (#set! injection.language "promql") + (#offset! @injection.content 0 1 0 0))) + +(block_mapping_pair + key: (flow_node) @_expr + (#eq? @_expr "expr") + value: (block_node + (block_sequence + (block_sequence_item + (flow_node + (plain_scalar + (string_scalar) @injection.content)) + (#set! injection.language "promql"))))) + +(block_mapping_pair + key: (flow_node) @_expr + (#eq? @_expr "expr") + value: (block_node + (block_sequence + (block_sequence_item + (block_node + (block_scalar) @injection.content + (#set! injection.language "promql") + (#offset! @injection.content 0 1 0 0)))))) diff --git a/runtime/queries/yaml/locals.scm b/runtime/queries/yaml/locals.scm new file mode 100644 index 000000000..f7c79e082 --- /dev/null +++ b/runtime/queries/yaml/locals.scm @@ -0,0 +1,9 @@ +[ + (stream) + (document) + (block_node) +] @local.scope + +(anchor_name) @local.definition + +(alias_name) @local.reference |
