You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Files with a .pgsql suffix are highlighted out of the box. If you want to
highlight .sql files using this plugin by default, add this to your .vimrc
(see :h ft_sql.txt):
letg:sql_type_default='pgsql'
Alternatively, after loading a .sql file use this command:
:SQLSetType pgsql.vim
To set the file type in new buffers use:
:letb:sql_type_override='pgsql' | setft=sql
Code between $pgsql$ or $$ pairs is treated as PL/pgSQL and highlighted
accordingly:
You may set g:pgsql_pl to a list of file types to be used in user-defined
functions. For example, after setting:
letg:pgsql_pl= ['python']
code between $python$ pairs will be highlighted as Python:
Hacking
The syntax file is generated automatically. If you want to hack it, edit
src/pgsql.sql, then execute:
cd ./src
DBUSER=<user> DBHOST=<hostname> make install
When DBUSER is omitted, postgres is assumed. When DBHOST is omitted,
127.0.0.1 is assumed.
The specified user must be a superuser, because the script will create
a database called vim_pgsql_syntax and a few extensions that require admin
privileges. It will then proceed to extract all the keywords. Feel free to
browse the source scripts to see exactly what they do.
The above command will update syntax/pgsql.vim. Use make distclean to drop
the database (or drop it manually).
The script has been tested in macOS, but it should work on any *nix system.
Acknowledgments
This plugin was originally based on code from
space::tekk (and completely
rewritten).