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

WIP: Provide folding support #614

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

nickspoons
Copy link
Member

@nickspoons nickspoons commented Jul 18, 2020

This PR adds command :OmniSharpFold to provide OmniSharp-roslyn backed folding, using a /v2/codestructure call to find all ranges in the file, and then build folds based on these.

Currently any range >= &foldminlines will have a fold created.

The /v2/codestructure endpoint doesn't include comment blocks, but these can be easily found by checking the lines above structural elements.

To do:

  • Add g:OmniSharp_fold_include_comments variable (default to 1) and add comment-matching functionality
  • Add g:OmniSharp_fold_kinds variable, default to ['class', 'property', 'method'], allowing users control over what they want folded.

Closes #610

@nickspoons
Copy link
Member Author

@Melandel how does this look to you? Will this provide the functionality you're imagining? And enough flexibility?

@nickspoons
Copy link
Member Author

There are some problems here that need to be addressed, as discussed with @Melandel in slack.

Take this function signature:

      public void SomeMethod() {

When this is folded (with the default Vim 'foldtext'), it looks like this:

+---  5 lines: public void SomeMethod() {---------------

This is fine. But if the function has an attribute, then:

      [Fact]
      public void SomeTest() {

becomes

+---  6 lines: [Fact]-----------------------------------

which is not helpful.

There are 2 ways to deal with this, that I can see:

  1. Excluded attributes from the fold.
  2. Overwrite 'foldtext' with a custom expression which includes the method signature

The problem with 2. is that this is annoying to users who have custom 'foldtext' expressions already, because suddenly their folds are different in .cs files to the rest of their environment.

All of this also applies to comments. We could potentially fold them all individually, but that is a bit silly for attributes which are only a single line:

+---  3 lines: <summary>--------------------------------
+---  1 line: [Fact]------------------------------------
+---  5 lines: public void SomeMethod() {---------------

I'm not quite sure which way to go at the moment, I'll try some things out and see. Feedback appreciated!

@nickspoons nickspoons force-pushed the folds branch 3 times, most recently from bc33c92 to aaae959 Compare July 21, 2020 02:18
@DasOhmoff
Copy link

DasOhmoff commented Jul 31, 2021

This feature seems very nice! Is it still being worked on?

@nickspoons
Copy link
Member Author

Ah, no not really 😅

I got stuck with how to manage fold text and somehow never got past it. Just over a year later though, I really should give this another look...

@DasOhmoff
Copy link

I am watching attentively.

@DasOhmoff
Copy link

Hey, I am still watching 👀 Please merge :)

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

Successfully merging this pull request may close these issues.

[Feature Request] Add support for folding members
2 participants