Skip to content

Sublime Text syntax definitions for SQL, rebuilt with better semantics. Currently only Postgres dialect.

License

Notifications You must be signed in to change notification settings

mitranim/sublime-sql

Repository files navigation

Overview

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 than storage.
  • 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 or delete.
  • 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.

Installation

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.

TODO

(Because I'll forget otherwise.)

  • More contextual keywords.
  • PL/PGSQL.
  • Better support for types.
  • A million other Postgres-specific things.

License

https://unlicense.org

Misc

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

About

Sublime Text syntax definitions for SQL, rebuilt with better semantics. Currently only Postgres dialect.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published