Neovim Database Completion

Configure database completion in Neovim.

2 min readDec 11, 2021


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.



  • Using packer.nvim, install vim-dadbod and its related plugins for user interface and completion.
use {
requires = {

config = function()
  • Create a file called dadbod.lua under lua/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"
return M

Key Mappings

I configure the following key mappings using which-key.nvim.

-- Database
x = {
name = "Database",
u = { "<Cmd>DBUIToggle<Cr>", "Toggle UI" },
f = { "<Cmd>DBUIFindBuffer<Cr>", "Find buffer" },
r = { "<Cmd>DBUIRenameBuffer<Cr>", "Rename buffer" },
q = { "<Cmd>DBUILastQueryInfo<Cr>", "Last query info" },


As you can see from the screenshot, I am able to connect to a PostgreSQL database now and run queries against it.


Configure Database Completion

Let’s continue to set up database completion using nvim-cmp. If you are new to nvim-cmp, check out this article.




Software engineer, Data Science and ML practitioner.