PgTidy — DataGrip / JetBrains Plugin
Formats SQL files in DataGrip (and any JetBrains IDE) by shelling out to the pgtidy binary.
Requirements
pgtidybinary onPATH— download from releases or build withgo install git.warky.dev/wdevs/pgtidy/cmd/pgtidy@latest- DataGrip 2024.3+ (or any JetBrains IDE 2024.3+)
Install the plugin
- Build:
./gradlew buildPlugin(output inbuild/distributions/) - In DataGrip: Settings → Plugins → ⚙ → Install Plugin from Disk… → select the
.zip - Restart the IDE
Features
- Formatting —
Format with PgTidy(Ctrl+Alt+Shift+Por right-click in the editor) formats the current SQL file viapgtidy fmt - Version check —
Tools → Show PgTidy Versionand the status bar widget show the installedpgtidyversion - Diagnostics — lint findings (MIG001–MIG003, COR001–003, NAM001–003) are shown inline as editor annotations, via a native
ExternalAnnotatorthat runspgtidy lint --json - Quick fixes — intention actions for MIG001 (add
CONCURRENTLY) and MIG003 (addNOT VALID)
Troubleshooting
"Cannot start pgtidy" error: the pgtidy binary isn't on PATH for the IDE process. Install it or restart the IDE after adding it to PATH.
No diagnostics showing: diagnostics only run on files with a .sql or .pgsql extension; check pgtidy lint --json runs cleanly on the file from a terminal with the same PATH as the IDE.