89 lines
2.2 KiB
Lua
89 lines
2.2 KiB
Lua
-- Database integration with vim-dadbod
|
|
-- Supports PostgreSQL, MySQL, SQLite, and more
|
|
|
|
return {
|
|
-- Core dadbod plugin
|
|
{
|
|
"tpope/vim-dadbod",
|
|
cmd = { "DB", "DBUI", "DBUIToggle", "DBUIAddConnection", "DBUIFindBuffer" },
|
|
},
|
|
|
|
-- UI for dadbod
|
|
{
|
|
"kristijanhusak/vim-dadbod-ui",
|
|
cmd = { "DBUI", "DBUIToggle", "DBUIAddConnection", "DBUIFindBuffer" },
|
|
dependencies = {
|
|
{ "tpope/vim-dadbod", lazy = true },
|
|
},
|
|
init = function()
|
|
-- UI configuration
|
|
vim.g.db_ui_use_nerd_fonts = 1
|
|
vim.g.db_ui_show_database_icon = 1
|
|
vim.g.db_ui_force_echo_notifications = 1
|
|
|
|
-- Save location for connections
|
|
vim.g.db_ui_save_location = vim.fn.stdpath("data") .. "/db_ui"
|
|
|
|
-- Execute on save
|
|
vim.g.db_ui_execute_on_save = 0
|
|
|
|
-- Icons
|
|
vim.g.db_ui_icons = {
|
|
expanded = "▾",
|
|
collapsed = "▸",
|
|
saved_query = "*",
|
|
new_query = "+",
|
|
tables = "~",
|
|
buffers = "»",
|
|
connection_ok = "✓",
|
|
connection_error = "✕",
|
|
}
|
|
end,
|
|
},
|
|
|
|
-- Autocompletion for dadbod
|
|
{
|
|
"kristijanhusak/vim-dadbod-completion",
|
|
dependencies = {
|
|
"tpope/vim-dadbod",
|
|
"hrsh7th/nvim-cmp",
|
|
"nvim-cmp",
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
"hrsh7th/cmp-buffer",
|
|
"hrsh7th/cmp-path",
|
|
},
|
|
ft = { "sql", "mysql", "plsql" },
|
|
init = function()
|
|
-- Setup completion for SQL files
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = { "sql", "mysql", "plsql" },
|
|
callback = function()
|
|
local cmp = require("cmp")
|
|
local sources = cmp.get_config().sources or {}
|
|
|
|
-- Add dadbod completion source
|
|
table.insert(sources, { name = "vim-dadbod-completion" })
|
|
|
|
cmp.setup.buffer({
|
|
sources = cmp.config.sources(sources),
|
|
})
|
|
end,
|
|
})
|
|
end,
|
|
},
|
|
|
|
-- Add dadbod-completion to nvim-cmp sources
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
optional = true,
|
|
dependencies = {
|
|
"kristijanhusak/vim-dadbod-completion",
|
|
"nvim-cmp",
|
|
},
|
|
opts = function(_, opts)
|
|
opts.sources = opts.sources or {}
|
|
table.insert(opts.sources, { name = "vim-dadbod-completion" })
|
|
end,
|
|
},
|
|
}
|