how i optimized my neovim config for 10ms startup
•system
the problem with plugin managers
my neovim used to take 400ms to start. that's fast enough for most people. it wasn't fast enough for me.
the culprit was eager plugin loading. every plugin, loaded on startup, whether you needed it or not.
lazy.nvim
lazy.nvim changed everything. it defers plugin loading until the plugin is actually needed — triggered by a command, filetype, or keymap.
require("lazy").setup({
{
"nvim-treesitter/nvim-treesitter",
event = "BufReadPost", -- load after buffer is read
build = ":TSUpdate",
},
{
"neovim/nvim-lspconfig",
ft = { "rust", "go", "typescript" }, -- load only for these filetypes
},
})
profiling startup
nvim --startuptime /tmp/nvim-startup.log
tail -20 /tmp/nvim-startup.log
this tells you exactly which files take the most time to source. in my case, a colorscheme plugin was loading 40ms of vimscript on every startup.
the result
after profiling and lazy-loading everything:
- before: 380ms startup, 47 plugins eager-loaded
- after: 9ms startup, same 47 plugins, all lazy
the config feels instant. opening files from the terminal is seamless. this is what neovim was designed to feel like.