Skip to content
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

Searching for symbols directly #40

Open
prabhuteja12 opened this issue Jan 2, 2025 · 1 comment
Open

Searching for symbols directly #40

prabhuteja12 opened this issue Jan 2, 2025 · 1 comment

Comments

@prabhuteja12
Copy link

prabhuteja12 commented Jan 2, 2025

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

@prabhuteja12
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant