-
-
Notifications
You must be signed in to change notification settings - Fork 7
Add support for workspace symbols #95
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: main
Are you sure you want to change the base?
Conversation
- Add WorkspaceSymbolRequest handler registration in server.rs - Implement workspace_symbol method in lsp.rs to handle workspace symbol requests - Add workspace_symbol_provider capability in initialize response - Create find_workspace_symbols method in state.rs to collect and filter symbols from all parsed trees - Add comprehensive test for workspace symbols functionality with snapshots - Sort symbols by name and URI for consistent ordering Co-authored-by: coder3101 <22212259+coder3101@users.noreply.github.com>
|
I found that your new protols only recognizes symbols of files I have accessed, and does not actively index files that have not been accessed. |
|
Workspace symbols need full workspace parsing, similar to what references or rename capabilities, otherwise for most of other capabilities, we only parse the opened and recursively imported files. Probably, AI got this wrong and let me nudge it in the right direction or will take a look at it over the weekend. |
|
@copilot the PR looks good but it only shows the workspace symbols of opened files and files imported by it, when workspace symbols is requested we should fallback to full workspace parsing similar to rename and references. Please update the PR to take this into account. |
- Add get_workspaces() method to WorkspaceProtoConfigs to retrieve all workspace folders - Update workspace_symbol handler to parse all files from all workspaces before collecting symbols - Add progress reporting support for workspace symbol requests - Now workspace symbols work across entire workspace, not just opened files Co-authored-by: coder3101 <22212259+coder3101@users.noreply.github.com>
Updated the implementation to parse all workspace files before collecting symbols, similar to how references and rename work. The workspace_symbol method now:
Changes in commit: Will be included in the next commit message. |
|
@coder3101 new commit looks good for me, I don't know if it need some cache or something to speed up workspace symbols lookup, but it works for now, I feel good, thanks |
|
I will merge these changes after a review, thanks for confirming that it works. Caching can be a follow up if requested. |
|
I will do a commit for non functional changes over the weekend before merging. In the meantime time feel free to use this branch for your testing. |
|
Hi folks, I think this branch is not quite ready yet. I would love to finish this feature, if you know what work remains. |
|
Yes please, go ahead! |
|
Great, thank you! Do you know what work remains to be done? |
|
I believe testing is needed, simple symbol, nested symbols, across different packages etc. Apart from that some lint issue with Depending on the testing some other fixes might be needed, or else good for merge. |
Overview
This PR implements workspace symbols support for the protols LSP server, enabling clients to search for symbols across all files in the workspace. This complements the existing document symbols feature by providing a global symbol search capability.
Changes
Server Capabilities
workspace_symbol_providerto the LSP server capabilities advertised during initializationWorkspaceSymbolRequesthandler in the server routerImplementation
The implementation adds a
workspace_symbolmethod insrc/lsp.rsthat processes workspace symbol requests with query-based filtering. The method now includes full workspace parsing before symbol collection:.protofiles from all workspace folders (similar to references and rename capabilities), ensuring complete coveragefind_workspace_symbolsinsrc/state.rs: Collects symbols from all parsed trees in the workspace, filters them based on the query string (case-insensitive substring match), and returns sorted resultscollect_workspace_symbolsinsrc/state.rs: Recursively traverses document symbols to extract workspace symbols, maintaining parent-child relationships via thecontainer_namefieldget_workspacesinsrc/config/workspace.rs: New helper method to retrieve all workspace folder URIsFeatures
Example Usage
When a client sends a
workspace/symbolrequest with query"author":{ "query": "author" }The server parses all workspace files and returns all symbols matching "author" across the workspace:
[ { "name": "Author", "kind": 23, "location": { "uri": "file:///path/to/b.proto", "range": { "start": { "line": 5, "character": 0 }, ... } } } ]Testing
Added comprehensive test coverage in
src/workspace/workspace_symbol.rs:All 29 tests pass successfully (28 existing + 1 new).
Fixes #21
Original prompt
Fixes #21
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.