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:
@@ -0,0 +1,3 @@
|
||||
.gradle/
|
||||
build/
|
||||
*.zip
|
||||
@@ -0,0 +1,37 @@
|
||||
# PgTidy — DataGrip / JetBrains Plugin
|
||||
|
||||
Formats and lints SQL files in DataGrip (and any JetBrains IDE) via the LSP4IJ plugin.
|
||||
|
||||
## Requirements
|
||||
|
||||
- `pgtidy` binary on `PATH` — download from [releases](https://git.warky.dev/wdevs/PgTidy/releases) or build with `go install git.warky.dev/wdevs/pgtidy/cmd/pgtidy@latest`
|
||||
- [LSP4IJ](https://plugins.jetbrains.com/plugin/23257-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`)
|
||||
|
||||
1. Build: `./gradlew buildPlugin` (output in `build/distributions/`)
|
||||
2. In DataGrip: **Settings → Plugins → ⚙ → Install Plugin from Disk…** → select the `.zip`
|
||||
3. Restart the IDE
|
||||
|
||||
### Option B — Install LSP4IJ and configure manually (no plugin build needed)
|
||||
|
||||
1. Install **LSP4IJ** from the marketplace (**Settings → Plugins → Marketplace → search "LSP4IJ"**)
|
||||
2. Go to **Settings → Language Servers → + (Add)**
|
||||
3. Fill in:
|
||||
- **Name:** `PgTidy`
|
||||
- **Command:** `pgtidy lsp`
|
||||
4. Under **Mappings**, add file patterns: `*.sql`, `*.pgsql`
|
||||
5. 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 (add `NOT 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`.
|
||||
@@ -0,0 +1,48 @@
|
||||
plugins {
|
||||
id("org.jetbrains.intellij.platform") version "2.3.0"
|
||||
kotlin("jvm") version "2.0.0"
|
||||
}
|
||||
|
||||
group = providers.gradleProperty("pluginGroup").get()
|
||||
version = providers.gradleProperty("pluginVersion").get()
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(17)
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
intellijPlatform {
|
||||
defaultRepositories()
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
intellijPlatform {
|
||||
val platformVersion = providers.gradleProperty("platformVersion")
|
||||
val platformType = providers.gradleProperty("platformType")
|
||||
create(platformType, platformVersion)
|
||||
bundledPlugin("com.intellij.database")
|
||||
plugin("com.redhat.devtools.lsp4ij:${providers.gradleProperty("lsp4ijVersion").get()}")
|
||||
instrumentationTools()
|
||||
}
|
||||
}
|
||||
|
||||
intellijPlatform {
|
||||
pluginConfiguration {
|
||||
name = providers.gradleProperty("pluginName")
|
||||
version = providers.gradleProperty("pluginVersion")
|
||||
ideaVersion {
|
||||
sinceBuild = providers.gradleProperty("pluginSinceBuild")
|
||||
}
|
||||
}
|
||||
signing {
|
||||
// Set CERTIFICATE_CHAIN, PRIVATE_KEY, PRIVATE_KEY_PASSWORD env vars for release signing.
|
||||
certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN")
|
||||
privateKey = providers.environmentVariable("PRIVATE_KEY")
|
||||
privateKeyPassword = providers.environmentVariable("PRIVATE_KEY_PASSWORD")
|
||||
}
|
||||
publishing {
|
||||
token = providers.environmentVariable("PUBLISH_TOKEN")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
pluginGroup=com.pgtidy
|
||||
pluginName=PgTidy
|
||||
pluginVersion=0.1.0
|
||||
pluginSinceBuild=243
|
||||
# DataGrip 2024.3
|
||||
platformVersion=2024.3
|
||||
platformType=DB
|
||||
lsp4ijVersion=0.8.0
|
||||
@@ -0,0 +1,5 @@
|
||||
rootProject.name = "pgtidy-datagrip"
|
||||
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.pgtidy.datagrip
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.redhat.devtools.lsp4ij.server.ProcessStreamConnectionProvider
|
||||
|
||||
class PgTidyServerConnection(project: Project) : ProcessStreamConnectionProvider(
|
||||
listOf("pgtidy", "lsp"),
|
||||
project.basePath ?: System.getProperty("user.home"),
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.pgtidy.datagrip
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.redhat.devtools.lsp4ij.LanguageServerFactory
|
||||
import com.redhat.devtools.lsp4ij.server.StreamConnectionProvider
|
||||
|
||||
class PgTidyServerFactory : LanguageServerFactory {
|
||||
override fun createConnectionProvider(project: Project): StreamConnectionProvider =
|
||||
PgTidyServerConnection(project)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<idea-plugin>
|
||||
<id>com.pgtidy.datagrip</id>
|
||||
<name>PgTidy</name>
|
||||
<version>0.1.0</version>
|
||||
<vendor url="https://git.warky.dev/wdevs/PgTidy">Warky Devs</vendor>
|
||||
<description><![CDATA[
|
||||
PostgreSQL formatter and linter powered by <a href="https://github.com/hein/pgtidy">pgtidy</a>.<br/>
|
||||
Requires the <code>pgtidy</code> binary on PATH and the
|
||||
<a href="https://plugins.jetbrains.com/plugin/23257-lsp4ij">LSP4IJ</a> plugin.
|
||||
]]></description>
|
||||
|
||||
<depends>com.intellij.modules.platform</depends>
|
||||
<depends>com.intellij.database</depends>
|
||||
<depends>com.redhat.devtools.lsp4ij</depends>
|
||||
|
||||
<extensions defaultExtensionNs="com.redhat.devtools.lsp4ij">
|
||||
<server id="com.pgtidy.lsp"
|
||||
name="PgTidy"
|
||||
factoryClass="com.pgtidy.datagrip.PgTidyServerFactory">
|
||||
<description>PostgreSQL formatter and linter (pgtidy lsp)</description>
|
||||
</server>
|
||||
|
||||
<fileNamePatternMapping patterns="*.sql;*.pgsql"
|
||||
serverId="com.pgtidy.lsp"
|
||||
languageId="SQL"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Reference in New Issue
Block a user