Skip to content

Commit 41f8592

Browse files
committed
docs: describe concrete hints through jury.nvim and the public seams
Replace the "Jev enrichment" section with how jury.nvim fills the generic hints, the install snippet for the pair, and the three things to know. Document `set_hint_resolver`, `set_overload_picker`, `hint_family`, and the templates in the public API. Mark the `typesafe` option as removed.
1 parent 0e7c258 commit 41f8592

1 file changed

Lines changed: 43 additions & 31 deletions

File tree

‎README.md‎

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -309,47 +309,47 @@ end,
309309
| `sources` | `{ typescript=true, ts=true, vtsls=true, effect=true }` | Diagnostic sources this plugin handles. Exact match only. Merged with the defaults, so `{ deno = true }` *adds* Deno — pass `{ typescript = false }` to drop one. `effect` is `@effect/language-service`. |
310310
| `format_ts_errors_fallback` | `true` | When no pattern matches, try [`format-ts-errors.nvim`](https://github.com/davidosomething/format-ts-errors.nvim) if installed. |
311311
| `extra_patterns` | `nil` | List of `function(msg) -> {kind, ...}` parsers run after builtins. Let you add custom shapes. |
312-
| `typesafe` | `{ enabled = false }` | Optional [Jev](https://docs.typesafe.ai) enrichment for overload errors. Off by default. See below. |
312+
| `typesafe` | removed | Jev enrichment moved to [jury.nvim](https://github.com/rashedInt32/jury.nvim). The option is ignored with a warning. See below. |
313313

314314
If `float = true` and something else later calls `vim.diagnostic.config({ float = ... })`, Neovim replaces the whole `float` table — the formatter reinstalls itself on `LspAttach`, so the ordering doesn't matter.
315315

316-
## Jev enrichment (optional, off by default)
316+
## Concrete hints with jury.nvim (optional)
317317

318-
A TS2769 "No overload matches this call." error carries one nested report per
319-
candidate overload, and only one of them describes the call you meant to write.
320-
The plugin picks with a hand-tuned heuristic: prefer an `Effect`/`Stream`/`Layer`
321-
pair, then prefer the shallower report. That is a guess, and on a heavily
322-
overloaded call like `Effect.gen` or a long `pipe` it can guess wrong.
318+
Every `⚡ Hint:` line above is generic: `.pipe(Effect.provide(SomeLayer))`,
319+
`.pipe(Effect.catchTags({...})) or Effect.orDie`. The parser knows the family
320+
exactly, but not which layer you meant or which fix fits this function.
323321

324-
Enabling `typesafe` lets [Jev](https://docs.typesafe.ai) choose instead:
322+
[jury.nvim](https://github.com/rashedInt32/jury.nvim) fills that in. It asks
323+
[Jev](https://docs.typesafe.ai) to pick among the layers and error classes
324+
found in your workspace and among a fixed set of fix shapes, then hands the
325+
pick back here to render through this plugin's own templates:
326+
327+
```
328+
│ ◈ Forgot to provide: Greeter | Database
329+
│ ⚡ Jev: .pipe(Effect.provide(AppLive))
330+
│ ↳ layer AppLive 0.99 · where here 0.60
331+
```
332+
333+
It also replaces the TS2769 overload heuristic when Jev is confident about
334+
which nested report you meant.
335+
336+
Install both and it works. Install only this plugin and nothing changes:
325337

326338
```lua
327-
require("effect-error-pretty").setup({
328-
float = true,
329-
typesafe = {
330-
enabled = true,
331-
-- Defaults to $TYPESAFE_API_KEY. Prefer the env var over a literal here.
332-
-- api_key = "...",
333-
min_confidence = 0.6,
334-
},
335-
})
339+
{ "rashedInt32/effect-error-pretty.nvim", opts = { float = true } },
340+
{ "rashedInt32/jury.nvim", dependencies = { "rashedInt32/effect-error-pretty.nvim" }, opts = {} },
336341
```
337342

338-
Four things are worth knowing before you turn it on.
343+
Three things to know.
339344

340-
- **Your diagnostics leave your machine.** The message text carries your own
341-
service, error and type names. That is why this is opt-in and why there is no
342-
default key.
343-
- **Nothing blocks.** `vim.diagnostic` calls the formatter synchronously, so the
344-
deterministic box always renders first. The answer lands out of band and is
345-
cached by message; the *next* hover on that diagnostic shows the enriched
346-
pick. An `User EffectErrorPrettyEnriched` autocmd fires when one arrives, if
347-
you want to redraw the float yourself.
348-
- **Code still owns the candidates.** The model only ever selects an index into
349-
the reports the parser already enumerated, so it can pick the wrong report but
350-
can never invent one or reword a type.
351-
- **The heuristic is the floor.** Below `min_confidence`, on a `none` answer, on
352-
a timeout, or with no key, the existing behavior stands unchanged.
345+
- **Nothing blocks.** jury judges in the background when diagnostics change
346+
and caches by message plus enclosing function. The formatter only reads
347+
that cache. A miss renders the generic hint; the next hover is concrete.
348+
- **Code still owns the candidates.** Jev selects a layer, an error class, a
349+
fix shape, or a report index from lists this plugin or jury enumerated. It
350+
never writes code or renames a type.
351+
- **This plugin stays offline on its own.** The seam is two registration
352+
functions, below. No key, no network, no option to set here.
353353

354354
## Public API
355355

@@ -365,6 +365,18 @@ pretty.inline_format(diagnostic)
365365
-- Low-level: parse a raw TS diagnostic message into a structured kind.
366366
-- Returns nil if no pattern matched.
367367
require("effect-error-pretty.parse").parse(message, { effect = true })
368+
369+
-- Seams for an external judge (this is what jury.nvim registers into).
370+
-- The resolver runs inside vim.diagnostic's formatter: synchronous, fast.
371+
pretty.set_hint_resolver(function(parsed, family, names, diagnostic)
372+
-- family is "services" or "errors"; return nil for the generic hint, or
373+
-- { label = "Jev", line = "...", detail = "..." } to replace it, or
374+
-- { lean = "..." } to keep it and add a line underneath.
375+
end)
376+
pretty.set_overload_picker(function(msg, candidates) return index_or_nil end)
377+
pretty.hint_family(parsed) -- "services"|"errors"|nil, names
378+
pretty.templates.provide(layer, names, where)
379+
pretty.templates.unhandled(fix, names, target)
368380
```
369381

370382
## Extending

0 commit comments

Comments
 (0)