https://github.com/prosumma/vim-pgsql
PGSQL syntax highlighting, etc.
https://github.com/prosumma/vim-pgsql
Last synced: 4 months ago
JSON representation
PGSQL syntax highlighting, etc.
- Host: GitHub
- URL: https://github.com/prosumma/vim-pgsql
- Owner: Prosumma
- Created: 2014-10-07T20:16:39.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-12-03T03:52:26.000Z (over 10 years ago)
- Last Synced: 2025-06-22T18:53:43.685Z (12 months ago)
- Language: VimL
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Opinionated Syntax Highlighting For PostgreSQL In Vim!
====
I started with Devrim Gunduz' psql.vim at http://www.gunduz.org/postgresql/pgsql.vim, but very little of that remains. This is PG highlighting the way I use it. It may be useful to you, it may not. I suspect it will work very well for most, and if not, it's not too hard to fork.
Some improvements:
Syntax Highlighting For Function Bodies
----
CREATE FUNCTION foo(_x INTEGER) RETURNS INTEGER
STRICT IMMUTABLE
AS $$
BEGIN
RETURN _x;
END;
$$;
The text inside the $$ delimiters will be highlighted. Of course, the syntax highlighting is _always_ more PostgreSQL highlighting, since that's all I ever use. (I've considered conventions such as $PYTHON$ or $PGSQL$ with $PGSQL$ being the default, but since I don't use Python in PG, I never had the motivation.)
A Broader Set Of Keywords
----
I've done a good, but probably imperfect job of adding far more keywords and trying to get them to work contextually.
Variables
---
One of the things I've always liked about Microsoft's SQL Server is the @ sigil it uses for variables. This makes them stand out and prevents collisions with field names. Sadly, PG has no such sigil, and its parser won't allow you to use one. As a compromise, I always prefix my variables with an underscore, e.g., \_foo. _If you do this, you will get syntax highlighting for variables._ They will stand out nicely, depending upon your color scheme.