▍ humdrum codex / glint v1.1.2
license AGPL-3.0
5.5 KB raw

Harper grammar actions — replacement & ignore (TASK-044)

Goal

Make glint's green grammar underlines actionable. On a grammar span at the cursor (Alt+;) or under a click, offer Harper's fix suggestions as replacement rows in the existing proofing popup, plus an Ignore action. Selecting a replacement applies Harper's edit to the buffer; Ignore suppresses that lint for the session.

Builds on TASK-043, which renders diagnostics only. Reuses the spell popup (spellOption/applySpell) plumbing.

Findings from live harper-ls 2.6 probe

These facts drove the design and narrowed scope:

  1. Replacement works. textDocument/codeAction for a diagnostic's range returns quickfix CodeActions: a Harper-authored title (e.g. Replace with: "an") plus edit.changes[uri] = [{range, newText}]. Each also carries a HarperRecordLint telemetry command we ignore. The response also includes bare Command objects {command:"HarperIgnoreLint", arguments:[uri, lint], title:"Ignore Harper error."}.
  2. HarperIgnoreLint is a no-op over LSP. Executing the command harper returns (verbatim args) yields null and never drops the lint — no changed re-publish after didChange, nothing written to ~/.config/harper-ls/ignored_lints/. So ignore must be implemented glint-side.
  3. Add-to-dictionary is never offered for grammar lints (spelling-only concept). Dropped from scope.
  4. Config reply bug. glint answers workspace/configuration with bare {}, causing harper's ERROR: Settings must contain a "harper-ls" key.. Reply must be {"harper-ls": {}}. Harmless to diagnostics but fixed here.

Scope

In: grammar-span replacement suggestions; client-side session ignore; the config fix. Out: add-to-dictionary for grammar; persistent (cross-launch) ignore; executing HarperIgnoreLint.

Design

grammar package

Synchronous CodeActions (blocking ≤400ms) is acceptable: user-initiated, rare, harper is local. readLoop runs in its own goroutine, so the Update-thread block resolves without deadlock.

editor package

app package

Testing (TDD)

Acceptance criteria (revised)