Neovim Plugin Management with lazy.nvim: Install & Configure 6 Essential Plugins | Episode 7
Video: Neovim Plugin Management with lazy.nvim: Install & Configure 6 Essential Plugins | Episode 7 by Taught by Celeste AI - AI Coding Coach
Watch full page →Neovim Plugin Management with lazy.nvim: Install & Configure 6 Essential Plugins
Learn how to efficiently manage Neovim plugins using the modern lazy.nvim plugin manager. This guide covers bootstrapping lazy.nvim, organizing plugin specifications in separate files, and installing six essential plugins that enhance your editing experience.
Code
-- init.lua: bootstrap lazy.nvim and set mapleader BEFORE loading plugins
vim.g.mapleader = " " -- Set leader key early
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)
-- Load all plugins from lua/plugins/
require("lazy").setup({ { import = "plugins" } })
-- Example plugin spec file: lua/plugins/catppuccin.lua
return {
"catppuccin/nvim",
name = "catppuccin",
priority = 1000,
config = function()
require("catppuccin").setup({})
vim.cmd.colorscheme("catppuccin")
end,
}
-- lua/plugins/lualine.lua
return {
"nvim-lualine/lualine.nvim",
opts = {}, -- use default setup
}
-- lua/plugins/which-key.lua
return {
"folke/which-key.nvim",
event = "VeryLazy", -- lazy-load after startup
opts = {},
}
-- lua/plugins/autopairs.lua
return {
"windwp/nvim-autopairs",
event = "InsertEnter", -- load on Insert mode entry
opts = {},
}
-- lua/plugins/comment.lua
return {
"numToStr/Comment.nvim",
opts = {},
}
-- lua/plugins/indent-blankline.lua
return {
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
opts = {},
}
Key Points
- Bootstrap lazy.nvim with a simple snippet in init.lua that clones it if missing and prepends it to runtime path.
- Set vim.g.mapleader before loading plugins to ensure keybindings work correctly.
- Organize plugins as individual Lua files under lua/plugins/, each returning a plugin specification table.
- Use require("lazy").setup({ { import = "plugins" } }) to automatically load all plugin specs from the plugins directory.
- Leverage lazy-loading events like "VeryLazy" and "InsertEnter" to speed up Neovim startup time.