Modern Neovim Config with lazy.nvim
Beginner15 min
Set up a modern Neovim configuration from scratch using lazy.nvim as the plugin manager with a clean directory structure.
Prerequisites
- -Neovim 0.9+ installed
- -Git installed
Steps
1
Back up existing config and create directory structure
Save any existing Neovim config and set up the standard directory layout.
$ mv ~/.config/nvim ~/.config/nvim.bak 2>/dev/null; mkdir -p ~/.config/nvim/lua/plugins
Neovim reads init.lua from ~/.config/nvim/ on Linux/macOS or ~/AppData/Local/nvim/ on Windows.
2
Bootstrap lazy.nvim in init.lua
Create the init.lua with the lazy.nvim bootstrap code that auto-installs the plugin manager.
$ cat > ~/.config/nvim/init.lua << 'EOF'
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ "git", "clone", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(lazypath)
-- Leader key (must be before lazy)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Core options
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.termguicolors = true
vim.opt.signcolumn = "yes"
vim.opt.clipboard = "unnamedplus"
-- Load plugins
require("lazy").setup("plugins")
EOF
3
Add a starter plugin spec
Create a plugin spec file that installs a colorscheme and essential plugins.
$ cat > ~/.config/nvim/lua/plugins/init.lua << 'EOF'
return {
{ "catppuccin/nvim", name = "catppuccin", priority = 1000,
config = function() vim.cmd.colorscheme("catppuccin") end },
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
{ "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
}
EOF
4
Launch Neovim and install plugins
Open Neovim to trigger lazy.nvim's automatic plugin installation.
$ nvim --headless '+Lazy sync' +qa
Run :Lazy inside Neovim to see the plugin manager UI, update plugins, and check health.
5
Verify the setup
Check that Neovim starts cleanly with no errors.
$ nvim +checkhealth
Full Script
FAQ
Discussion
Loading comments...