feat(tree-sitter): add ts to open/close all

also refactor +fold-open-all, +fold-close-all to use cond instead of the
when case for vimish fold.
This commit is contained in:
Jeetaditya Chatterjee 2021-10-28 15:07:03 +01:00
parent c3e360eeaa
commit 7b9d00d661
No known key found for this signature in database
GPG key ID: 09D54CECD2132B91

View file

@ -109,18 +109,20 @@ Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds."
"Open folds at LEVEL (or all folds if LEVEL is nil)."
(interactive
(list (if current-prefix-arg (prefix-numeric-value current-prefix-arg))))
(when (featurep 'vimish-fold)
(vimish-fold-unfold-all))
(save-excursion
(+fold--ensure-hideshow-mode)
(if (integerp level)
(progn
(outline-hide-sublevels (max 1 (1- level)))
(hs-life-goes-on
(hs-hide-level-recursive (1- level) (point-min) (point-max))))
(hs-show-all)
(when (fboundp 'outline-show-all)
(outline-show-all)))))
(cond ((+fold--ts-fold-p)
(ts-fold-open-all))
((featurep 'vimish-fold)
(vimish-fold-unfold-all))
(t (save-excursion
(+fold--ensure-hideshow-mode)
(if (integerp level)
(progn
(outline-hide-sublevels (max 1 (1- level)))
(hs-life-goes-on
(hs-hide-level-recursive (1- level) (point-min) (point-max))))
(hs-show-all)
(when (fboundp 'outline-show-all)
(outline-show-all)))))))
;;;###autoload
(defun +fold/close-all (&optional level)
@ -128,13 +130,15 @@ Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds."
(interactive
(list (if current-prefix-arg (prefix-numeric-value current-prefix-arg))))
(save-excursion
(when (featurep 'vimish-fold)
(vimish-fold-refold-all))
(+fold--ensure-hideshow-mode)
(hs-life-goes-on
(if (integerp level)
(hs-hide-level-recursive (1- level) (point-min) (point-max))
(hs-hide-all)))))
(cond ((+fold--ts-fold-p)
(ts-fold-close-all))
(t (when (featurep 'vimish-fold)
(vimish-fold-refold-all))
(+fold--ensure-hideshow-mode)
(hs-life-goes-on
(if (integerp level)
(hs-hide-level-recursive (1- level) (point-min) (point-max))
(hs-hide-all)))))))
;;;###autoload
(defun +fold/next (count)