Basic dbcli query history viewer support with telescope
This plugin will only work on Neovim nightly (0.5). It also assumes you are already using the popular telescope plugin which can be found here and that you are using some of the dbcli tools i.e. pgcli, mssql-cli
Using your preferred plugin manager ( Packer and vim-plug for example )
-- Packer
use { 'mark-coyle/telescope-dbcli.nvim' }
-- Plug
Plug 'mark-coyle/telescope-dbcli.nvim'
Run your plugin managers installer :PackerSync/:PlugInstall
Then load the extension in your lua/viml config
-- in lua
require('telescope').load_extension('dbcli')
-- in vimscript
:lua require('telescope').load_extension('dbcli')
After installing, you should now be able to run :Telescope dbcli
or you can map it as you like using something like
:lua require('telescope').extensions.dbcli.pgcli()
:lua require('telescope').extensions.dbcli.mssql_cli()
As it happens, pgcli
and mssql-cli
have history files that share a format, the same underlying picker logic works for both.
As such, you can define the history file path and the prompt title for none, either or both in the telescope extension config.
The defaults for the following config options are the values used in the example, should you need to change the defaults, you can override them like so:
require('telescope').setup {
extensions = {
dbcli = {
pgcli = {
prompt_title = 'Pgcli History'
history_file = os.getenv('HOME') .. "/.config/pgcli/history",
display_timestamp_in_finder = true
},
mssql_cli = {
prompt_title = 'Mssql-cli History'
history_file = os.getenv('HOME') .. "/.config/mssqlcli/history",
display_timestamp_in_finder = true
},
on_query_select = {
open_in_scratch_buffer = true,
add_query_to_register = false
}
}
}
}