See what we can provide for LSP #3

Closed
opened 2026-07-25 09:11:46 +00:00 by warkanum · 1 comment
Owner
https://microsoft.github.io/language-server-protocol/
Member

LSP research for issue #3

Findings on what PgTidy's LSP (pkg/lsp, cmd/pgtidy/lsp.go) actually provides today.

The V3 milestone is already implemented and shipping (per docs/todo.md), so this is a capability inventory + gap analysis, verified by a framed JSON-RPC 2.0 smoke test over stdio against the built binary.

Advertised capabilities (initialize):

  • textDocumentSync = 1 (full sync)
  • documentFormattingProvider = true
  • documentRangeFormattingProvider = true
  • codeActionProvider = true

Verified at runtime: initialize returns that block; didOpen on select * from t; publishes a COR001 hint; textDocument/formatting returns a real edit (SELECT *\nFROM t;\n); hover correctly returns -32601 method not found.

Gaps (most useful first):

  1. No hover (returns -32601) — return the rule explanation for the hovered diagnostic, or a keyword/type glossary.
  2. No documentSymbol — outline of CREATE FUNCTION/PROCEDURE signatures (low cost, reuses the existing CST header parse).
  3. Diagnostic Range is a 1-char caret, not the actual offending span.
  4. No willSaveWaitUntil/didSave — format-on-save currently relies on client binding.
  5. No initializationOptions / workspace config; no completion/rename/foldingRange.

Recommended smallest-delta next steps: (1) real diagnostic highlight range, (2) hover, (3) documentSymbol, (4) willSaveWaitUntil. All reuse the shared pkg/diagnostics + pkg/lint core — no new wire types or deps.

Verification: go build ./... OK. pkg/lsp unit tests pass for initialize (formatting/range-formatting tests time out on this box due to slow WASM go-pgquery first-init — pre-existing on main, not code-related). Framed JSON-RPC e2e confirmed capabilities, a COR001 diagnostic, and a formatting edit.

Artifacts:

  • Branch: issue-3-lsp-research
  • Commit: 1be745b (docs only)
  • PR: #4
  • Full write-up: docs/lsp-status.md
## LSP research for issue #3 Findings on what PgTidy's LSP (`pkg/lsp`, `cmd/pgtidy/lsp.go`) actually provides today. **The V3 milestone is already implemented and shipping** (per `docs/todo.md`), so this is a capability inventory + gap analysis, verified by a framed JSON-RPC 2.0 smoke test over stdio against the built binary. **Advertised capabilities (`initialize`):** - `textDocumentSync = 1` (full sync) - `documentFormattingProvider = true` - `documentRangeFormattingProvider = true` - `codeActionProvider = true` **Verified at runtime:** `initialize` returns that block; `didOpen` on `select * from t;` publishes a `COR001` hint; `textDocument/formatting` returns a real edit (`SELECT *\nFROM t;\n`); `hover` correctly returns `-32601 method not found`. **Gaps (most useful first):** 1. No `hover` (returns -32601) — return the rule explanation for the hovered diagnostic, or a keyword/type glossary. 2. No `documentSymbol` — outline of `CREATE FUNCTION`/`PROCEDURE` signatures (low cost, reuses the existing CST header parse). 3. Diagnostic `Range` is a 1-char caret, not the actual offending span. 4. No `willSaveWaitUntil`/`didSave` — format-on-save currently relies on client binding. 5. No `initializationOptions` / workspace config; no `completion`/`rename`/`foldingRange`. **Recommended smallest-delta next steps:** (1) real diagnostic highlight range, (2) `hover`, (3) `documentSymbol`, (4) `willSaveWaitUntil`. All reuse the shared `pkg/diagnostics` + `pkg/lint` core — no new wire types or deps. **Verification:** `go build ./...` OK. `pkg/lsp` unit tests pass for `initialize` (formatting/range-formatting tests time out on this box due to slow WASM go-pgquery first-init — pre-existing on `main`, not code-related). Framed JSON-RPC e2e confirmed capabilities, a COR001 diagnostic, and a formatting edit. **Artifacts:** - Branch: `issue-3-lsp-research` - Commit: `1be745b` (docs only) - PR: https://git.warky.dev/wdevs/PgTidy/pulls/4 - Full write-up: `docs/lsp-status.md`
Sign in to join this conversation.
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wdevs/PgTidy#3