diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-01 09:23:53 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-09-01 11:24:12 -0300 |
| commit | ae9325a5cb128d0d952afb8f9feaaca68e5e37a2 (patch) | |
| tree | 9ae44ac38f7b71edfe2882d0a882dbc61304ec80 /test/snapshots | |
| parent | 848ad99fa597387a85f75e752dc4c9e10f8c24f4 (diff) | |
| download | pardes-ae9325a5cb128d0d952afb8f9feaaca68e5e37a2.tar.gz pardes-ae9325a5cb128d0d952afb8f9feaaca68e5e37a2.zip | |
lsp: a protocol client for every other language, narrated on the message row
The seam grows a second backend: src/lsp/lsp_client.zig speaks JSON-RPC to
child language servers — rust-analyzer, clangd, gopls, tsserver, pyright are
rows in a spec table — while the in-process ZLS analyser keeps .zig. One
reader thread per server owns the socket, routes responses to a mailbox
under the conn mutex (monotonic condvar), answers server-to-client requests,
feeds the diagnostics store, and narrates $/progress and state changes
through a status sink both native shells post to the transient message row:
"rust-analyzer: cargo check 88% 955/1083" lands where a save narrates, with
the same clock. Chatty progress is throttled and deduplicated; settled
states always land, which is also what makes the goldens deterministic.
Nothing wedges and nothing healthy dies: waits are deadline-bounded, a
timeout cancels and returns no rows, three consecutive timeouts restart the
server ONLY while it is idle (an indexing server is narrating its own
excuse), spawn and handshake failures back off 10s to 2min, a crash shortly
after ready counts as a failure, and only a missing binary disables a spec.
PARDES_LSP_{RS,C,GO,TS,PY} override binaries; empty disables; the snapshot
harness pins RS to test/lspmock.zig and empties the rest.
Mutating answers really mutate now: the @put record beside rename @edit
carries per-range text, so = applies the formatter (both backends) and a
same-file WorkspaceEdit rename applies atomically, one undo step, narrated
("renamed 2 range(s)"); a multi-file rename previews as rows instead of
half-applying. Malformed responses fail closed: coordinates validated not
clamped, one bad TextEdit poisons the whole edit set, poison frames kill
the connection instead of buffering forever, decoded control bytes reject a
uri, hierarchy items too deep to reserialize are skipped.
Four kinds helix does not have, on SPC l: c/C incoming/outgoing calls (rows
are call sites), t/T super/subtypes. Pull diagnostics (3.17) preferred when
advertised. Help gains a language-keys footer for the motions no builtin
row could carry; lsp.rel and look.grep now share one path-shortening rule.
zig build lspprobe drives the seam from the CLI (comma-separated kinds share
one server); measured against a 1083-crate workspace warm: gd 26ms, gr 213
rows 165ms, incoming calls 212 sites 197ms, document symbols 670 rows 347ms.
docs/lsp.md tells the whole story; lsp-evaluation.md gets an addendum.
Diffstat (limited to 'test/snapshots')
| -rw-r--r-- | test/snapshots/builtins.golden | 66 | ||||
| -rw-r--r-- | test/snapshots/builtins.snap | 11 | ||||
| -rw-r--r-- | test/snapshots/leader.golden | 30 | ||||
| -rw-r--r-- | test/snapshots/lsp-client-edit.golden | 44 | ||||
| -rw-r--r-- | test/snapshots/lsp-client-edit.snap | 35 | ||||
| -rw-r--r-- | test/snapshots/lsp-client.golden | 27 | ||||
| -rw-r--r-- | test/snapshots/lsp-client.snap | 34 | ||||
| -rw-r--r-- | test/snapshots/lsp-rename.golden | 8 | ||||
| -rw-r--r-- | test/snapshots/lspdebug.golden | 2 |
9 files changed, 208 insertions, 49 deletions
diff --git a/test/snapshots/builtins.golden b/test/snapshots/builtins.golden index 5019c855..555a6fc4 100644 --- a/test/snapshots/builtins.golden +++ b/test/snapshots/builtins.golden @@ -42,39 +42,39 @@ |64: 30 SPC h t Tutor topbar |65: 31 SPC j i Forward C-i == snap index-tail grid=120x66 cursor=7,64 -|35: 49 SPC s a Attach -|36: 50 SPC s d Dump topbar -|37: 51 SPC s r Restore -|38: 52 SPC t a Ascii -|39: 53 SPC t b Tagbottom -|40: 54 SPC t c Colors -|41: 55 SPC t d Debug topbar -|42: 56 SPC t i PdfTint -|43: 57 SPC t l Palette -|44: 58 SPC t n NextColor topbar -|45: 59 SPC t p Petscii -|46: 60 SPC t s PdfSections -|47: 61 SPC t t ThemeSel -|48: 62 SPC t w Wrap -|49: 63 SPC t z PdfFit -|50: 64 SPC w h Left C-w h, C-w left -|51: 65 SPC w j Down C-w j, C-w down -|52: 66 SPC w k Up C-w k, C-w up -|53: 67 SPC w l Right C-w l, C-w right -|54: 68 SPC y ClipYank -|55: 69 Look enter, right-click -|56: 70 Exec tab, middle-click -|57: 71 Msg -|58: 72 ThemeFile -|59: 73 DumpThemes -|60: 74 Filter -|61: 75 EffectCode -|62: 76 9p -|63: 77 Theme -|64: 78 Shell -|65: 79 -== snap not-a-picker grid=120x66 cursor=7,64 -== snap window-group grid=120x66 cursor=7,35 +|35: 66 SPC t w Wrap +|36: 67 SPC t z PdfFit +|37: 68 SPC w h Left C-w h, C-w left +|38: 69 SPC w j Down C-w j, C-w down +|39: 70 SPC w k Up C-w k, C-w up +|40: 71 SPC w l Right C-w l, C-w right +|41: 72 SPC y ClipYank +|42: 73 Look enter, right-click +|43: 74 Exec tab, middle-click +|44: 75 Msg +|45: 76 ThemeFile +|46: 77 DumpThemes +|47: 78 Filter +|48: 79 EffectCode +|49: 80 9p +|50: 81 Theme +|51: 82 Shell +|52: 83 +|53: 84 language keys (motions, not words): +|54: 85 gd gD gy gi gr goto: definition, +|55: 86 declaration, type-def, +|56: 87 implementation, refs +|57: 88 ]d [d ]D [D diagnostics: next, +|58: 89 prev, last, first +|59: 90 = format (applies, one +|60: 91 undo step) +|61: 92 Tab after a . completion, in insert +|62: 93 C-left-click definition, by mouse +|63: 94 SPC l ... hover, rename, symbols, +|64: 95 calls, types: above +|65: 96 +== snap not-a-picker grid=120x66 cursor=19,61 +== snap window-group grid=120x66 cursor=19,35 |35: 1 pardes builtins under SPC w |36: 2 |37: 3 SPC w h Left C-w h, C-w left diff --git a/test/snapshots/builtins.snap b/test/snapshots/builtins.snap index ad8e27f3..4eaa3543 100644 --- a/test/snapshots/builtins.snap +++ b/test/snapshots/builtins.snap @@ -55,12 +55,15 @@ snap window-group # which is the whole reason n/N were never allowed to be the picker. # # The one place in this suite a builtin cannot be added for free: the click is -# a SCREEN coordinate, so every row inserted above `SPC h t` in the listing -# moves Tutor down one and this number with it. The five clipboard builtins -# put three there — SPC P, SPC R and SPC Y, uppercase sorting ahead of the -# lowercase `SPC h`; the eleven panel effects now follow them as well. +# a SCREEN COORDINATE. The rows above `SPC h t` in the listing move Tutor and +# this number with them — the five clipboard builtins put three there. And +# since the language-keys footer made the page longer than the pane, the +# re-opened view RETAINS the scroll the `ge` above left behind, which is why +# `gg` now pins the top before the click: an exec aimed one row into the +# footer would run "declaration," in a shell instead of opening the tutor. key space ? wait 10000 SPC c n +key g g stable 700 15000 press middle 20 65 release middle 20 65 diff --git a/test/snapshots/leader.golden b/test/snapshots/leader.golden index 38b4f9dc..5d3adba2 100644 --- a/test/snapshots/leader.golden +++ b/test/snapshots/leader.golden @@ -160,17 +160,21 @@ |36: == snap help-language grid=100x40 cursor=7,22 |22: 1 pardes builtins under SPC l -|24: 3 SPC l D WsDiagnostics -|25: 4 SPC l S WsSymbols -|26: 5 SPC l a CodeAction -|27: 6 SPC l d Diagnostics -|28: 7 SPC l h SelectRefs -|29: 8 SPC l i Lspinfo -|30: 9 SPC l k Hover -|31: 10 SPC l r Rename -|32: 11 SPC l s Symbols -|33: 12 SPC l w Lspwhy -|34: 13 +|24: 3 SPC l C Callees +|25: 4 SPC l D WsDiagnostics +|26: 5 SPC l S WsSymbols +|27: 6 SPC l T Subtypes +|28: 7 SPC l a CodeAction +|29: 8 SPC l c Callers +|30: 9 SPC l d Diagnostics +|31: 10 SPC l h SelectRefs +|32: 11 SPC l i Lspinfo +|33: 12 SPC l k Hover +|34: 13 SPC l r Rename +|35: 14 SPC l s Symbols +|36: 15 SPC l t Supertypes +|37: 16 SPC l w Lspwhy +|38: 17 == snap del-output grid=100x40 cursor=7,2 |21: |22: @@ -186,3 +190,7 @@ |32: |33: |34: +|35: +|36: +|37: +|38: diff --git a/test/snapshots/lsp-client-edit.golden b/test/snapshots/lsp-client-edit.golden new file mode 100644 index 00000000..15a477b2 --- /dev/null +++ b/test/snapshots/lsp-client-edit.golden @@ -0,0 +1,44 @@ +== snap formatted grid=100x24 cursor=7,3 +|New Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill +| /tmp/pardes-snap/lsp-client-edit/cwd/main.rs * Save New Newtty Del +| 1 // formatted by mock +| 2 mod lib; +| 3 +| 4 fn main() { +| 5 let x = add(1, 2); +| 6 let y = add(3, 4); +| 7 let _ = x + y; +| 8 } +| 9 +| +| +| +| +| +| +| +| +| +| +| +| +| formatted 1 range(s) +== snap unformatted grid=100x24 cursor=7,2 +|2: 1 mod lib; +|3: 2 +|4: 3 fn main() { +|5: 4 let x = add(1, 2); +|6: 5 let y = add(3, 4); +|7: 6 let _ = x + y; +|8: 7 } +|9: 8 +|10: +|23: +== snap renamed grid=100x24 cursor=12,4 +|5: 4 let x = sum(1, 2); +|6: 5 let y = sum(3, 4); +|23: renamed 2 range(s) +== snap unrenamed grid=100x24 cursor=12,4 +|5: 4 let x = add(1, 2); +|6: 5 let y = add(3, 4); +|23: diff --git a/test/snapshots/lsp-client-edit.snap b/test/snapshots/lsp-client-edit.snap new file mode 100644 index 00000000..a9e66e51 --- /dev/null +++ b/test/snapshots/lsp-client-edit.snap @@ -0,0 +1,35 @@ +# The protocol client's MUTATING answers, through the @put record path: a +# server TextEdit response becomes one atomic buffer edit with one undo step. +# = applies the mock's formatting edit (a header line) and narrates +# "formatted 1 range(s)" on the message row +# SPC l r renames both `add` calls via the server's WorkspaceEdit +# u reverses each as a single transaction +file main.rs mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n +file lib.rs // mock fixture\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n +start 24 100 main.rs +wait 8000 add(1, 2) +stable 700 20000 +key = +wait 10000 formatted by mock +stable 700 15000 +snap formatted +key u +wait 8000 mod lib; +stable 700 15000 +snap unformatted +# rename through the leader prompt: both call sites change in one step +press left 13 5 +release left 13 5 +key space +key l +key r +stable 400 5000 +text sum +key enter +wait 10000 sum(3, 4) +stable 700 15000 +snap renamed +key u +wait 8000 add(3, 4) +stable 700 15000 +snap unrenamed diff --git a/test/snapshots/lsp-client.golden b/test/snapshots/lsp-client.golden new file mode 100644 index 00000000..a203cc7c --- /dev/null +++ b/test/snapshots/lsp-client.golden @@ -0,0 +1,27 @@ +== snap gd-jumped grid=100x24 cursor=16,15 +|New Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill +| /tmp/pardes-snap/lsp-client/cwd/main.rs Save New Newtty Del +| 1 mod lib; +| 2 +| 3 fn main() { +| 4 let x = add(1, 2); +| 5 let y = add(3, 4); +| 6 let _ = x + y; +| 7 } +| 8 +| +| +| --:--:-- lsp rust-analyzer: ready +| /tmp/pardes-snap/lsp-client/cwd/lib.rs Save New Newtty Del +| 1 // mock fixture +| 2 pub fn add(a: i32, b: i32) -> i32 { +| 3 a + b +| 4 } +| 5 +== snap gr-list grid=100x24 cursor=16,15 +|12: +|20: /tmp/pardes-snap/lsp-client/cwd/+Search Save New Newtty Del +|21: 1 main.rs:4:13-15 let x = add(1, 2); +|22: 2 main.rs:5:13-15 let y = add(3, 4); +|23: 3 lib.rs:2:8-10 pub fn add(a: i32, b: i32) -> i32 { +== snap gr-opened grid=100x24 cursor=21,6 diff --git a/test/snapshots/lsp-client.snap b/test/snapshots/lsp-client.snap new file mode 100644 index 00000000..bc5267cc --- /dev/null +++ b/test/snapshots/lsp-client.snap @@ -0,0 +1,34 @@ +# The protocol client end to end, against the deterministic mock server the +# harness pins via PARDES_LSP_RS (test/lspmock.zig). What this exercises is +# everything BETWEEN the keymap and the analyser: spawn, handshake, the reader +# thread, $/progress narration onto the transient message row, and the +# location shapes coming back as +Search rows. +# gd on a cross-file Location -> a look: lib.rs opens with `add` selected, +# and the message row still carries the server's settled state +# ("lsp lspmock: ready") because nothing has cleared it yet. +# gr -> three rows with column SPANS, n arms the walk, Enter opens one. +file main.rs mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n +file lib.rs // mock fixture\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n +start 24 100 main.rs +wait 8000 add(1, 2) +stable 700 20000 +# cursor into the first `add` call, then helix's goto-definition +press left 13 5 +release left 13 5 +key g +key d +wait 10000 pub fn add +stable 700 15000 +snap gd-jumped +# references from the definition the look landed on (cursor sits on `add`) +key g +key r +wait 10000 add(3, 4) +stable 700 15000 +snap gr-list +# step the list and open the second hit: main.rs with the span selected +key n +key n +key enter +stable 700 15000 +snap gr-opened diff --git a/test/snapshots/lsp-rename.golden b/test/snapshots/lsp-rename.golden index e21228e4..a241a93c 100644 --- a/test/snapshots/lsp-rename.golden +++ b/test/snapshots/lsp-rename.golden @@ -16,9 +16,17 @@ | 13 _ = helper; | 14 } | 15 +| +| +| +| +| +| +| renamed 2 range(s) == snap undone grid=110x24 cursor=17,9 |4: 3 fn helper(x: u32) u32 { |9: 8 _ = helper(41); +|23: == snap redone grid=110x24 cursor=17,9 |4: 3 fn renamed_helper(x: u32) u32 { |9: 8 _ = renamed_helper(41); diff --git a/test/snapshots/lspdebug.golden b/test/snapshots/lspdebug.golden index 91ab400a..cd9ac0c7 100644 --- a/test/snapshots/lspdebug.golden +++ b/test/snapshots/lspdebug.golden @@ -27,7 +27,7 @@ |43: 9 0 row(s) == snap info grid=120x44 cursor=7,4 |18: /tmp/pardes-snap/lspdebug/cwd/+Lsp Save New Newtty Del -|19: 1 backend: zls-inproc +|19: 1 backend: zls-inproc+lsp-client |20: 2 zls: 0.16.1-dev+3e0d0820 (compiled in — no server process, no JSON-RPC) |21: 3 zig lib dir: /usr/lib/zig [OK] |22: 4 offsets: utf-8 walk caps: 512 files, 2000 rows |
