diff --git a/modules/languages/siren-yaml.el b/modules/languages/siren-yaml.el index 366763d..8e80d5b 100644 --- a/modules/languages/siren-yaml.el +++ b/modules/languages/siren-yaml.el @@ -47,7 +47,41 @@ or *.yaml file in a .github/workflows/ directory." :preface (defun siren-yaml-mode-setup () (run-hooks 'prog-mode-hook) - (setq-local tab-width 2)) + (setq-local tab-width 2) + + ;; Manually set custom queries for tree-sitter mode, as I don't like the + ;; default queries now treating all keys as properties rather than + ;; variables, giving them the wrong syntax highlighting color. + (setq-local tree-sitter-hl-default-patterns + [;; keys + (block_mapping_pair + key: (flow_node [(double_quote_scalar) (single_quote_scalar)] @variable)) + (block_mapping_pair + key: (flow_node (plain_scalar (string_scalar) @variable))) + + ;; keys within inline {} blocks + (flow_mapping + (_ key: (flow_node [(double_quote_scalar) (single_quote_scalar)] @variable))) + (flow_mapping + (_ key: (flow_node (plain_scalar (string_scalar) @variable)))) + + ["[" "]" "{" "}"] @punctuation.bracket + ["," "-" ":" "?" ">" "|"] @punctuation.delimiter + ["*" "&" "---" "..."] @punctuation.special + + [(null_scalar) (boolean_scalar)] @constant.builtin + [(integer_scalar) (float_scalar)] @number + [(double_quote_scalar) (single_quote_scalar) (block_scalar)] @string + (escape_sequence) @escape + + (comment) @comment + [(anchor_name) (alias_name)] @function + (yaml_directive) @type + + (tag) @type + (tag_handle) @type + (tag_prefix) @string + (tag_directive) @property ])) :config (siren-flycheck-setup-yaml-actionlint))