I have checked that this feature is not already implemented
Use case
Code organization within the file doesn't always follow blocks semantics: sometimes it's nice to group a few methods together inside a class, or name a few top-level methods, etc.
Description
VS Code supports folding regions based on comments, but Ruby doesn't seem to use any of the comment styles on that page, and the supported folding feature doesn't mention an alternative comment style.
Implementation
RubyLsp::Listeners::FoldingRanges should be extended to notice region comments.
I'd suggest we follow the other languages and use the format # region Name.
- The leading space should be optional (
#region and # region should both work)
- The name is optional (
# region and # region Section should both work)
- You should be able to do an arbitrary number of
# up front (so # region and ######### region should both work)
If there's some format that could match RDoc or YARD style (# @region?), that'd be a good alternative, too.
I have checked that this feature is not already implemented
Use case
Code organization within the file doesn't always follow blocks semantics: sometimes it's nice to group a few methods together inside a class, or name a few top-level methods, etc.
Description
VS Code supports folding regions based on comments, but Ruby doesn't seem to use any of the comment styles on that page, and the supported folding feature doesn't mention an alternative comment style.
Implementation
RubyLsp::Listeners::FoldingRangesshould be extended to notice region comments.I'd suggest we follow the other languages and use the format
# region Name.#regionand# regionshould both work)# regionand# region Sectionshould both work)#up front (so# regionand######### regionshould both work)If there's some format that could match RDoc or YARD style (
# @region?), that'd be a good alternative, too.