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
`@narumitw/pi-lsp` is a native [Pi coding agent](https://pi.dev) extension that exposes Biome, ty, and Ruff language-server behavior through language/file-extension routed Pi tools.
5
+
`@narumitw/pi-lsp` is a native [Pi coding agent](https://pi.dev) extension that exposes diagnostics and source-fix tools through configurable Language Server Protocol routes.
6
6
7
-
It supersedes the older split packages `@narumitw/pi-biome-lsp` and `@narumitw/pi-python-lsp`, which now live under `extensions/deprecated/`and are excluded from active workspace scripts.
7
+
The extension is language-agnostic: servers are selected by config and file extension instead of hard-coded language families.
8
8
9
9
## ✨ Features
10
10
11
-
- Routes Biome-supported web/config files to `biome lsp-proxy` for diagnostics, formatting, import organization, and source fixes.
12
-
- Routes Python `.py` and `.pyi` type diagnostics to `ty server`.
13
-
- Routes Python `.py` and `.pyi` lint diagnostics, formatting, import organization, and source fixes to `ruff server`.
14
-
- Uses one internal LSP runner for JSON-RPC framing, subprocess lifecycle, diagnostics, formatting, code actions, and workspace edit application.
15
-
- Keeps Biome, ty, and Ruff behavior in small server adapters.
16
-
- Supports workspace roots, file limits, recursive file discovery, language overrides, and write-or-preview edits.
11
+
- Configure LSP servers with simple JSON keyed by server name.
12
+
- Routes diagnostics and source fixes by configured file extensions.
13
+
- Supports multiple servers for the same extension, for example `ty` and `ruff` for `.py`/`.pyi` diagnostics.
14
+
- Uses one internal LSP runner for JSON-RPC framing, subprocess lifecycle, diagnostics, code actions, and workspace edit application.
15
+
- Supports workspace roots, file limits, recursive file discovery, server overrides, and write-or-preview edits.
17
16
- Starts language servers only for tool calls, then shuts them down.
18
17
- Shows statusline activity only while LSP tools are running.
19
18
@@ -23,182 +22,127 @@ It supersedes the older split packages `@narumitw/pi-biome-lsp` and `@narumitw/p
23
22
pi install npm:@narumitw/pi-lsp
24
23
```
25
24
26
-
Try without installing permanently:
27
-
28
-
```bash
29
-
pi -e npm:@narumitw/pi-lsp
30
-
```
31
-
32
25
Try this package locally from the repository root:
33
26
34
27
```bash
35
28
pi -e ./extensions/pi-lsp
36
29
```
37
30
38
-
## ⚠️ Tool-name compatibility
39
-
40
-
This package now exposes three language/file-extension routed tools instead of the old backend-specific tool names:
31
+
## ⚙️ Configuration
41
32
42
-
| Old tool | New call |
43
-
| --- | --- |
44
-
|`biome_lsp_diagnostics`|`lsp_diagnostics` with `language: "web"` when an override is needed |
45
-
|`biome_lsp_format`|`lsp_format` for a Biome-supported file |
46
-
|`biome_lsp_fix`|`lsp_fix` for a Biome-supported file |
47
-
|`ty_lsp_diagnostics`|`lsp_diagnostics` with `language: "python"`, `checker: "type"`|
48
-
|`ruff_lsp_diagnostics`|`lsp_diagnostics` with `language: "python"`, `checker: "lint"`|
49
-
|`ruff_lsp_format`|`lsp_format` for a Python file |
50
-
|`ruff_lsp_fix`|`lsp_fix` for a Python file |
33
+
If no config is provided, pi-lsp ships compatible defaults for Biome, ty, and Ruff.
51
34
52
-
Avoid installing `@narumitw/pi-lsp` side by side with the older deprecated LSP packages unless you have verified how your Pi version handles overlapping capabilities.
35
+
Custom config can be supplied in one of these locations:
53
36
54
-
## ✅ Requirements
37
+
1.`PI_LSP_CONFIG` as inline JSON or a path to a JSON file
38
+
2.`<workspace>/.pi/lsp.json`
39
+
3.`~/.pi/agent/lsp.json`
55
40
56
-
Install the language servers you want to use somewhere on `PATH`:
41
+
`lsp.json` can be a plain object keyed by server name:
57
42
58
-
```bash
59
-
uv tool install ty
60
-
uv tool install ruff
43
+
```json
44
+
{
45
+
"ty": {
46
+
"command": ["ty", "server"],
47
+
"extensions": [".py", ".pyi"]
48
+
},
49
+
"ruff": {
50
+
"command": ["ruff", "server"],
51
+
"extensions": [".py", ".pyi"]
52
+
},
53
+
"biome": {
54
+
"command": ["biome", "lsp-proxy"],
55
+
"extensions": [
56
+
".astro",
57
+
".css",
58
+
".graphql",
59
+
".gql",
60
+
".html",
61
+
".js",
62
+
".jsx",
63
+
".json",
64
+
".jsonc",
65
+
".ts",
66
+
".tsx",
67
+
".vue"
68
+
]
69
+
}
70
+
}
61
71
```
62
72
63
-
For Biome, either install it globally/on `PATH`, add your project's `node_modules/.bin` to `PATH`, or point the extension at a project-local command. For example:
73
+
Use `servers` when you need global pi-lsp options such as timeout:
64
74
65
-
```bash
66
-
npm install -D @biomejs/biome
67
-
PI_BIOME_LSP_COMMAND="./node_modules/.bin/biome lsp-proxy" pi -e ./extensions/pi-lsp
75
+
```json
76
+
{
77
+
"timeout": 30000,
78
+
"servers": {
79
+
"ty": {
80
+
"command": ["ty", "server"],
81
+
"extensions": [".py", ".pyi"],
82
+
"env": {
83
+
"LSP_LOG": "debug"
84
+
},
85
+
"initialization": {
86
+
"settings": {}
87
+
}
88
+
}
89
+
}
90
+
}
68
91
```
69
92
70
-
Or provide custom server commands:
93
+
Each server entry supports:
71
94
72
-
```bash
73
-
PI_BIOME_LSP_COMMAND="npx biome lsp-proxy" \
74
-
PI_TY_LSP_COMMAND="uvx ty server" \
75
-
PI_RUFF_LSP_COMMAND="uvx ruff server" \
76
-
pi -e ./extensions/pi-lsp
77
-
```
95
+
-`command`: argv array used to start the LSP server.
96
+
-`extensions`: file extensions that should route to this server.
97
+
-`env`: extra environment variables for the LSP server process.
98
+
-`initialization`: LSP initialization options and workspace configuration values.
78
99
79
-
Optional timeout overrides:
100
+
Global options:
101
+
102
+
-`timeout`: request timeout in milliseconds. Defaults to `20000`.
103
+
104
+
pi-lsp infers `languageId` from common extensions and falls back to the extension without the leading dot.
105
+
106
+
Per-server command overrides still use the normalized server name:
80
107
81
108
```bash
82
-
PI_BIOME_LSP_TIMEOUT_MS=30000 \
83
-
PI_TY_LSP_TIMEOUT_MS=30000 \
84
-
PI_RUFF_LSP_TIMEOUT_MS=30000 \
109
+
PI_TY_LSP_COMMAND="uvx ty server" \
110
+
PI_RUFF_LSP_COMMAND="uvx ruff server" \
85
111
pi -e ./extensions/pi-lsp
86
112
```
87
113
88
114
## 🛠️ Pi tools
89
115
90
116
### `lsp_diagnostics`
91
117
92
-
Run diagnostics through language/file-extension routes.
118
+
Run diagnostics through configured servers.
93
119
94
120
Parameters:
95
121
96
122
-`paths?`: files or directories to check. Defaults to the workspace root.
97
123
-`root?`: workspace root. Defaults to cwd.
98
-
-`limit?`: maximum files to open per selected route.
99
-
-`language?`: optional override, either `"web"` for Biome-supported web/config files or `"python"` for `.py`/`.pyi` files.
100
-
-`checker?`: Python diagnostics checker, one of `"type"`, `"lint"`, or `"all"`. Defaults to `"all"`.
-`limit?`: maximum files to open per selected server.
125
+
-`server?`: configured server name, or an array of names. Defaults to all matching servers.
124
126
125
127
### `lsp_fix`
126
128
127
-
Apply source fixes or import organization through the route selected from the file extension.
129
+
Apply source fixes or import organization through a configured server that matches its extension. If multiple servers match, pass `server` explicitly.
128
130
129
131
Parameters:
130
132
131
133
-`path`: file to fix.
132
134
-`root?`: workspace root. Defaults to cwd.
133
-
-`kind?`: source action kind. Defaults to the routed backend's fix-all action.
135
+
-`kind?`: source action kind. Defaults to `source.fixAll`.
134
136
-`write?`: write fixed text back to the file. Defaults to false.
135
-
-`language?`: optional route override, either `"web"` or `"python"`.
136
-
137
-
Routes:
138
-
139
-
- Biome-supported web/config files → Biome source fixes such as `source.fixAll.biome` or `source.organizeImports.biome`.
140
-
- Python `.py`/`.pyi` files → Ruff source fixes such as `source.fixAll.ruff` or `source.organizeImports.ruff`.
141
-
142
-
## 🚀 Examples
143
-
144
-
Check a mixed project subset and run all applicable diagnostics:
145
-
146
-
```json
147
-
{
148
-
"paths": ["src", "extensions/pi-lsp/src"],
149
-
"limit": 100
150
-
}
151
-
```
152
-
153
-
Check only Biome-supported web/config files:
154
-
155
-
```json
156
-
{
157
-
"language": "web",
158
-
"paths": ["extensions/pi-lsp/src"],
159
-
"limit": 100
160
-
}
161
-
```
162
-
163
-
Check Python type diagnostics only:
164
-
165
-
```json
166
-
{
167
-
"language": "python",
168
-
"checker": "type",
169
-
"paths": ["src", "tests"],
170
-
"limit": 100
171
-
}
172
-
```
173
-
174
-
Format a TypeScript file with the inferred Biome route:
175
-
176
-
```json
177
-
{
178
-
"path": "src/index.ts",
179
-
"write": true
180
-
}
181
-
```
182
-
183
-
Organize Python imports with the inferred Ruff route:
184
-
185
-
```json
186
-
{
187
-
"path": "src/app.py",
188
-
"kind": "source.organizeImports.ruff",
189
-
"write": true
190
-
}
191
-
```
192
-
193
-
If `paths` is omitted for diagnostics, the tool recursively discovers supported files under the workspace root while skipping common generated, dependency, cache, and virtualenv directories.
137
+
-`server?`: optional configured server name.
194
138
195
139
## 💬 Command
196
140
197
141
```text
198
142
/lsp
199
143
```
200
144
201
-
Shows the configured Biome, ty, and Ruff LSP commands and whether each command is available on `PATH`.
145
+
Shows configured LSP commands and whether each command is available on `PATH`.
202
146
203
147
## 🗂️ Package layout
204
148
@@ -220,10 +164,6 @@ extensions/pi-lsp/
220
164
└── package.json
221
165
```
222
166
223
-
## 🔎 Keywords
224
-
225
-
Pi extension, Pi coding agent, Language Server Protocol, Biome LSP, ty, Ruff, Python LSP, formatter, linter, import organization, AI coding tools.
0 commit comments