Migrating from Vanilla Neovim to LazyVim
If you've spent months building a custom init.lua, you might be hesitant to switch to a pre-configured distribution. However, migrating to LazyVim is often worth it for the improved performance, standardized configuration, and reduced maintenance burden.
Why Migrate?
- Zero maintenance: Plugin updates rarely break your config because LazyVim maintains version locks and compatibility.
- Best practices: LazyVim implements advanced lazy-loading techniques that are hard to get right manually.
- Community: When you have an issue, you're using the same base setup as thousands of others.
Pre-migration Checklist
- Verify your Neovim version is >=
0.9.0. - Ensure you have a Nerd Font installed for icons.
- Have a basic understanding of
lazy.nvimsyntax.
Step 1: Back up existing config
Always back up your current vanilla setup!
mv ~/.config/nvim ~/.config/nvim.bak
mv ~/.local/share/nvim ~/.local/share/nvim.bak
mv ~/.local/state/nvim ~/.local/state/nvim.bak
mv ~/.cache/nvim ~/.cache/nvim.bak
Step 2: Install LazyVim starter
Clone the LazyVim starter template to kickstart your new config:
git clone https://github.com/LazyVim/starter ~/.config/nvim
rm -rf ~/.config/nvim/.git
Step 3: Map your existing plugins
Compare your old plugin list to LazyVim's defaults. You might find you don't need half of them anymore! Enable the required language support via :LazyExtras.
| Vanilla Plugin | LazyVim Equivalent |
|---|---|
| packer.nvim / vim-plug | lazy.nvim (Built-in) |
| nvim-cmp | blink.cmp or nvim-cmp (via extras) |
| null-ls (deprecated) | conform.nvim & nvim-lint |
| NvimTree | Neo-tree (Pre-configured) |
Step 4: Move custom keymaps
Copy your custom mappings into lua/config/keymaps.lua. You don't need to define leader key or standard window/buffer motions; LazyVim has you covered.
-- lua/config/keymaps.lua
vim.keymap.set("i", "jk", "<ESC>", { desc = "Exit insert mode" })
Step 5: Move custom options
Migrate your vim.opt settings into lua/config/options.lua. LazyVim already sets sensible defaults (like number, relativenumber, ignorecase), so only copy over your specific preferences.
-- lua/config/options.lua
vim.opt.wrap = true
vim.opt.tabstop = 4
Step 6: Move custom autocmds
Place your autocommands in lua/config/autocmds.lua.
Step 7: Add non-default plugins
Create files in lua/plugins/ for any plugins from your old setup that LazyVim doesn't include (e.g., Harpoon, Vim-Fugitive).