omnisharp-vim icon indicating copy to clipboard operation
omnisharp-vim copied to clipboard

WIP: Provide folding support

Open nickspoons opened this issue 4 years ago • 6 comments

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
  • [x] Add g:OmniSharp_fold_kinds variable, default to ['class', 'property', 'method'], allowing users control over what they want folded.

Closes #610

nickspoons avatar Jul 18 '20 02:07 nickspoons

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

nickspoons avatar Jul 18 '20 02:07 nickspoons

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 avatar Jul 19 '20 22:07 nickspoons

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

DasOhmoff avatar Jul 31 '21 07:07 DasOhmoff

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...

nickspoons avatar Jul 31 '21 08:07 nickspoons

I am watching attentively.

DasOhmoff avatar Aug 08 '21 20:08 DasOhmoff

Hey, I am still watching 👀 Please merge :)

DasOhmoff avatar Mar 26 '22 16:03 DasOhmoff