rust-lang / rls

Repository for the Rust Language Server (aka RLS)
Other
3.51k stars 257 forks source link

Code folding support #1615

Open LukeMauldin opened 4 years ago

LukeMauldin commented 4 years ago

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

kotauskas commented 4 years ago

Well, folding in VSCode works for me.

LukeMauldin commented 4 years ago

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

kotauskas commented 4 years ago

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.

LukeMauldin commented 4 years ago

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?

norru commented 4 years ago

Is code folding implemented in VSC or in RLS though?

jhpratt commented 4 years ago

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

kotauskas commented 4 years ago

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.

bestia-dev commented 4 years ago

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 commented 4 years ago

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