Use the omnicomplete popup menu to explore and complete SQL table and column
names. The plugin currently supports mysql
and postgres
databases.
The plugin provides one function to call for completing tables and columns and a convenience function for easily switching the database that suggestions are provided for.
You will need to map the complete function in insert mode. Here is an example.
<Leader>sc
will complete for columns and <Leader>st
will complete for
tables.
inoremap <Leader>sc <C-R>=SQLComplete("column")<CR>
inoremap <Leader>st <C-R>=SQLComplete("table")<CR>
You can set a default database by setting the variable suggest_db
in your .vimrc
like so:
let g:suggest_db = "psql -U Jrock example_table"
You can also use the command UpdateSuggestDB
to easily set the database that
the plugin will look in for completions.
Use your plugin manager of choice.
- Pathogen
git clone https://github.com/JarrodCTaylor/vim-sql-suggest ~/.vim/bundle/vim-sql-suggest
- Vundle
- Add
Bundle 'JarrodCTaylor/vim-sql-suggest'
to .vimrc - Run
:BundleInstall
- Add
- NeoBundle
- Add
NeoBundle 'JarrodCTaylor/vim-sql-suggest'
to .vimrc - Run
:NeoBundleInstall
- Add
- vim-plug
- Add
Plug 'JarrodCTaylor/vim-sql-suggest'
to .vimrc - Run
:PlugInstall
- Add