← Catalog

@piex-dev/lsp

LSP extension for pi — diagnostics (incl. post-edit ERRORs), navigation, rename, code actions, format

Extension

Install

Install with PiG

pig install npm:@piex-dev/lsp

Install with Pi

pi install npm:@piex-dev/lsp
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/lsp.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.3.0 (README.md). PiG does not review it.

lsp

LSP(Language Server Protocol)扩展:注册 lsp 工具,并在 edit/write 成功后自动附加 ERROR 诊断。

功能

  • lsp 工具:stdio JSON-RPC 客户端,按项目 rootMarkers 发现 server,会话内复用进程
  • ~50 个默认 server(defaults.json):typescript、rust-analyzer、gopls、pyright、clangd、biome/eslint(linter)等
  • 导航:definition / type_definition / implementation / references / hover / symbols / workspace_symbols
  • 诊断:单文件聚合多 server;relatedInformation;写后自动 ERROR 反馈;push 诊断静默期 settle(慢服务器先推空后推真,不会误报干净);server 声明 diagnosticProvider 时改用 LSP 3.17 pull 诊断
  • 重构:rename(默认 preview)、code_actions(list / apply)
  • 格式化:format(写回磁盘)
  • 健壮性:server stderr 捕获进错误消息;重叠 TextEdit 拒绝应用(防文件损坏);Windows .bat/.cmd 经 cmd.exe 包装 spawn
  • 运维:status / reload;AbortSignal 超时取消;PI_<NAME>_LSP_COMMAND 环境变量覆盖单 server 命令

使用说明

pi install npm:@piex-dev/lsp

本机安装对应 language server,例如:

npm install -g typescript-language-server typescript
pip install pyright
rustup component add rust-analyzer
go install golang.org/x/tools/gopls@latest

关闭写后诊断(默认开启):

export PI_LSP_DIAGNOSTICS_ON_EDIT=0

覆盖单个 server 的启动命令:

export PI_TYPESCRIPT_LANGUAGE_SERVER_LSP_COMMAND="typescript-language-server --stdio"

冒烟测试:

cd extensions/lsp && npm install && cd ../..
bun test extensions/lsp

依赖

  • @earendil-works/pi-coding-agent(peer)
  • typebox(peer)

延伸阅读