Skip to content
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

Support folding long block of code by indentation? #127

Open
yxiong opened this issue Sep 23, 2021 · 4 comments
Open

Support folding long block of code by indentation? #127

yxiong opened this issue Sep 23, 2021 · 4 comments

Comments

@yxiong
Copy link

yxiong commented Sep 23, 2021

The plugin currently folds imports, docstrings and class/function definitions, but not indentation block. This works great for me in most of situations. In some cases when I deal with very long code block, I wanted to be able to fold them by indentation level. Is there a way to support that as an optional feature, or use a separate tool that integrates with this plugin?

@tmhedberg
Copy link
Owner

tmhedberg commented Sep 23, 2021

By "indentation block", do you mean the bodies of loops and conditional statements? There is no option for that currently, and I originally left it out on purpose (just because I didn't want it, personally).

I'm not strongly opposed to the idea, but Vim has built-in support for folding based on indentation level, without any plugin (:set foldmethod=indent), so I don't see much need to build custom support for this.

Does the built-in indentation-based folding work well enough for your case?

@yxiong
Copy link
Author

yxiong commented Sep 23, 2021

Yes, by "indentation block" I meant bodies of loops and conditional statements. :set foldmethod=indent works for those indentation blocks, but when I do that, I lost folding for imports and docstrings. Is there a way to use foldmethod=indent together with SimpylFold plugin, so that I can take the good part of both world?

@tmhedberg
Copy link
Owner

Unfortunately, there's not an easy way that I know of to combine multiple fold methods.

There are some partial workarounds you could try, like this tip for using indentation-based folding along with manual folding, but this has some significant drawbacks which you might not be happy with. You have to define the non-indentation-based folds manually in each file, and they won't be saved across sessions without using some tricks with :mkview/:loadview.

Basically, this functionality would have to be added to the plugin if you want it to be automatic. I'm willing to review a patch for that, if you want to send one, but I'm not likely to work on it myself.

@yxiong
Copy link
Author

yxiong commented Sep 24, 2021

I probably won't have the expertise or bandwidth to add this functionality as a pull request. So feel free to close it as "won't fix" or keep it open for future contributors, whichever you prefer.

Thanks again for all the discussion and information, @tmhedberg !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants