Skip to content

Commit

Permalink
fix: some dadbod stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
willruggiano committed Sep 29, 2023
1 parent fac2bda commit bd6a8e1
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 4 deletions.
18 changes: 15 additions & 3 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@
"rev": "ceda07dc7339f35444b5f4c4016f76a9eb42ac16",
"type": "git"
},
"nvim-notify": {
"branch": "master",
"repo": "[email protected]:rcarriga/nvim-notify",
"rev": "e4a2022f4fec2d5ebc79afa612f96d8b11c627b3",
"type": "git"
},
"nvim-pqf": {
"branch": "main",
"repo": "ssh://[email protected]/yorickpeterse/nvim-pqf",
Expand Down Expand Up @@ -464,7 +470,7 @@
"vim-dadbod": {
"branch": "master",
"repo": "[email protected]:tpope/vim-dadbod",
"rev": "3f57c0cd41523423fd781422dfc833820095a3e8",
"rev": "7d80bbd11c407a09e0f7b869c38f3dec3902805f",
"type": "git"
},
"vim-dadbod-completion": {
Expand All @@ -475,8 +481,14 @@
},
"vim-dadbod-ui": {
"branch": "master",
"repo": "[email protected]:kristijanhusak/vim-dadbod-ui",
"rev": "986324fa6372170ec47b28a5558ae7f7185e1d71",
"repo": "[email protected]:willruggiano/vim-dadbod-ui",
"rev": "5e829791a060c06b9aa6c20863e1236697a035bc",
"type": "git"
},
"vim-dispatch": {
"branch": "master",
"repo": "[email protected]:tpope/vim-dispatch",
"rev": "6cc2691576f97d43f8751664d1a1a908b99927e5",
"type": "git"
},
"vim-graphql": {
Expand Down
21 changes: 21 additions & 0 deletions plugins/dadbod.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
return function()
vim.g.db_ui_use_nvim_notify = 1

require("cmp").setup.filetype({ "mysql", "plsql", "sql" }, {
sources = {
{ name = "vim-dadbod-completion" },
},
})

local nnoremap = require("bombadil.lib.keymap").nnoremap
local xnoremap = require("bombadil.lib.keymap").xnoremap

nnoremap("<space>d", function()
vim.api.nvim_cmd({
cmd = "DBUIToggle",
mods = {
silent = true,
},
}, {})
end, { desc = "[dadbod] Toggle" })

vim.api.nvim_create_autocmd("FileType", {
pattern = "sql",
callback = function(opts)
xnoremap("<C-M>", "db#op_exec()", { buffer = opts.buf, desc = "[dadbod] Run selected query", expr = true })
end,
})
end
8 changes: 8 additions & 0 deletions plugins/notify.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
return function()
require("notify").setup {
render = "compact",
stages = "static",
}

vim.notify = require "notify"
end
14 changes: 13 additions & 1 deletion plugins/spec.nix
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ in rec {
dadbod-ui = {
src = sources.vim-dadbod-ui;
};
vim-dispatch = {
src = sources.vim-dispatch;
};
};
};

Expand Down Expand Up @@ -190,7 +193,9 @@ in rec {
init = pkgs.writeTextFile {
name = "fzy-lua-native.lua";
text = ''
package.cpath = package.cpath .. ";" .. "${package}/static/?.so";
return function()
package.cpath = package.cpath .. ";" .. "${package}/static/?.so";
end
'';
};
};
Expand Down Expand Up @@ -378,6 +383,13 @@ in rec {
src = sources.nvim-nonicons;
};

nvim-notify = {
src = sources.nvim-notify;
config = ./notify.lua;
lazy = false;
priority = 1000;
};

nvim-surround = {
src = sources.nvim-surround;
config = true;
Expand Down
10 changes: 10 additions & 0 deletions test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local nnoremap = require("bombadil.lib.keymap").nnoremap

nnoremap("<space>d", function()
vim.api.nvim_cmd({
cmd = "DBUIToggle",
mods = {
silent = true,
},
}, {})
end, { desc = "[dadbod] Toggle" })

0 comments on commit bd6a8e1

Please sign in to comment.