Make origami-treesit a proper minor mode

This commit is contained in:
Jeremy Dormitzer 2024-05-08 10:59:18 -04:00
parent d46352276a
commit 650a90b812
2 changed files with 20 additions and 5 deletions

View File

@ -114,6 +114,7 @@
:ensure nil
:load-path "packages/origami-treesit"
:after origami
:hook (origami-mode . origami-treesit-mode)
:custom
(origami-treesit-level 4))

View File

@ -199,11 +199,25 @@
(child-nodes (list value)))
(list start end offset child-nodes)))))))
(with-eval-after-load 'origami
(add-to-list 'origami-parser-alist '(yaml-ts-mode . origami-yaml-treesit-parser))
(add-to-list 'origami-parser-alist '(yaml-mode . origami-yaml-treesit-parser))
(add-to-list 'origami-parser-alist '(ruby-ts-mode . origami-ruby-treesit-parser))
(add-to-list 'origami-parser-alist '(ruby-mode . origami-ruby-treesit-parser)))
(defvar origami-treesit-parser-alist
'((yaml-ts-mode . origami-yaml-treesit-parser)
(yaml-mode . origami-yaml-treesit-parser)
(ruby-ts-mode . origami-ruby-treesit-parser)
(ruby-mode . origami-ruby-treesit-parser))
"Alist mapping major-mode to origami-treesit parser function.")
;;;###autoload
(define-minor-mode origami-treesit-mode
"Minor mode for folding code using tree-sitter."
:group 'origami
:lighter nil
:init-value nil
(if origami-treesit-mode
(setq-local origami-parser-alist
(append origami-treesit-parser-alist origami-parser-alist))
(setq-local origami-parser-alist
(-difference origami-parser-alist origami-treesit-parser-alist))))
(provide 'origami-treesit)
;;; origami-treesit.el ends here