Closed isamert closed 5 days ago
Is this with Emacs 30?
Yes, forgot to mention that. I am on the following:
GNU Emacs 30.0.90 (build 1, aarch64-apple-darwin23.6.0, NS appkit-2487.70 Version 14.6.1 (Build 23G93)) of 2024-08-23
Aha, hadn't seem that coming. Does setting outline-search-function
to nil
fully resolve the issue? I'm wondering if having both forms of folding would be appealing (or feasible). What do you think?
Honestly, I didn't even try what the folding provided by treesit.el
does. Now that I tried, it does the obvious, you can fold functions
etc. I did not find it very satisfactory though, at least in it's
current form. Probably I'll keep hs-minor-mode
for C-like languages
for now.
Having said that, making outli work with treesit would be nice but it may end up being confusing. When I fold the whole file, I only expect the outli outlines to be folded. Not the whole file hierarchy, with functions and all. There may be a way to handle this more gracefully but I suspect that it will be hard to do (all folding functions needs become context-aware).
But of course not integrating them means users of outli will lose the ability to fold with treesit. Currently I am fine with this but if treesit folding becomes superior and de facto way of folding files, then I might reconsider this statement :D
Does setting
outline-search-function
tonil
fully resolve the issue?
Yes, it fully resolves the issue.
That's a very good point. For now HS might still be the superior solution, but treesitter is more precise and would enable folding lots of interesting things (long data structures, for example). I wonder if HS will get treesitter support; presumably it could do this too.
In terms of outli working with tree-sitter, I think that's out of scope. But it could possibly try hard to prevent other tools which want to work with treesitter from breaking. So for example it could "composite" a search function that forms the union of the two search modalities. But then tree-sitter must set the search depth somehow too and you'd have to work around that (e.g. a top-level function inside a 3rd level # *** Heading
). Could get complicated.
I've pushed a small change to disable outline-search-function
; can you give it a test?
I wonder if HS will get treesitter support; presumably it could do this too.
Yeah I think that would be much better. It's a better fit for code folding, outline mode is, I believe, something different. HS also have more granular control over what needs to be folded etc.
In terms of outli working with tree-sitter, I think that's out of scope. [...] Could get complicated.
Makes sense.
I've pushed a small change to disable
outline-search-function
; can you give it a test?
Yep, working perfectly. Thank you!
treesit.el sets the following:
so, when you enable outli in a treesitter based major mode, typescript-ts-mode for example, the folding will not work correctly.
outli already sets
outline-level
function. It also, probably, should set theoutline-search-function
to nil while initializing the mode so that it works as expected.