A full-featured, well-typed, and easy-to-use Python LSP client library that provides a high-level interface to interact with Language Server Protocol servers.
uv add lsp-clientfrom pathlib import Path
from lsp_client import Position
from lsp_client.clients.based_pyright import BasedPyrightClient
async def main():
async with BasedPyrightClient(workspace="/path/to/my/project") as client:
# Find references
refs = await client.request_references(
file_path="main.py",
position=Position(line=10, character=5)
)
if not refs:
print("No references found")
return
for ref in refs:
print(f"Found reference: {ref.uri} at {ref.range}")
# Get document symbols
symbols = await client.request_document_symbols("main.py")src/lsp_client/
├── client/ # Client base classes and utilities
├── server/ # Server base classes and process management
├── capability/ # LSP capability groups and protocols
├── clients/ # Server-specific client implementations
└── utils/ # Shared utilities
Contributions are welcome! Please check the contribution guide for more information.
This project is licensed under the MIT License.
- Language Server Protocol Specification
- lsprotocol - LSP type definitions
Making LSP integration simple and powerful! 🚀