mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
refactor: specs
This commit is contained in:
parent
9904bbb887
commit
5e18789e03
1 changed files with 59 additions and 55 deletions
|
|
@ -3,9 +3,66 @@ local sql_ft = { "sql", "mysql", "plsql" }
|
||||||
return {
|
return {
|
||||||
recommended = function()
|
recommended = function()
|
||||||
return LazyVim.extras.wants({
|
return LazyVim.extras.wants({
|
||||||
ft = { "sql", "mysql", "plsql" },
|
ft = sql_ft,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
{
|
||||||
|
"tpope/vim-dadbod",
|
||||||
|
cmd = "DB",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"kristijanhusak/vim-dadbod-completion",
|
||||||
|
dependencies = "vim-dadbod",
|
||||||
|
ft = sql_ft,
|
||||||
|
init = function()
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = sql_ft,
|
||||||
|
callback = function()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
|
||||||
|
-- global sources
|
||||||
|
---@param source cmp.SourceConfig
|
||||||
|
local sources = vim.tbl_map(function(source)
|
||||||
|
return { name = source.name }
|
||||||
|
end, cmp.get_config().sources)
|
||||||
|
|
||||||
|
-- add vim-dadbod-completion source
|
||||||
|
table.insert(sources, { name = "vim-dadbod-completion" })
|
||||||
|
|
||||||
|
-- update sources for the current buffer
|
||||||
|
cmp.setup.buffer({ sources = sources })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"kristijanhusak/vim-dadbod-ui",
|
||||||
|
cmd = { "DBUI", "DBUIToggle", "DBUIAddConnection", "DBUIFindBuffer" },
|
||||||
|
dependencies = "vim-dadbod",
|
||||||
|
keys = {
|
||||||
|
{ "<leader>D", "<cmd>DBUIToggle<CR>", desc = "Toggle DBUI" },
|
||||||
|
},
|
||||||
|
init = function()
|
||||||
|
local data_path = vim.fn.stdpath("data")
|
||||||
|
|
||||||
|
vim.g.db_ui_auto_execute_table_helpers = 1
|
||||||
|
vim.g.db_ui_save_location = data_path .. "/dadbod_ui"
|
||||||
|
vim.g.db_ui_show_database_icon = true
|
||||||
|
vim.g.db_ui_tmp_query_location = data_path .. "/dadbod_ui/tmp"
|
||||||
|
vim.g.db_ui_use_nerd_fonts = true
|
||||||
|
vim.g.db_ui_use_nvim_notify = true
|
||||||
|
|
||||||
|
-- NOTE: The default behavior of auto-execution of queries on save is disabled
|
||||||
|
-- this is useful when you have a big query that you don't want to run every time
|
||||||
|
-- you save the file running those queries can crash neovim to run use the
|
||||||
|
-- default keymap: <leader>S
|
||||||
|
vim.g.db_ui_execute_on_save = false
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
optional = true,
|
optional = true,
|
||||||
|
|
@ -23,6 +80,7 @@ return {
|
||||||
title = "Database",
|
title = "Database",
|
||||||
ft = "dbui",
|
ft = "dbui",
|
||||||
pinned = true,
|
pinned = true,
|
||||||
|
width = 0.3,
|
||||||
open = function()
|
open = function()
|
||||||
vim.cmd("DBUI")
|
vim.cmd("DBUI")
|
||||||
end,
|
end,
|
||||||
|
|
@ -34,63 +92,9 @@ return {
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"tpope/vim-dadbod",
|
|
||||||
cmd = "DB",
|
|
||||||
dependencies = {
|
|
||||||
{
|
|
||||||
"kristijanhusak/vim-dadbod-completion",
|
|
||||||
ft = sql_ft,
|
|
||||||
init = function()
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
|
||||||
pattern = sql_ft,
|
|
||||||
callback = function()
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
|
||||||
local cmp = require("cmp")
|
|
||||||
local global_sources = cmp.get_config().sources
|
|
||||||
local buffer_sources = {}
|
|
||||||
|
|
||||||
-- add globally defined sources (see separate nvim-cmp config)
|
|
||||||
-- this makes e.g. luasnip snippets available since luasnip is configured globally
|
|
||||||
if global_sources then
|
|
||||||
for _, source in ipairs(global_sources) do
|
|
||||||
table.insert(buffer_sources, { name = source.name })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- add vim-dadbod-completion source
|
|
||||||
table.insert(buffer_sources, { name = "vim-dadbod-completion" })
|
|
||||||
|
|
||||||
-- update sources for the current buffer
|
|
||||||
cmp.setup.buffer({ sources = buffer_sources })
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{ "jsborjesson/vim-uppercase-sql", ft = sql_ft },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kristijanhusak/vim-dadbod-ui",
|
|
||||||
cmd = { "DBUI", "DBUIToggle", "DBUIAddConnection", "DBUIFindBuffer" },
|
|
||||||
dependencies = {
|
|
||||||
"tpope/vim-dadbod",
|
|
||||||
},
|
|
||||||
init = function()
|
|
||||||
local data_path = vim.fn.stdpath("data")
|
|
||||||
|
|
||||||
vim.g.db_ui_save_location = data_path .. "/dadbod_ui"
|
|
||||||
vim.g.db_ui_tmp_query_location = data_path .. "/dadbod_ui/tmp"
|
|
||||||
|
|
||||||
vim.g.db_ui_use_nerd_fonts = true
|
|
||||||
vim.g.db_ui_show_database_icon = true
|
|
||||||
vim.g.db_ui_use_nvim_notify = true
|
|
||||||
|
|
||||||
-- NOTE: The default behavior of auto-execution of queries on save is disabled
|
|
||||||
-- this is useful when you have a big query that you don't want to run every time
|
|
||||||
-- you save the file running those queries can crash neovim to run use the
|
|
||||||
-- default keymap: <leader>S
|
|
||||||
vim.g.db_ui_execute_on_save = false
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue