From eeca6cd891564f14224f078578983e6ebf9553fa Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 9 Mar 2024 01:35:39 +0300 Subject: feat(emacs-pkgs/treecrumbs): support "JSON-style" YAML syntax 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 Autosubmit: tazjin Tested-by: BuildkiteCI --- tools/emacs-pkgs/treecrumbs/treecrumbs.el | 19 ++++++++++++------- 1 file 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.") -- cgit 1.4.1