nvim-treesitter-pyfold icon indicating copy to clipboard operation
nvim-treesitter-pyfold copied to clipboard

More fine-grained folding: function call, if else, for loop.

Open lkhphuc opened this issue 2 years ago • 4 comments

Hi, thanks for the nice plugin.

Currently the the fold only goes down to the function/method doc or body. However I sometime misses the fold the inside the body of a method provided by treesitter, e.g folding long function call, internal if/else or for loop logic.

I suppose the current behavior is a design choice to avoid over-folding, but could you consider support finer folding as wellj possibly as an configurable option?

Screenshot 2022-07-10 at 13 13 27

lkhphuc avatar Jul 10 '22 12:07 lkhphuc

Sure, this is possible but that's just very much the default behaviour of tree-sitter folding, I'm not sure how this would differ from that?

P.s. how did you get syntax highlighting on folded lines?

eddiebergman avatar Jul 11 '22 06:07 eddiebergman

You can see what I've commented out here in the fold.scm to get an idea of what's in the normal tree-sitter folds. All this plugin does it just make some custom ones and comment those out.

eddiebergman avatar Jul 11 '22 07:07 eddiebergman

Thanks, I will take a look. What I like about this pluging is the proper grouping of the multiline function definition with the summary sentence, plus separate folding of doc. That would be great addition on top of base treesitter.

P.s. how did you get syntax highlighting on folded lines?

I use this recent plugin https://github.com/kevinhwang91/nvim-ufo

lkhphuc avatar Jul 11 '22 09:07 lkhphuc

Hmm, I could probably extend this at somepoint but I'm not sure how to make it into a nice API, feel free to make a PR if you have the time.

And thanks for the link, I should check it out :)

eddiebergman avatar Jul 11 '22 12:07 eddiebergman