A small reproducible playground for pgls
— exercises completion, hover, and diagnostics in both .sql files and
SQL string literals inside .go files.
.pgls.json -- Tells pgls to load DDL from ./schema (auto-discovered)
schema/
users.sql -- CREATE TABLE definitions
orders.sql
example.sql -- Standalone SQL file to play with
main.go -- Backtick SQL strings inside Go source
-
Install the pgls server binary:
go install github.com/winebarrel/pgls@latest
-
Install an editor client:
- VSCode: https://github.com/winebarrel/pgls-vscode
- Neovim / Vim / Helix: see the pgls README
-
Open this folder in your editor — pgls picks up
.pgls.jsonautomatically, no per-editorschemaDirconfiguration needed.
Open example.sql or main.go and:
- Place the cursor after
FROM→ completion offersusers,orders. - After
SELECT(withFROM users u JOIN orders o) → completion offers columns scoped to those two tables, and the duplicateidshows asu.id/o.id. - After
u.→ only the columns ofusers. - Hover over
email→users.email varchar. - Hover over
users→ a markdown table of the columns. - Cmd+click on a table or
u.email→ opens the corresponding row inschema/users.sql. - Uncomment the diagnostic-fire lines at the bottom of either file to
see
pglsflag the typos.
main.go shows two ways pgls picks up SQL strings:
- Marker form (
q1,q2): a// language=sqlcomment on the line directly above flags the string as SQL. - Function-call form (
db.Query(...)): no comment needed — pgls's defaultsqlFunctionsset coversdatabase/sql'sQuery/Exec/Prepareand their*Contextvariants.
Strings outside both paths (notSQL in the example) are
intentionally ignored.
MIT