https://github.com/alex-oleshkevich/fastapi-lsp
Language server for FastAPI and Starlette — route resolution, Depends() graph, url_for, Jinja templates, env intelligence. One Rust binary.
https://github.com/alex-oleshkevich/fastapi-lsp
fastapi language-server-protocol lsp lsp-server starlette
Last synced: 3 days ago
JSON representation
Language server for FastAPI and Starlette — route resolution, Depends() graph, url_for, Jinja templates, env intelligence. One Rust binary.
- Host: GitHub
- URL: https://github.com/alex-oleshkevich/fastapi-lsp
- Owner: alex-oleshkevich
- License: mit
- Created: 2026-06-15T08:55:22.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2026-07-01T11:55:39.000Z (14 days ago)
- Last Synced: 2026-07-01T12:24:39.552Z (14 days ago)
- Topics: fastapi, language-server-protocol, lsp, lsp-server, starlette
- Language: Rust
- Homepage:
- Size: 479 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Agents: AGENTS.md
Awesome Lists containing this project
- awesome-zed-extensions - Fastapi Lsp
README
# fastapi-lsp
[](https://github.com/alex-oleshkevich/fastapi-lsp/actions/workflows/ci.yml)
[](https://github.com/alex-oleshkevich/fastapi-lsp/releases)
Language server for FastAPI and Starlette — routes, `Depends()` graph, `url_for`, Jinja templates, env/settings. One Rust binary, any LSP-capable editor. Static analysis only.
## Features
| | |
|---|---|
| **Diagnostics** | param mismatches, shadowed routes, unincluded routers, `Depends(fn())`, dep cycles, broken `url_for`, missing templates, undefined env keys |
| **Navigation** | test call → handler, `Depends()` chains both ways, template files, `.env` lines |
| **Hover** | route card: resolved path, router chain, response model, deps, middleware |
| **Completions** | route paths, `url_for` names, template paths, env keys |
| **Symbols** | `GET /api/books/{book_id}` in the symbol picker |
| **Code lenses** | test count, dep usage, override count per handler |
| **`check` CLI** | same diagnostics as a linter — `fastapi-lsp check .` |
## Installation
```bash
uv tool install fastapi-lsp
```
Or with pip:
```bash
pip install fastapi-lsp
```
Or download a pre-built binary from the [releases page](https://github.com/alex-oleshkevich/fastapi-lsp/releases).
## Editor setup
### Neovim
```lua
vim.lsp.config('fastapi_lsp', {
cmd = { 'fastapi-lsp', '--stdio' },
filetypes = { 'python', 'html', 'htmldjango' },
root_markers = { 'pyproject.toml', '.git' },
})
vim.lsp.enable('fastapi_lsp')
```
### Helix
```toml
# ~/.config/helix/languages.toml
[language-server.fastapi-lsp]
command = "fastapi-lsp"
args = ["--stdio"]
[[language]]
name = "python"
language-servers = ["pyright", "fastapi-lsp"]
[[language]]
name = "html"
language-servers = ["vscode-html-language-server", "fastapi-lsp"]
[[language]]
name = "jinja"
language-servers = ["fastapi-lsp"]
```
### Zed
Install from the Zed extensions panel (`Cmd+Shift+X`) — search for **fastapi-lsp** and click Install. It activates automatically for Python, HTML, and Jinja2 files.
To control server order alongside other language servers or pass initialization options, add to `~/.config/zed/settings.json`:
```jsonc
{
"languages": { "Python": { "language_servers": ["fastapi-lsp", "..."] } },
"lsp": { "fastapi-lsp": { "initialization_options": { "templates": ["app/templates"] } } }
}
```
## Configuration
Zero config for standard projects. Priority: `InitializationOptions` › `fastapi-lsp.toml` › `[tool.fastapi-lsp]` in `pyproject.toml`.
| Option | Default | |
|---|---|---|
| `entrypoint` | _(auto-detected)_ | main app file |
| `templates` | `[]` | Jinja template directories |
| `source_roots` | `[]` | extra import resolution roots |
| `env_files` | `[".env", ".env.example"]` | env key definitions |
| `settings_env_files` | `[".env", ".env.example", ".env.unittest"]` | env files checked for `BaseSettings` coverage |
| `process_env` | `false` | include server process env |
| `process_env_show_values` | `false` | show process-env values in hover |
| `client_fixtures` | `["client", "async_client"]` | pytest HTTP client fixture names |
| `env.ignore` | `[]` | env keys to suppress from diagnostics |
Feature toggles — all `true` by default except `test_unknown_paths`:
| Toggle | Default |
|---|---|
| `diagnostics` | `true` |
| `completion` | `true` |
| `hover` | `true` |
| `navigation` | `true` |
| `code_actions` | `true` |
| `code_lens` | `true` |
| `symbols` | `true` |
| `inlay_hints` | `true` |
| `document_links` | `true` |
| `test_unknown_paths` | `false` |
```toml
# fastapi-lsp.toml
entrypoint = "app/main.py"
templates = ["app/templates"]
[features]
code_lens = false
[check]
only = []
ignore = ["env/undefined-key"]
```
## CLI
```
fastapi-lsp lsp [--stdio | --tcp --address 127.0.0.1 --port 9257]
fastapi-lsp check PATH [--only CODES] [--ignore CODES] [--format text|json] [--fix]
fastapi-lsp routes [PATH] [--format text|json]
```
## Development
```bash
cargo build
cargo test
uv run --group dev pytest e2e/ -v
```
## License
MIT