Sublime Text syntax for Postgres SQL. Written in SBNF:
- Source file:
pgsql.sbnf
. - Auto-generated syntax:
pgsql.sublime-syntax
.
Differences from built-in "SQL" and Package Control packages "PgSQL" and "PostgreSQL Syntax Highlighting":
- Contextual types.
- Types are scoped only where expected.
- No whitelist of built-ins.
- No difference between pre-defined and user-defined types.
- Conservative use of keywords.
- Only reserved keywords and extremely common keywords are context-free.
- Other keywords are contextual, where expected.
- No unnecessary scopes for built-in functions or types.
- Prefers to scope keywords as
keyword
rather thanstorage
. - Adheres more closely to ST scope conventions while respecting SQL semantics.
- Supports ordinal parameters like
$1
and named parameters like:ident
.
Current limitations:
- Only the Postgres dialect is implemented.
- Doesn't implement some non-reserved but common keywords such as
update
ordelete
. - Doesn't implement some contextual keywords such as
on update cascade
. - NYI: PL/PGSQL.
- NYI: multi-word types.
- NYI: function calls.
- ... Probably a few more NYI.
Despite the limitations, I consider this much more usable than the previously-mentioned packages.
Clone the repo and symlink it to your Sublime packages directory. Example for MacOS:
git clone https://github.com/mitranim/sublime-sql.git
cd sublime-sql
ln -sf "$(pwd)" "$HOME/Library/Application Support/Sublime Text 3/Packages/"
To find the packages directory on your system, use Sublime Text menu → Preferences → Browse Packages.
(Because I'll forget otherwise.)
- More contextual keywords.
- PL/PGSQL.
- Better support for types.
- A million other Postgres-specific things.
I'm receptive to suggestions. If this package almost satisfies you but needs changes, open an issue or chat me up. Contacts: https://mitranim.com/#contacts