1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'pgsql') == -1
*pgsql.txt* Syntax highlighting for PostgreSQL files
_ ~
| | ~
____ ____ ___ ____| | ~
| _ \ / _ |/___)/ _ | | ~
| |_| ( (_| |___ | |_| | | ~
| __/ \___ (___/ \__ |\_) ~
|_| (_____| |_| ~
The best PostgreSQL plugin for Vim!
Author: Lifepillar <https://github.com/lifepillar>
License: Public Domain
==============================================================================
CONTENTS *pgsql-contents*
1. Syntax highlighting ................... |pgsql-syntax|
2. Customization ......................... |pgsql-customization|
3. Autocompletion ........................ |pgsql-autocompletion|
4. Contributing .......................... |pgsql-contributing|
5. Credits ............................... |pgsql-credits|
==============================================================================
Syntax highlighting *pgsql-syntax*
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 |ft_sql.txt| for more details):
>
let g: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:
>
let b:sql_type_override='pgsql' | set ft=sql
<
Identifiers starting with an underscore are highlighted as variables. It is
recommended to adopt the convention of prefixing function parameters and local
variables with `_`.
Code between `$pgsql$`, `$body$`, or `$$` pairs is interpreted as PL/pgSQL and
highlighted accordingly (the delimiters are case-insensitive). If you prefer
to use `$$` to highlight strings instead, you may set |g:pgsql_dollar_strings|
to 1.
Text enclosed between `$anyword$` pairs, where `anyword` is any non-empty
sequence of word characters different from those with a special meaning (such
as `$pgsql$`) is treated as a multi-line string.
Finally, the plugin supports syntax highlighting of arbitrary languages within
procedure and function blocks. This feature needs to be configured: see
|g:pgsql_pl|.
==============================================================================
Customization *pgsql-customization*
*'g:pgsql_backslash_quote'*
Set to 1 to recognize `\'` as an escape sequence in all strings. By default,
`\'` is treated as an escape sequence only in "escape" strings constants,
i.e., strings enclosed in `E''`.
>
let g:pgsql_backslash_quote = 0
<
*'g:pgsql_disabled_extensions'*
Support for the most common PostgreSQL extensions is enabled by default. Set
this to a List of names of extensions whose keywords you do not want to be
highlighted.
>
let g:pgsql_disabled_extensions = []
<
*'g:pgsql_dollar_strings'*
Set to 1 if you want double-dollar enclosed text highlighted as a SQL string.
By default, text quoted with `$$` is highlighted as PL/pgSQL.
>
let g:pgsql_dollar_strings = 0
<
*'g:pgsql_pl'*
*'b:pgsql_pl'*
A List of the filetypes that should be highlighted inside the body of
user-defined functions and procedures.
>
let g:pgsql_pl = []
<
For example, to use PL/Python and PL/R, you should define:
>
let g:pgsql_pl = ['python', 'r']
<
Then, code between `$python$` pairs will be highlighted as Python, and code
between `$r$` pairs will be highlighted as R.
The buffer-local version of this setting can be used to override the global
setting in a single buffer.
Note: changes to any of these variables take effect after the SQL filetype is
reloaded.
==============================================================================
Autocompletion *pgsql-autocompletion*
This plugin just defines a new dialect for Vim's SQL plugin. As such, it
inherits the static and dynamic completion methods already offered by Vim (see
|sql-completion|). So, for example, by default you may use `<C-c>f` to
complete function names, `<C-c>T` to complete types, and so on. See
|ft_sql.txt| for thorough documentation about SQL support in Vim.
As far as I know, YouCompleteMe does not support SQL. If you use YouCompleteMe
you may want to disable it for SQL buffers. Add this to
`.vim/after/ftplugin/sql.vim`:
>
if exists('g:ycm_filetype_blacklist')
call extend(g:ycm_filetype_blacklist, { 'sql': 1 })
endif
<
Of course, I recommend using my own MUcomplete plugin over YCM ;)
==============================================================================
Contributing *pgsql-contributing*
For bug reports and feature requests please use:
https://github.com/lifepillar/pgsql.vim/issues
Pull requests are welcome, too!
==============================================================================
Credits *pgsql-credits*
This plugin was originally a fork of space::tekk's
https://github.com/spacetekk/pgsql.vim
and completely rewritten.
vim:tw=78:ts=8:noet:ft=help:norl:
endif
|