Make origami-treesit a proper minor mode
This commit is contained in:
parent
d46352276a
commit
650a90b812
@ -114,6 +114,7 @@
|
|||||||
:ensure nil
|
:ensure nil
|
||||||
:load-path "packages/origami-treesit"
|
:load-path "packages/origami-treesit"
|
||||||
:after origami
|
:after origami
|
||||||
|
:hook (origami-mode . origami-treesit-mode)
|
||||||
:custom
|
:custom
|
||||||
(origami-treesit-level 4))
|
(origami-treesit-level 4))
|
||||||
|
|
||||||
|
@ -199,11 +199,25 @@
|
|||||||
(child-nodes (list value)))
|
(child-nodes (list value)))
|
||||||
(list start end offset child-nodes)))))))
|
(list start end offset child-nodes)))))))
|
||||||
|
|
||||||
(with-eval-after-load 'origami
|
(defvar origami-treesit-parser-alist
|
||||||
(add-to-list 'origami-parser-alist '(yaml-ts-mode . origami-yaml-treesit-parser))
|
'((yaml-ts-mode . origami-yaml-treesit-parser)
|
||||||
(add-to-list 'origami-parser-alist '(yaml-mode . origami-yaml-treesit-parser))
|
(yaml-mode . origami-yaml-treesit-parser)
|
||||||
(add-to-list 'origami-parser-alist '(ruby-ts-mode . origami-ruby-treesit-parser))
|
(ruby-ts-mode . origami-ruby-treesit-parser)
|
||||||
(add-to-list 'origami-parser-alist '(ruby-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)
|
(provide 'origami-treesit)
|
||||||
;;; origami-treesit.el ends here
|
;;; origami-treesit.el ends here
|
||||||
|
Loading…
Reference in New Issue
Block a user