Add dadbod as a database client for neovim
This commit is contained in:
parent
f9b0ddf8d9
commit
58f515d9d0
6 changed files with 91 additions and 5 deletions
|
|
@ -24,6 +24,8 @@ end
|
|||
-- See `:help vim.keymap.set()`
|
||||
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true })
|
||||
|
||||
vim.keymap.set("n", "<C-s>", "<CMD>w<CR>", default("Keep cursor centered while junping"))
|
||||
|
||||
-- Remap for dealing with word wrap
|
||||
vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
||||
vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@ return { -- Change colors.none if not using a transparent background
|
|||
transparent_background = false,
|
||||
integrations = {
|
||||
cmp = true,
|
||||
notify = true,
|
||||
harpoon = true,
|
||||
mason = true,
|
||||
neogit = true,
|
||||
noice = true,
|
||||
lsp_trouble = true,
|
||||
indent_blankline = {
|
||||
enabled = true,
|
||||
},
|
||||
|
|
@ -17,6 +23,10 @@ return { -- Change colors.none if not using a transparent background
|
|||
Pmenu = { bg = colors.none, blend = 0 },
|
||||
FloatBorder = { bg = colors.none },
|
||||
CmpItemMenu = { fg = colors.text, bg = colors.none },
|
||||
-- dadbod-ui
|
||||
NotificationInfo = { bg = colors.none, fg = colors.text },
|
||||
NotificationWarning = { bg = colors.none, fg = colors.yellow },
|
||||
NotificationError = { bg = colors.none, fg = colors.red },
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
---@diagnostic disable: missing-fields
|
||||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
version = false, -- last release is way too old
|
||||
|
|
@ -6,9 +7,11 @@ return {
|
|||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"petertriho/cmp-git",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
opts = function()
|
||||
config = function()
|
||||
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
|
||||
local cmp = require("cmp")
|
||||
local defaults = require("cmp.config.default")()
|
||||
|
|
@ -18,7 +21,7 @@ return {
|
|||
-- fix colors for catppuccin colorscheme
|
||||
winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None",
|
||||
}
|
||||
return {
|
||||
local opts = {
|
||||
completion = {
|
||||
completeopt = "menu,menuone,noinsert",
|
||||
},
|
||||
|
|
@ -37,11 +40,12 @@ return {
|
|||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<BR>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
["<S-CR>"] = cmp.mapping.confirm({
|
||||
["<C-CR>"] = cmp.mapping.confirm({ select = false }), -- Confirm only if selected an item
|
||||
["<CR>"] = cmp.mapping.confirm({
|
||||
-- Auto confirms first item
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
}), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
|
|
@ -70,5 +74,25 @@ return {
|
|||
},
|
||||
sorting = defaults.sorting,
|
||||
}
|
||||
|
||||
cmp.setup(opts)
|
||||
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline({ "/", "?" }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(":", {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "cmdline" },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
44
config/nvim/lua/aleidk/plugins/database.lua
Normal file
44
config/nvim/lua/aleidk/plugins/database.lua
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
return {
|
||||
"kristijanhusak/vim-dadbod-ui",
|
||||
dependencies = {
|
||||
{ "tpope/vim-dadbod", lazy = true },
|
||||
{ "kristijanhusak/vim-dadbod-completion", ft = { "sql", "mysql", "plsql" }, lazy = true },
|
||||
},
|
||||
cmd = {
|
||||
"DBUI",
|
||||
"DBUIToggle",
|
||||
"DBUIAddConnection",
|
||||
"DBUIFindBuffer",
|
||||
},
|
||||
keys = {
|
||||
{ "<Leader>ud", "<CMD>DBUIToggle<CR>", desc = "Toggle DB UI" },
|
||||
},
|
||||
init = function()
|
||||
-- Your DBUI configuration
|
||||
vim.g.db_ui_use_nerd_fonts = 1
|
||||
vim.g.db_ui_force_echo_notifications = 1
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = {
|
||||
"sql",
|
||||
"mysql",
|
||||
"plsql",
|
||||
},
|
||||
command = [[setlocal omnifunc=vim_dadbod_completion#omni]],
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = {
|
||||
"sql",
|
||||
"mysql",
|
||||
"plsql",
|
||||
},
|
||||
callback = function()
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
require("cmp").setup.buffer({
|
||||
sources = { { name = "vim-dadbod-completion" } },
|
||||
})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ return {
|
|||
"python",
|
||||
"regex",
|
||||
"rust",
|
||||
"sql",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue