mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
fix(language/yaml): define custom tree-sitter queries
The upstream queries have been modified causing a dramatic change to the visual coloring of syntax highlighting of YAML files when using tree-sitter-mode. Hence I'm here setting custom highlight queries that work my preferred way.
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user