gleam-lang/gleam

LSP: Allow for folding documentation in code editors

Open

#5,813 opened on Jun 5, 2026

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Rust (21,417 stars) (960 forks)batch import
help wanted

Description

Similar to the feature that allows for code editors to collapse the contents of a function.

Telling the code editor about which sections of the code can be folded and which can't is the LSP's job, and so the issue is made here.

Implementation idea

Note: I'm not at all familiar with the inner workings of the LSP protocol, so take everything I say here with a healthy pinch of salt

Make the LSP keep track of the beginning and end of code documentation (module-level documentation marked by ////, and type and function documentation marked by ///), and communicate this information to the code editor through textDocument/foldingRange.

Since documentation is already kept track of by the LSP (since it can communicate this to the user through hovering over function calls and type constructions), it should be quite simple to implement.

Contributor guide