rls icon indicating copy to clipboard operation
rls copied to clipboard

Code folding support

Open LukeMauldin opened this issue 5 years ago • 9 comments

Does the current version of rls support the Code Folding part of the LSP protocol?

LukeMauldin avatar Jan 15 '20 22:01 LukeMauldin

Well, folding in VSCode works for me.

kotauskas avatar Feb 05 '20 17:02 kotauskas

What delimiters did you use to get code folding to work in VSCode?

LukeMauldin avatar Feb 06 '20 03:02 LukeMauldin

I'm using the latest VSCode, latest RLS on stable-x86_64-pc-windows-msvc and latest RLS for VSCode without any other special setup.

kotauskas avatar Feb 06 '20 10:02 kotauskas

Can you paste a simple code example that demonstrates how it works? Do you use region tags? To clarify, I would like to be able to define my own regions. Is this possible?

LukeMauldin avatar Feb 06 '20 16:02 LukeMauldin

Is code folding implemented in VSC or in RLS though?

norru avatar Feb 06 '20 22:02 norru

Code folding is a VS Code feature, not RLS. However, I have been unable to get anything to work in the past with Rust.

jhpratt avatar Feb 08 '20 03:02 jhpratt

Can you paste a simple code example that demonstrates how it works? Do you use region tags? To clarify, I would like to be able to define my own regions. Is this possible?

Functional folding with RLS in VSCode Something like that. Hovering over the gutter (to the right of the line numbers) reveals the folding arrows.

kotauskas avatar Feb 08 '20 12:02 kotauskas

I understood that VSCode has its own "naive" folding functionality. It simply looks the indentation. It is universal, but it lacks syntax understanding. Then VSCode has a FoldingRangeProvider API to allow every language server to create syntax meaningful folding. Inside the code https://github.com/rust-lang/rls/blob/master/rls/src/server/mod.rs on line 460: folding_range_provider: None, I suppose it means, that it is not implemented. I would also like very much to have the // region: name, // endregion folding. It means a lot to me.

bestia-dev avatar May 05 '20 11:05 bestia-dev

I wrote a proof of concept, that can be used to return a list of "folding regions" to VS from the language server. https://github.com/LucianoBestia/region_folding

bestia-dev avatar May 27 '20 07:05 bestia-dev