Skip to content

support for outshine mode #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jave opened this issue Apr 15, 2025 · 6 comments · Fixed by #87
Closed

support for outshine mode #82

jave opened this issue Apr 15, 2025 · 6 comments · Fixed by #87
Labels
feature request Request for new functionality good first issue Good for newcomers

Comments

@jave
Copy link

jave commented Apr 15, 2025

I like using outshine mode in clojure-mode buffers, but folding doesnt appear to work in clojure-ts mode.

https://github.com/alphapapa/outshine

@bbatsov bbatsov added the feature request Request for new functionality label Apr 15, 2025
@bbatsov
Copy link
Member

bbatsov commented Apr 17, 2025

Seems that's some extension of the built-in outline-mode. Probably we haven't implemented properly the support for outline, as I doubt outshine requires something special. Should be an easy task.

@bbatsov bbatsov added the good first issue Good for newcomers label Apr 17, 2025
@rrudakov
Copy link
Contributor

FYI, we need to define proper value for treesit-outline-predicate. From the documentation:

treesit-outline-predicate is a variable defined in ‘treesit.el’.

Its value is ‘treesit-outline-predicate--from-imenu’

Predicate used to find outline headings in the syntax tree.
The predicate can be a function, a regexp matching node type,
and more; see docstring of ‘treesit-thing-settings’.
It matches the nodes located on lines with outline headings.
Intended to be set by a major mode.  When nil, the predicate
is constructed from the value of ‘treesit-simple-imenu-settings’
when a major mode sets it.

@bbatsov
Copy link
Member

bbatsov commented Apr 17, 2025

Yeah, that's what I figured as well.

@rrudakov
Copy link
Contributor

treesit.el sets treesit-outline-predicate automatically based on imenu settings, so if I execute M-x outline-cycle in clojure-ts-mode buffer when point is on function or var definition, it hides the content correctly:

Image
Image

In clojure-mode it works differently, there we set 2 buffer local variables:

(setq-local outline-regexp ";;;;* ")
(setq-local outline-level 'lisp-outline-level)

Which allows hiding buffer content based on comments starting from 4 and more semicolons. M-x outline-cycle doesn't fold def-like forms in clojure-mode.

I don't think it's possible to set treesit-outline-predicate to fold special comments, any comment in the syntax tree is just a (comment) node, no matter how many semicolons are there. To calculate outline depth treesit.el just counts how many parent nodes does the current node have, but (comment) node, which is supposed to be outline heading is always top-level.

What is the desired behavior of outline-minor-mode for clojure-ts-mode? We can leave default treesit-based settings and fold forms based on imenu, or we can just use the same settings as clojure-mode to fold comments.

@rrudakov
Copy link
Contributor

We can also add a customization option, something like clojure-ts-outline-variant with 2 values, imenu or comments. WDYT?

rrudakov added a commit to rrudakov/clojure-ts-mode that referenced this issue Apr 25, 2025
@bbatsov
Copy link
Member

bbatsov commented Apr 25, 2025

Yeah, this seems like a reasonable approach to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for new functionality good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants