dotfiles/.config/nvim/lua/plugins/extras/db.lua
Sergio Laín c4e8fe2941
♻️ refactor(nvim): big changes to the config structure
a lot of plugins are moving to the extra modules
all the keymaps are on the keys section of each plugin
which-key options are now dependant on the plugin they are in, etc
2023-10-20 15:01:41 +02:00

52 lines
1.4 KiB
Lua

return {
{
"tpope/vim-dadbod",
dependencies = {
"kristijanhusak/vim-dadbod-ui",
"kristijanhusak/vim-dadbod-completion",
"jsborjesson/vim-uppercase-sql",
},
cmd = { "DBUI", "DBUIToggle" },
ft = "sql",
opts = {
db_competion = function()
require("cmp").setup.buffer({ sources = { { name = "vim-dadbod-completion" } } })
end,
},
config = function(_, opts)
vim.g.db_ui_save_location = vim.fn.stdpath("config") .. require("plenary.path").path.sep .. "db_ui"
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"sql",
},
command = [[setlocal omnifunc=vim_dadbod_completion#omni]],
})
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"sql",
"mysql",
"plsql",
},
callback = function()
vim.schedule(opts.db_completion)
end,
})
end,
keys = {
{ "<leader>Dt", "<cmd>DBUIToggle<cr>", desc = "Toggle UI" },
{ "<leader>Df", "<cmd>DBUIFindBuffer<cr>", desc = "Find Buffer" },
{ "<leader>Dr", "<cmd>DBUIRenameBuffer<cr>", desc = "Rename Buffer" },
{ "<leader>Dq", "<cmd>DBUILastQueryInfo<cr>", desc = "Last Query Info" },
},
},
{
"folke/which-key.nvim",
opts = {
defaults = {
["<leader>D"] = { name = "+database" },
},
},
},
}