feat: add LSP server, VSCode + DataGrip extensions, release infra, autofix
- pkg/lsp: JSON-RPC 2.0 LSP server (formatting, diagnostics, codeAction quick-fixes) - cmd/pgtidy: lsp and config subcommands - pkg/diagnostics: TextFix struct for byte-range autofixes - pkg/lint: MIG001/MIG003 autofixes, ApplyFixes helper, --fix flag on lint command - editors/vscode: TypeScript extension with LanguageClient, showVersion/showConfig/formatDocument commands, logo - editors/datagrip: Gradle JetBrains plugin via LSP4IJ, pluginIcon - .goreleaser.yaml, .github/workflows: CI + release pipeline - Makefile: snapshot, release, vscode-compile, vscode-package targets - go.mod + all imports: module path updated to git.warky.dev/wdevs/pgtidy - assets: logo files (256px, 128px, 1024px, ico)
This commit is contained in:
+23
-11
@@ -9,7 +9,7 @@ Legend: ✅ done · 🚧 in progress · ⬜ not started
|
||||
## V1 — Formatter + CLI (current milestone)
|
||||
|
||||
### ✅ Scaffold module + repo hygiene
|
||||
- `go.mod` (`module github.com/hein/pgtidy`, go 1.26).
|
||||
- `go.mod` (`module git.warky.dev/wdevs/pgtidy`, go 1.26).
|
||||
- Replaced WkMailSync boilerplate: `AGENTS.md` (PgTidy architecture + invariants),
|
||||
`CLAUDE.md`, `Makefile` (`build`/`test`/`vet`/`fmt`/`lint`/`clean`).
|
||||
- Directory layout created (`cmd/`, `pkg/...`, `testdata/`).
|
||||
@@ -108,21 +108,33 @@ Legend: ✅ done · 🚧 in progress · ⬜ not started
|
||||
- NAM001/2/3 table/column/function names not snake_case (quoted identifiers only)
|
||||
- `pgtidy lint [--only=ID,...] [files...]`; exits 1 on findings, 2 on error.
|
||||
- Fixture SQL in `testdata/lint/`; 6 tests covering violations + clean fixtures.
|
||||
- _`--fix` for autofixable rules: future._
|
||||
- `--fix` rewrites files in place applying autofixes; for stdin, prints fixed SQL to stdout.
|
||||
- Autofixable: **MIG001** (insert `CONCURRENTLY` after `INDEX`) and **MIG003** (insert `NOT VALID` before `;`). MIG002, COR*, NAM* are intentionally not autofixable.
|
||||
- `pkg/diagnostics.TextFix{Offset, End, New, Title}` — byte-range replacement attached to `Diagnostic.Fix`.
|
||||
- `pkg/lint.ApplyFixes` — applies all fixes in reverse-offset order; overlapping fixes skipped.
|
||||
- Fix helpers (`mig001Fix`, `mig003Fix`) handle pg_query's convention of `StmtLen` excluding the trailing `;`.
|
||||
|
||||
## V3 — LSP + VSCode (later)
|
||||
- `pkg/lsp`: formatting + range formatting, publishDiagnostics, codeAction quick-fixes.
|
||||
- `editors/vscode`: TS extension (`vscode-languageclient`) launching bundled `pgtidy lsp`;
|
||||
per-platform VSIX matrix in CI (rust-analyzer model) + target-less fallback.
|
||||
## ✅ V3 — LSP + VSCode
|
||||
- `pkg/lsp`: JSON-RPC 2.0 over stdio; `textDocument/formatting` (full document), `publishDiagnostics` on every open/change, `textDocument/codeAction` quick-fixes, lifecycle (initialize/shutdown/exit). No external deps.
|
||||
- `cmd/pgtidy/lsp.go`: `pgtidy lsp` subcommand; config discovered from cwd.
|
||||
- `editors/vscode/`: TS extension using `vscode-languageclient`; launches `pgtidy lsp` via stdio; `.pgsql` mapped to `sql` language; `pgtidy.path` / `pgtidy.enable` settings.
|
||||
- _Range formatting: future._
|
||||
|
||||
## V4 — DataGrip (later)
|
||||
- `editors/datagrip`: integrate via free **LSP4IJ** plugin.
|
||||
## ✅ V4 — DataGrip
|
||||
- `editors/datagrip/`: Gradle-based JetBrains plugin targeting DataGrip 2024.3+ via LSP4IJ.
|
||||
- `build.gradle.kts` / `settings.gradle.kts` / `gradle.properties` — IntelliJ Platform Gradle Plugin v2.
|
||||
- `plugin.xml` — registers `PgTidyServerFactory` as an LSP4IJ `<server>` extension and maps `*.sql`/`*.pgsql` to it.
|
||||
- `PgTidyServerFactory.kt` + `PgTidyServerConnection.kt` — launches `pgtidy lsp` via `ProcessStreamConnectionProvider`.
|
||||
- Requires LSP4IJ plugin installed in the IDE; `pgtidy` binary on PATH.
|
||||
|
||||
---
|
||||
|
||||
## Build / release (cross-cutting)
|
||||
- ⬜ Add goreleaser for the multi-platform binary matrix (clean: no cgo).
|
||||
- `make_release.sh` retained from boilerplate (generic version tagging).
|
||||
## ✅ Build / release (cross-cutting)
|
||||
- `.goreleaser.yaml`: multi-platform matrix — linux/darwin × amd64/arm64 + windows/amd64; no CGO; ldflags version injection; draft GitHub release.
|
||||
- `Makefile` extended: `snapshot` (local multi-platform build), `release` (publish), `vscode-compile`, `vscode-package`.
|
||||
- `.github/workflows/ci.yml`: test + vet + gofmt check + goreleaser snapshot on every push/PR.
|
||||
- `.github/workflows/release.yml`: goreleaser publish + VSCode `.vsix` artifact on `v*` tag.
|
||||
- `make_release.sh` retained from boilerplate.
|
||||
|
||||
## Core invariants (must always hold — tested)
|
||||
1. ✅ Lossless lex: `emit(Lex(src)) == src` (corpus round-trip).
|
||||
|
||||
Reference in New Issue
Block a user