Skip to content

feat(lsp): alias definition, references and rename - #27

Merged
gandarfh merged 1 commit into
mainfrom
feat/lsp-nav-trio
Jun 13, 2026
Merged

feat(lsp): alias definition, references and rename#27
gandarfh merged 1 commit into
mainfrom
feat/lsp-nav-trio

Conversation

@gandarfh

Copy link
Copy Markdown
Member

Slice 3 core: the navigation/refactor trio over block aliases. The handler had hover/completion/semanticTokens/diagnostics; this adds go-to-definition, find-all-references and rename — reusing the existing alias/scope analysis (no new inference).

Pure core (analyze.ml): symbol_at blocks ~offset resolves the alias symbol under the cursor — the cursor may sit on the alias value in a fence info string (a declaration) or on the name token of a {{alias...}} reference. Returns the declaration range + the name-token range of every reference that resolves to that same declaration (nearest-aliased-above, honoring shadowing; $prev resolves via prev_decl). Path segments and prose yield None — so rename never touches text that merely looks like an alias.

Handlers (httui_lsp.ml) mirror on_hover: on_definition (Location), on_references (honors includeDeclaration), on_rename (WorkspaceEdit over the single document; $prev is a no-op — positional, no name token). Capabilities advertise definition/references/rename providers. Intra-document only (refs never cross files — DAG within one doc).

Tests (test_lsp.ml, +7): definition→declaration, references incl/excl declaration (3/2), rename produces decl + 2 ref-name edits, the {{req1.req1}} path segment is NOT renamed (the RFC exit criterion), every edit writes the new name, and $prev (definition resolves to the previous block, rename is null). 119 total green; bench --check gate still green (nav is on-demand, no per-keystroke cost).

Follow-up (separate PR): desktop wiring (go-to-def/find-refs/rename via @codemirror/lsp-client + keybindings) and removing cm-references.ts/cm-autocomplete.ts.

@gandarfh
gandarfh merged commit 5917597 into main Jun 13, 2026
9 checks passed
@gandarfh
gandarfh deleted the feat/lsp-nav-trio branch June 13, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant