Searching for symbols directly
Hello,
Thank you for the great code!
I was wondering if there is a way to search for a symbol directly instead of pointing to file and line number where that symbol is mentioned.
For eg: Currently
lsp.request_definition("myfile.py", 10, 2)
searches for the symbol (say something called SymbolName) that is mentioned in the 11th line, and 3rd character. I would like to check if something like lsp.request_definition("SymbolName") is possible.
Thank you! Edit:
LSP specification seems to do something for this: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_symbol
I hacked together a small solution to suit my needs by adding the following method to the LanguageServer class.
async def workspace_symbol(
self, symbol: str
) -> Union[List[SymbolInformation], List[WorkspaceSymbol], None]:
response = await self.server.send.workspace_symbol(
params=WorkspaceSymbolParams(query=symbol)
)
return response
Hi @prabhuteja12, great find and implementation. Could you please contribute a PR about the same?
I would just request to include a test using this function in at least one of the languages (hopefully your target usecase). Please let me know if I can help in any way!