You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A full-featured, well-typed, and easy-to-use Python client for the Language Server Protocol (LSP). This library provides a clean, async-first interface for interacting with language servers, supporting both local and Docker-based runtimes.
8
+
A production-ready, async-first Python client for the Language Server Protocol (LSP). Built for developers who need fine-grained control, container isolation, and extensibility when integrating language intelligence into their tools.
8
9
9
-
## Features
10
+
## Why lsp-client?
10
11
11
-
-**🚀 Async-first Design**: Built for high-performance concurrent operations
12
-
-**🔧 Full LSP Support**: Comprehensive implementation of LSP 3.17 specification
13
-
-**🐳 Docker Support**: Run language servers in isolated containers
14
-
-**📝 Type Safety**: Full type annotations with Pydantic validation
15
-
-**🧩 Modular Architecture**: Mixin-based capability system for easy extension
16
-
-**🎯 Production Ready**: Robust error handling with tenacity retries
17
-
-**📚 Well Documented**: Extensive documentation and examples
12
+
`lsp-client` is engineered for developers building **production-grade tooling** that requires precise control over language server environments:
13
+
14
+
-**🐳 Container-First Architecture**: Containers as first-class citizens with workspace mounting, path translation, and lifecycle management. Pre-built images available, seamless switching between local and container environments.
15
+
-**🧩 Intelligent Capability Management**: Zero-overhead mixin system with automatic registration, negotiation, and availability checks. Only access methods for registered capabilities.
16
+
-**🎯 Complete LSP 3.17 Support**: Full specification implementation with pre-configured clients for Pyright, Rust-Analyzer, Deno, TypeScript, and Pyrefly.
17
+
-**⚡ Production-Ready & Modern**: Explicit environment control with no auto-downloads. Built with async patterns, comprehensive error handling, retries, and full type safety.
18
18
19
19
## Quick Start
20
20
21
21
### Installation
22
22
23
23
```bash
24
+
# Recommended: Use uv for modern Python dependency management
24
25
uv add lsp-client
26
+
27
+
# Or with pip
28
+
pip install lsp-client
25
29
```
26
30
27
-
### Basic Usage
31
+
### Local Language Server
32
+
33
+
The following code snippet can be run as-is, try it out:
28
34
29
35
```python
30
-
from pathlib import Path
36
+
# install pyrefly with `uv tool install pyrefly` first
31
37
import anyio
32
38
from lsp_client import Position
33
-
from lsp_client.clients.pyrightimportPyrightClient, PyrightLocalServer
39
+
from lsp_client.clients.pyreflyimportPyreflyClient
34
40
35
41
asyncdefmain():
36
-
workspace = Path.cwd()
37
-
asyncwith PyrightClient(
38
-
workspace=workspace,
39
-
server=PyrightLocalServer(),
40
-
) as client:
41
-
# Find definition of something at line 11, character 28 in a file
42
-
refs =await client.request_definition_locations(
43
-
file_path="src/main.py",
44
-
position=Position(11, 28) # line 12, character 29 (1-indexed)
| TypeScript Language Server |`lsp_client.clients.typescript`| TypeScript/JavaScript |
100
+
### Key Benefits
101
+
102
+
1.**Method Safety**: You can only call methods for capabilities you've registered. No runtime surprises from unavailable capabilities.
103
+
2.**Automatic Registration**: The mixin system automatically handles client registration, capability negotiation, and availability checks behind the scenes.
104
+
3.**Zero Boilerplate**: No manual capability checking, no complex initialization logic, no error handling for missing capabilities.
105
+
4.**Type Safety**: Full type annotations ensure you get compile-time guarantees about available methods.
106
+
5.**Composability**: Mix and match exactly the capabilities you need, creating perfectly tailored clients.
100
107
101
108
## Contributing
102
109
103
-
We welcome contributions! Please see our [Contributing Guide](docs/contribution/) for details.
110
+
We welcome contributions! Please see our [Contributing Guide](docs/contribution/) for details on:
111
+
112
+
- Adding new language server support
113
+
- Extending protocol capabilities
114
+
- Container image updates
115
+
- Development workflow
104
116
105
117
## License
106
118
@@ -110,4 +122,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
110
122
111
123
- Built on the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) specification
112
124
- Uses [lsprotocol](https://github.com/microsoft/lsprotocol) for LSP type definitions
113
-
-Inspired by [multilspy](https://github.com/microsoft/multilspy) and other LSP clients
125
+
-Architecture inspired by [multilspy](https://github.com/microsoft/multilspy) and other LSP clients
0 commit comments