# PgTidy — VSCode Extension Formats and lints PostgreSQL/PL-pgSQL files using the `pgtidy` language server. ## Requirements - `pgtidy` binary on `PATH` (see [Build the binary](#build-the-binary) below) - Go 1.21+ (to build from source) - VSCode 1.85+ ## Build the binary **Option A — install directly with Go (recommended):** ```sh go install git.warky.dev/wdevs/pgtidy/cmd/pgtidy@latest ``` The binary lands in `$(go env GOPATH)/bin/`. Make sure that directory is on your `PATH`. **Option B — build from source and place manually:** ```sh git clone https://git.warky.dev/wdevs/PgTidy cd PgTidy go build -o pgtidy ./cmd/pgtidy # Linux / macOS — move to a directory on PATH mv pgtidy /usr/local/bin/ # Windows — move to a directory on PATH, e.g. # move pgtidy.exe C:\tools\ ``` Verify the binary is reachable: ```sh pgtidy version ``` If you place it somewhere not on `PATH`, set the full path in VSCode settings: ```json "pgtidy.path": "/path/to/pgtidy" ``` ## Install from `.vsix` 1. Build the package: `pnpm run build && pnpm run package` 2. In VSCode: **Extensions** → `···` menu → **Install from VSIX…** → select `pgtidy-*.vsix` Or via CLI: ```sh code --install-extension pgtidy-0.1.0.vsix ``` ## Settings | Setting | Default | Description | |---|---|---| | `pgtidy.path` | `"pgtidy"` | Path to the binary if not on `PATH` | | `pgtidy.enable` | `true` | Enable/disable the language server | ## Features - **Format on save** — configure via VSCode's `editor.formatOnSave` - **Diagnostics** — lint findings shown inline as you type (MIG001–MIG003, COR001–003, NAM001–003) - **Quick fixes** — lightbulb actions for MIG001 (add `CONCURRENTLY`) and MIG003 (add `NOT VALID`) `.sql` and `.pgsql` files are both handled. ## Troubleshooting **No formatting / diagnostics:** Open the Output panel → select **PgTidy** to see server errors. Most common cause: `pgtidy` not found — set `pgtidy.path` to the full binary path.