* Implement PgTidyFormatAction to format SQL using pgtidy * Register action in plugin.xml with keyboard shortcut * Update dependencies for bundled plugins * Modify build configuration for Gradle wrapper
PgTidy — DataGrip / JetBrains Plugin
Formats and lints SQL files in DataGrip (and any JetBrains IDE) via the LSP4IJ plugin.
Requirements
pgtidybinary onPATH— download from releases or build withgo install git.warky.dev/wdevs/pgtidy/cmd/pgtidy@latest- LSP4IJ plugin installed (free, by Red Hat)
- DataGrip 2024.3+ (or any JetBrains IDE 2024.3+)
Install the plugin
Option A — Install from disk (.zip)
- Build:
./gradlew buildPlugin(output inbuild/distributions/) - In DataGrip: Settings → Plugins → ⚙ → Install Plugin from Disk… → select the
.zip - Restart the IDE
Option B — Install LSP4IJ and configure manually (no plugin build needed)
- Install LSP4IJ from the marketplace (Settings → Plugins → Marketplace → search "LSP4IJ")
- Go to Settings → Language Servers → + (Add)
- Fill in:
- Name:
PgTidy - Command:
pgtidy lsp
- Name:
- Under Mappings, add file patterns:
*.sql,*.pgsql - Click OK and restart the IDE
Features
- Formatting —
Code → Reformat Code(Ctrl+Alt+L) formats the current SQL file - Diagnostics — lint findings shown as inspections (MIG001–MIG003, COR001–003, NAM001–003)
- Quick fixes — intention actions for MIG001 (add
CONCURRENTLY) and MIG003 (addNOT VALID)
Troubleshooting
Server not starting: Check View → Tool Windows → LSP4IJ Consoles for stderr output. Most common cause: pgtidy not found on PATH — update the command to the full path, e.g. /usr/local/bin/pgtidy lsp.