Neovim Database Completion
This is an updated article on how to configure database completion in Neovim. In the previous articles, I talked about configuring Vim and Neovim to manage databases and setting up database completion using nvim-compe
. Since nvim-compe
is deprecated, let’s try out nvim-cmp
.
Setup
Plugins
- Using
packer.nvim
, installvim-dadbod
and its related plugins for user interface and completion.
use {
"tpope/vim-dadbod",
requires = {
"kristijanhusak/vim-dadbod-ui",
"kristijanhusak/vim-dadbod-completion"
},
config = function()
require("config.dadbod").setup()
end,
}
- Create a file called
dadbod.lua
underlua/config
folder with the following content. In this file, I specify the location to save the connection details.
local M = {}function M.setup()
vim.g.db_ui_save_location = "~/.config/nvim/db_ui"
endreturn M
Key Mappings
I configure the following key mappings using which-key.nvim
.
-- Database
x = {
name = "Database",
u = { "<Cmd>DBUIToggle<Cr>", "Toggle UI" },
f = {…