Files
omp-lsp/README.md
T

105 lines
4.9 KiB
Markdown

# omp-lsp
[oh-my-pi](https://github.com/can1357/oh-my-pi)-style language-server integration for the DeepSeek Harness (DSH).
- **Diagnostics writethrough:** after every successful `edit` or `write` (DSH's built-ins or [omp-edit](https://git.rizzy.dev/DSH-Plugins/omp-edit)), the touched files are synced to their language server. Fresh errors and warnings are appended to the tool result, so the agent sees what it just broke:
```
The file src/a.ts has been updated successfully.
LSP diagnostics after this edit (1 error, 0 warnings):
src/a.ts:1:7 error [2322]: Type 'string' is not assignable to type 'number'. (typescript)
```
- **`lsp` agent tool:**
| Action | Inputs | Result |
| --- | --- | --- |
| `diagnostics` | `file` (path or glob) | All diagnostics with counts |
| `definition` / `type_definition` / `implementation` / `references` | `file`, `line`, `symbol` | `path:line:col: source line` list |
| `hover` | `file`, `line`, `symbol` | Type/doc text |
| `symbols` | `file`, or `file="*"` + `query` | Document outline / workspace symbol search |
| `rename` | `file`, `line`, `symbol`, `new_name`, `apply` | Applies the rename across the workspace (`apply=false` previews) |
| `rename_file` | `file`, `new_name`, `apply` | Moves the file and updates imports when the server supports it |
| `code_actions` | `file`, `line`, `query`, `apply` | Lists actions; `apply=true` applies the first match |
| `status` / `reload` / `capabilities` | — | Installed/running servers, restart, server capabilities |
| `request` | `file`, `query` (method), `payload` (JSON) | Raw LSP request |
`symbol` locates the column on the line: bare identifiers match on word boundaries, other text as a substring, and `name#2` picks the 2nd occurrence.
## Language servers
They're auto-detected on `PATH`, `~/.local/bin` and the project's `node_modules/.bin`. There's one client per (server, project root), found from the nearest root marker, and idle servers stop after `idleMinutes`.
| id | Command | Files | Install |
| --- | --- | --- | --- |
| typescript | `typescript-language-server` | ts tsx js jsx mjs cjs | `npm i -g typescript-language-server typescript@5` |
| pyright | `pyright-langserver` | py pyi | `npm i -g pyright` |
| gopls | `gopls` | go | `go install golang.org/x/tools/gopls@latest` |
| rust-analyzer | `rust-analyzer` | rs | `rustup component add rust-analyzer` |
| clangd | `clangd` | c h cc cpp hpp | distro package `clangd` |
| bash | `bash-language-server` | sh bash zsh | `npm i -g bash-language-server` |
| json / css / html | `vscode-*-language-server` | json, css/scss/less, html | `npm i -g vscode-langservers-extracted` |
| yaml | `yaml-language-server` | yaml yml | `npm i -g yaml-language-server` |
Without root access, install the npm ones into `~/.local`:
```bash
npm i -g --prefix ~/.local typescript-language-server typescript@5 pyright bash-language-server yaml-language-server vscode-langservers-extracted
```
TypeScript 7 (the Go port) ships no `tsserver.js`, so keep `typescript@5` for the language server. If a project has no local `typescript` dependency, the plugin points the server at the global install.
## Installation
```bash
dsh plugin --profile web add git+https://git.rizzy.dev/DSH-Plugins/omp-lsp.git
```
Or go to **Settings → Plugins → Install** with the same URL, or ask the agent to use `plugin_manager` → `install_bundle`.
For development:
```bash
git clone https://git.rizzy.dev/DSH-Plugins/omp-lsp.git ~/dsh-plugins/omp-lsp
dsh plugin --profile web add link:$HOME/dsh-plugins/omp-lsp
```
Then restart DSH (`systemctl --user restart dsh` or re-run `dsh web`), and check with `lsp action=status` in a new session.
## Configuration
Set options in `config` of the `omp-lsp` row in `~/.dsh/profiles/web/cordis.patch.yml`:
```yaml
- id: omp-lsp
config:
writethrough: true # append diagnostics to edit/write results
writethroughTools: [edit, write]
minSeverity: 2 # 1 error, 2 +warnings, 3 +info, 4 +hints
budgetMs: 4000 # max wait for fresh diagnostics per write
maxDiagnostics: 25
idleMinutes: 10
disabled: [html] # server ids to turn off
servers: # override or add servers
lua:
command: lua-language-server
args: []
extensions: [.lua]
roots: [.luarc.json]
languageId: lua
```
## Tests
```bash
npm test # unit tests + live tests against typescript-language-server and pyright when installed
```
## Files
| File | Role |
| --- | --- |
| `index.js` | DSH plugin: `lsp` tool, `tools/post-execute` diagnostics writethrough, workspace-edit application through `ctx.fs` |
| `lib/client.js` | JSON-RPC/stdio LSP client: document sync, push + pull diagnostics with freshness tracking |
| `lib/servers.js` | Server catalog, PATH detection, root markers, per-root pool, idle reaping |
| `lib/format.js` | Diagnostics/locations/symbols/hover formatting, TextEdit application, column lookup |