omnisharp-vim
omnisharp-vim copied to clipboard
WIP: Provide folding support
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
@Melandel how does this look to you? Will this provide the functionality you're imagining? And enough flexibility?
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:
- Excluded attributes from the fold.
- 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!
This feature seems very nice! Is it still being worked on?
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...
I am watching attentively.
Hey, I am still watching 👀 Please merge :)