This patch introduces basic textDocument/foldingRange support. It relies on
textDocument/documentSymbols to collect all symbols and uses takes ranges
to create folds.
The next steps for textDocument/foldingRange support would be:
- Implementing FoldingRangeClientCapabilities and respecting respect client preferences
- Specifying folding range kind
- Migrating from DocumentSymbol implementation to custom RecursiveASTVisitor flow that will allow more flexibility
- Supporting more folding range types: comments, PP conditional regions, includes and other code regions (e.g. public/private/protected sections of classes, control flow statement bodies)
Tested: (Neo)Vim (coc-clangd) and VSCode.
Related issue: https://github.com/clangd/clangd/issues/310
this should return (as callback) vector<FoldingRange>.
You got unlucky: it's sandwiched between onDocumentSymbol and onCodeAction which both have to be dynamically typed as they return different structures depending on capabilities.