From 8c3168d2855818847e09dd21f5edc4aacadb13a9 Mon Sep 17 00:00:00 2001 From: Oscar Najera Date: Mon, 19 Aug 2024 01:18:53 +0200 Subject: khardel imenu --- config/doom/config.org | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/doom/config.org b/config/doom/config.org index 6a2df58..8c32144 100644 --- a/config/doom/config.org +++ b/config/doom/config.org @@ -501,7 +501,14 @@ this new window. (package! khardel) #+end_src #+begin_src emacs-lisp -(use-package! khardel) +(use-package! khardel + :config + (after! tree-sitter-langs + (add-to-list 'tree-sitter-major-mode-language-alist '(khardel-edit-mode . yaml))) + (add-hook 'khardel-edit-mode-hook + (lambda () + (tree-sitter-mode) + (setq imenu-create-index-function #'on/imenu-nested-path-elements)))) #+end_src * IRC #+begin_src emacs-lisp @@ -611,9 +618,11 @@ Emacs mode for managing ledger text files (defun on/ts-elements () "Tree sitter matches for all entries in data buffer." (let ((query (thread-last - (pcase major-mode - ('json-mode "(object (pair (string (string_content) @key) (_)) @item)") - ('yaml-mode "(block_mapping_pair (flow_node) @key (_)) @item")) + (cond + ((derived-mode-p 'json-mode) + "(object (pair (string (string_content) @key) (_)) @item)") + ((derived-mode-p 'yaml-mode) + "(block_mapping_pair (flow_node) @key (_)) @item")) (tsc-make-query tree-sitter-language))) (root-node (tsc-root-node tree-sitter-tree))) (tsc-query-matches query root-node #'tsc--buffer-substring-no-properties))) -- cgit v1.2.3