Editor Support
pgfence ships an LSP server in the OSS npm package. The VS Code extension is a thin client on top of that server, and other editors can launch the same server directly.
Install
If you use VS Code, install the extension from the VS Code Marketplace or from the command line:
code --install-extension flvmnt.pgfence The extension requires the OSS package in your project or a global install:
# In your project (recommended)
npm install -D @flvmnt/pgfence
# Or globally
npm install -g @flvmnt/pgfence For editors like Neovim, Helix, or Zed, launch the bundled server with either entrypoint:
npx @flvmnt/pgfence lsp
# or
pgfence-lsp Features
Diagnostics
The public LSP server surfaces the same core checks as the CLI:
- Lock mode and risk diagnostics for dangerous DDL
- Policy violations like missing
lock_timeoutorCONCURRENTLYinside transactions - Extraction and parse warnings when a migration cannot be analyzed cleanly
Quick Fixes
Quick fixes are available when pgfence has a runnable safe rewrite for the statement. If a rewrite is guidance-only or still contains placeholders, the server keeps the rewrite in hover text but does not offer a one-click replacement.
Every flagged statement can still get a pgfence-ignore quick fix for an inline suppression comment.
Hover
Hover cards show the exact lock mode, what gets blocked, the risk level, and any safe alternative recipe attached to that finding.
Statement Surfaces
The shipped LSP server also exposes:
- Document symbols, one entry per flagged SQL statement
- Folding ranges for multi-line flagged statements
- Inlay hints that show lock mode and risk at the end of a statement
Supported Files
- Raw
.sqlfiles - TypeORM migration source files
- Knex migration source files
- Sequelize migration source files
- Prisma and Drizzle generated SQL migration files
For TypeORM, Knex, and Sequelize, the LSP analyzes the current in-memory editor buffer, not just what is on disk. Unsaved edits are included in diagnostics.
Configuration
The current public LSP server reads these workspace settings:
| Setting | Default | Description |
|---|---|---|
pgfence.minPostgresVersion | 14 | Minimum PostgreSQL version to assume |
pgfence.requireLockTimeout | true | Require SET lock_timeout in every migration |
pgfence.requireStatementTimeout | true | Require SET statement_timeout in every migration |
How It Works
The VS Code extension discovers @flvmnt/pgfence from your workspace node_modules first, then from a global install. It launches the bundled LSP server over stdio.
The same analyzer, extractors, and rule engine power both the CLI and editor surfaces, so diagnostics, hover content, and quick fixes stay aligned with pgfence analyze.