-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdadbod.lua
52 lines (49 loc) · 1.22 KB
/
dadbod.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
local function db_completion()
require("cmp").setup.buffer({ sources = { { name = "vim-dadbod-completion" } } })
end
return {
"tpope/vim-dadbod",
dependencies = {
"kristijanhusak/vim-dadbod-ui",
"kristijanhusak/vim-dadbod-completion",
},
config = function()
vim.g.db_ui_save_location = vim.fn.expand("~/.config/dadbod")
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(db_completion)
end,
})
vim.api.nvim_create_autocmd("FileType", {
pattern = { "dbui" },
callback = function()
vim.keymap.set({ "n", "x" }, "<C-Space>", "<Plug>(DBUI_ExecuteQuery)")
end,
})
vim.g.db_ui_table_helpers = {
postgresql = {
Count = 'select count(*) from "{table}"',
},
}
end,
cmd = {
"DBUI",
"DBUIToggle",
"DBUIAddConnection",
"DBUIFindBuffer",
"DBUIRenameBuffer",
"DBUILastQueryInfo",
},
enabled = require("config.util").is_enabled("tpope/vim-dadbod"),
}