rust-lang / vscode-rust

Rust extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=rust-lang.rust
Other
1.39k stars 167 forks source link

Syntax aware folding #350

Open dvdplm opened 6 years ago

dvdplm commented 6 years ago

VSCode recently gained the ability to do language-specific code folding. This is interesting for Rust for things like folding lists of extern crate, use, license headers and doc comments (which often take up a lot of space).

Is this in-scope for rls-vscode? Is it planned? It'd be very useful! :)

nrc commented 6 years ago

It is definitely in scope, but not planned in the near future (priority is a stable 1.0 release, rather than feature work). If you'd like to try and implement, I'm happy to help however is useful.

Centril commented 6 years ago

Relevant: https://stackoverflow.com/questions/46310047/is-there-any-way-to-fold-collapse-rust-documentation-comments-in-visual-studio-c/

real-felix commented 6 years ago

I know roughly how to do this, but I never contributed to such an extension project and I do not really know typescript. I can give it a try though.

real-felix commented 6 years ago

Ok, I did a first (incomplete) implementation: https://github.com/Boiethios/rls-vscode. The issue is that when I ship my own folding, it disable the previous one.

Does someone know how this works? I guess that vscode has its own default folding implementation overridden by another one. In this case, a clean and fast solution, IMHO, would be to implement the folding in RLS and call the function from the extension, just like some other functionality of the extension.

nrc commented 6 years ago

Does someone know how this works? I guess that vscode has its own default folding implementation overridden by another one.

That sounds right to me - it's often how VSCode works.

would be to implement the folding in RLS and call the function from the extension

is there support for this in the LSP? If so, this seems like a great idea. If not we'd have to think what the API looks like and whether it is worth adding another custom protocol element.

real-felix commented 6 years ago

Is there support for this in the LSP? If so, this seems like a great idea. If not we'd have to think what the API looks like and whether it is worth adding another custom protocol element.

It seems that nobody implemented this yet: https://docs.rs/lsp/0.3.1/lsp/index.html?search=fold

I guess that it will be useful to add another protocol element.

norru commented 5 years ago

@nrc @Boiethios @dvdpl Asking for a friend ;): how is code folding implemented in VSCode nowadays?

I'd like to replicate the feature in Eclipse Corrosion.

Xanewok commented 5 years ago

Document folding is now implemented in the LSP 3.10, which should be implemented by the RLS to be reused by other clients out there. https://github.com/Microsoft/language-server-protocol/issues/418