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 for markers in folding #81

Open
amigrave opened this issue Feb 17, 2017 · 3 comments
Open

Support for markers in folding #81

amigrave opened this issue Feb 17, 2017 · 3 comments

Comments

@amigrave
Copy link

Sometimes I have portions of code that I would like to be folded as such as classes and functions.
For this, I use the vim's markers that are supported by Python-Syntax-Folding. eg:

# {{{ My big dictionary
dic = {
[...]
}
# }}}

I prefer this opt-in method because I don't want all dictionnaries to be folded, besides it allows me to allow folding on any type of code.

Note that Python-Syntax-Folding shows the text of the maker line in the fold so it can also serve as documentation for the folding:

I'd like to use python-syntax because it supports python3 syntax but the problem is that it does not support folding so I'm trying SimpylFold and this is the only lack of feature that prevent me to switch.

I think that adding support for markers in SimpylFold would provide a work around to the specific use cases requests that are reported by your users many times.

@nfnty
Copy link
Collaborator

nfnty commented Feb 17, 2017

I'm not sure about this, and would need opinions on what the best implementation would look like as I have no interest in this feature myself. And the implementation could get quite hairy and non-performant due to the way this plugin works.

The only other issue that I can see this would really solve is #50. As the others want automated folding.

PS. hdima/python-syntax has been forked with a lot of new features and Python 3.6 support over at python-vim/python-syntax.

@tmhedberg
Copy link
Owner

My opinion is that this feature is probably out of scope for what this plugin should do. I do understand the utility of what you're asking for, but I don't actually see demand for this specific feature; that is, marker-based dictionary folding combined with automatic folding for classes and functions. I think the ratio of general usage to added complexity would be too low to make it worthwhile. Folding dictionaries automatically may be worthy of more discussion, though, since that is a somewhat common request.

@Shados
Copy link

Shados commented Oct 31, 2018

@tmhedberg Amusingly, I've come to also want this feature, but from the other direction -- I have written a lot of Python code extensively using manual fold markers, but would like to also have function and class folding on occasion.

Fold markers are good for much more than simply folding lengthy dictionaries and lists, including:

  • Visually eliding away boilerplate, 'magic number' definitions, and anything else that distracts from the 'meat' of the code.
  • Providing some semantic structure in situations where breaking something down into individual functions or methods wouldn't work well.
  • Grouping sections of code that you intend to break out into independent functions later.

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

No branches or pull requests

4 participants