-
Notifications
You must be signed in to change notification settings - Fork 29
Add hierarchical DocumentSymbol support (LSP 3.10) #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Add hierarchical DocumentSymbol support (LSP 3.10) #108
Conversation
Implement dual-mode DocumentSymbol provider supporting both LSP 2.x flat mode (SymbolInformation) and LSP 3.x hierarchical mode (DocumentSymbol with children). Changes: - Add TSymbolMode enum and TSymbolBuilder class for dual-mode building - Detect client hierarchicalDocumentSymbolSupport capability during init - Build hierarchical structure with parent-child relationships - Return DocumentSymbol (with range/children) or SymbolInformation (with location/containerName) based on client capability Benefits: - Better IDE integration (Outline view shows proper nesting in VS Code) - Enables hierarchical navigation and symbol search (Class/Method paths) - Backward compatible with clients not supporting hierarchical mode - Compliant with LSP 3.10+ specification Tested with VS Code and Serena MCP, both working correctly in hierarchical mode with proper symbol nesting.
|
Merry Christmas to everyone! 🎄🎁 |
|
I see two problems here:
btw, @zen010101 do you know how much this interacts with #98? I didn't get a chance to review this and I see multiple problems with it which I think you're building on with DocumentSymbol changes. Here's at least two places where the structure is wrong and are missing their parents. I seem to be remember SublimeText showed the hierarchy as
Hmmm I just tested this in VSCode and it looks much better here so maybe that PR is working better than I thought but I still see regression in your code. It's pretty clear then we need a flat version for editors that don't support the hierarchy as well. Remember the LSP was made by Microsoft so they custom built VSCode around it and not all editors are willing to have the same UI.
|
- Reintroduce interface/implementation namespaces in hierarchical mode for proper breadcrumb navigation (flat mode unchanged) - Add nested function/procedure support in symbol hierarchy - Support program files (.lpr/.dpr) with separate symbols for type declarations and method implementation containers - Add Python integration tests for breadcrumb and Outline validation
About PR #98PR #98 attempted to add hierarchical display in flat mode by hardcoding
My PR takes a different approach: keeping flat mode unchanged while implementing proper hierarchy only in hierarchical mode (DocumentSymbol with children). About SublimeTextRegarding SublimeText compatibility: I don't currently have SublimeText installed. I'll download and test it in the coming days to ensure flat mode works correctly with the dot notation format you mentioned. Why hierarchical mode is needed
Flat mode still works for editors like SublimeText that only support flat lists. This PR keeps flat mode unchanged while adding proper hierarchical support for modern IDEs and AI-powered tools. |






Summary
Implement dual-mode DocumentSymbol provider supporting both LSP 2.x flat mode and LSP 3.x hierarchical mode, enabling better IDE integration and symbol navigation.
Changes
TSymbolModeenum andTSymbolBuilderclass for dual-mode symbol buildinghierarchicalDocumentSymbolSupportcapability during initializationDocumentSymbol(with range/children) orSymbolInformation(with location/containerName) based on client capabilityBenefits
TUser/GetFullName)Testing
Tested and verified with:
Screenshots
VS Code Outline view showing hierarchical structure:
References
This is the first PR in a series. Future work will add Property and Field symbol extraction.