diff options
author | Vincent Ambo <tazjin@tvl.su> | 2024-03-08T22·35+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-03-10T19·27+0000 |
commit | eeca6cd891564f14224f078578983e6ebf9553fa (patch) | |
tree | e7c0cf4ba6ed8a75bc0cee2aa3832c0e6840974b /tools | |
parent | 13cced5b84a8b9a246604b82d09075494f55f545 (diff) |
feat(emacs-pkgs/treecrumbs): support "JSON-style" YAML syntax r/7667
Makes crumbs work correctly for weird stuff like: ```yaml foo: - { "bar": [ { baz: 1 }]} ``` Would be nice to have tests for this at some point. Change-Id: I034e83318435404ef8613e439313dbb08865f228 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11105 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'tools')
-rw-r--r-- | tools/emacs-pkgs/treecrumbs/treecrumbs.el | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/emacs-pkgs/treecrumbs/treecrumbs.el b/tools/emacs-pkgs/treecrumbs/treecrumbs.el index 7694e6134f14..ae8abf867671 100644 --- a/tools/emacs-pkgs/treecrumbs/treecrumbs.el +++ b/tools/emacs-pkgs/treecrumbs/treecrumbs.el @@ -36,13 +36,7 @@ (require 'treesit) -(defvar treecrumbs-languages - `(;; In YAML documents, crumbs are generated from the keys of maps, - ;; and from elements of arrays. - (yaml . (("block_mapping_pair" . - ,(treesit-query-compile 'yaml '((block_mapping_pair key: (_) @key)))) - ("block_sequence_item" . "[]")))) - +(defvar treecrumbs-languages nil "Describes the tree-sitter language grammars supported by treecrumbs, and how the breadcrumbs for their node types are generated. @@ -65,6 +59,17 @@ Treecrumbs will only consider node types that are mentioned in the node type list. All other nodes are ignored when constructing the crumbs.") +(setq treecrumbs-languages + `(;; In YAML documents, crumbs are generated from the keys of maps, + ;; and from elements of arrays. + (yaml . (("block_mapping_pair" . + ,(treesit-query-compile 'yaml '((block_mapping_pair key: (_) @key)))) + ("block_sequence" . "[]") + ("flow_pair" . + ;; TODO: Why can this query not match on to (flow_pair)? + ,(treesit-query-compile 'yaml '((_) key: (_) @key))) + ("flow_sequence" . "[]"))))) + (defvar-local treecrumbs--current-crumbs nil "Current crumbs to display in the header line. Only updated when the node under point changes.") |