*ft_sql.txt* Nvim
by David Fishburn
This is a filetype plugin to work with SQL files.
The Structured Query Language (SQL) is a standard which specifies statements
that allow a user to interact with a relational database. Vim includes
features for navigation, indentation and syntax highlighting.
1. Navigation |sql-navigation|
1.1 Matchit |sql-matchit|
1.2 Text Object Motions |sql-object-motions|
1.3 Predefined Object Motions |sql-predefined-objects|
1.4 Macros |sql-macros|
2. SQL Dialects |sql-dialects|
2.1 SQLSetType |SQLSetType|
2.2 SQLGetType |SQLGetType|
2.3 SQL Dialect Default |sql-type-default|
3. Adding new SQL Dialects |sql-adding-dialects|
4. OMNI SQL Completion |sql-completion|
4.1 Static mode |sql-completion-static|
4.2 Dynamic mode |sql-completion-dynamic|
4.3 Tutorial |sql-completion-tutorial|
4.3.1 Complete Tables |sql-completion-tables|
4.3.2 Complete Columns |sql-completion-columns|
4.3.3 Complete Procedures |sql-completion-procedures|
4.3.4 Complete Views |sql-completion-views|
4.4 Completion Customization |sql-completion-customization|
4.5 SQL Maps |sql-completion-maps|
4.6 Using with other filetypes |sql-completion-filetypes|
==============================================================================
1. Navigation *sql-navigation*
The SQL ftplugin provides a number of options to assist with file
navigation.
------------------------------------------------------------------------------
1.1 Matchit *sql-matchit*
The matchit plugin (https://www.vim.org/scripts/script.php?script_id=39)
provides many additional features and can be customized for different
languages. The matchit plugin is configured by defining a local
buffer variable, b:match_words. Pressing the % key while on various
keywords will move the cursor to its match. For example, if the cursor
is on an "if", pressing % will cycle between the "else", "elseif" and
"end if" keywords.
The following keywords are supported: >
if
elseif | elsif
else [if]
end if
[while condition] loop
leave
break
continue
exit
end loop
for
leave
break
continue
exit
end loop
do
statements
doend
case
when
when
default
end case
merge
when not matched
when matched
create[ or replace] procedure|function|event
returns
------------------------------------------------------------------------------
1.2 Text Object Motions *sql-object-motions*
Vim has a number of predefined keys for working with text |object-motions|.
This filetype plugin attempts to translate these keys to maps which make sense
for the SQL language.
The following |Normal| mode and |Visual| mode maps exist (when you edit a SQL
file): >
]] move forward to the next 'begin'
[[ move backwards to the previous 'begin'
][ move forward to the next 'end'
[] move backwards to the previous 'end'
------------------------------------------------------------------------------
1.3 Predefined Object Motions *sql-predefined-objects*
Most relational databases support various standard features, tables, indices,
triggers and stored procedures. Each vendor also has a variety of proprietary
objects. The next set of maps have been created to help move between these
objects. Depends on which database vendor you are using, the list of objects
must be configurable. The filetype plugin attempts to define many of the
standard objects, plus many additional ones. In order to make this as
flexible as possible, you can override the list of objects from within your
|vimrc| with the following: >
let g:ftplugin_sql_objects = 'function,procedure,event,table,trigger' ..
\ ',schema,service,publication,database,datatype,domain' ..
\ ',index,subscription,synchronization,view,variable'
The following |Normal| mode and |Visual| mode maps have been created which use
the above list: