Goal
Allow the non-plugin parts of this Neovim configuration to be reloaded without
closing and restarting Neovim.
Provide a user command, proposed as :ConfigReload, that safely reapplies the
supported configuration files without attempting to re-run Lazy.nvim startup.
Background
Running command :source $MYVIMRC re-executes file nvim/init.lua. That file
calls function require("lazy").setup(...), and Lazy.nvim intentionally rejects
a second setup pass with:
Re-sourcing your config is not supported with lazy.nvim
Lazy.nvim supports command :Lazy reload {plugin} for individual plugins, but
that experimental command does not reload this repository's core configuration.
The desired workflow is:
- Edit and save a supported Neovim config file.
- Run command
:ConfigReload.
- Observe the change without restarting Neovim.
Terminology
An autocommand is Neovim behavior triggered by an event, such as saving a
buffer or opening a file type.
An augroup is a named collection of autocommands. Creating an augroup with
clear = true removes its previous autocommands before adding replacements.
This prevents reloads from stacking duplicate actions, such as formatting the
same file multiple times after saving.
Proposed design
- Keep Lazy.nvim bootstrap and function
require("lazy").setup(...) as
startup-only behavior in file nvim/init.lua.
- Refactor reloadable configuration into modules with an idempotent
setup()
function. Running setup() multiple times must leave one effective version
of each keymap, command, option, and autocommand.
- Add command
:ConfigReload, implemented outside the Lazy.nvim setup path.
- Have command
:ConfigReload reload only an explicit allowlist of safe core
modules. Do not source file nvim/init.lua.
- Clear and recreate reloadable autocommands through named augroups.
- Define reloadable user commands with
force = true, or otherwise avoid
redefining them during a reload.
- Print a concise confirmation listing the modules that were reloaded.
Initial reloadable candidates
-
File nvim/lua/core/vim.lua
- Core options and keymaps.
- Requires cleanup before it can be safely re-run because it defines user
commands and has ungrouped FileType autocommands.
-
File nvim/lua/core/telescope.lua
- Telescope setup and keymaps.
-
File nvim/lua/core/treesitter.lua
- Already clears its
UserTreesitter augroup and is a strong candidate.
-
File nvim/lua/core/cmp.lua
-
File nvim/lua/core/comment.lua
- Comment.nvim and context-commentstring setup.
-
File nvim/lua/core/harpoon.lua
Excluded from the first implementation
- File
nvim/init.lua: must not be re-run because it initializes Lazy.nvim.
- File
nvim/lua/core/lazy-plugins.lua: contributes Lazy.nvim plugin specs.
- File
nvim/lua/core/lsp.lua: reconfigures LSP/Mason state and defines user
commands; evaluate separately.
- File
nvim/lua/core/fmt.lua: its ungrouped BufWritePost autocommand would
duplicate save-time formatting.
- Files
nvim/lua/core/debugger.lua,
nvim/lua/core/debug-kickstart.lua, and nvim/lua/core/snippets.lua:
plugin state requires separate idempotency review.
Acceptance criteria
Non-goals
- Reloading Lazy.nvim itself.
- Installing, updating, or reloading arbitrary plugins.
- Restarting active language servers unless a later follow-up explicitly adds
that behavior.
Goal
Allow the non-plugin parts of this Neovim configuration to be reloaded without
closing and restarting Neovim.
Provide a user command, proposed as
:ConfigReload, that safely reapplies thesupported configuration files without attempting to re-run Lazy.nvim startup.
Background
Running command
:source $MYVIMRCre-executes filenvim/init.lua. That filecalls function
require("lazy").setup(...), and Lazy.nvim intentionally rejectsa second setup pass with:
Lazy.nvim supports command
:Lazy reload {plugin}for individual plugins, butthat experimental command does not reload this repository's core configuration.
The desired workflow is:
:ConfigReload.Terminology
An autocommand is Neovim behavior triggered by an event, such as saving a
buffer or opening a file type.
An augroup is a named collection of autocommands. Creating an augroup with
clear = trueremoves its previous autocommands before adding replacements.This prevents reloads from stacking duplicate actions, such as formatting the
same file multiple times after saving.
Proposed design
require("lazy").setup(...)asstartup-only behavior in file
nvim/init.lua.setup()function. Running
setup()multiple times must leave one effective versionof each keymap, command, option, and autocommand.
:ConfigReload, implemented outside the Lazy.nvim setup path.:ConfigReloadreload only an explicit allowlist of safe coremodules. Do not source file
nvim/init.lua.force = true, or otherwise avoidredefining them during a reload.
Initial reloadable candidates
File
nvim/lua/core/vim.luacommands and has ungrouped
FileTypeautocommands.File
nvim/lua/core/telescope.luaFile
nvim/lua/core/treesitter.luaUserTreesitteraugroup and is a strong candidate.File
nvim/lua/core/cmp.luaFile
nvim/lua/core/comment.luaFile
nvim/lua/core/harpoon.luaExcluded from the first implementation
nvim/init.lua: must not be re-run because it initializes Lazy.nvim.nvim/lua/core/lazy-plugins.lua: contributes Lazy.nvim plugin specs.nvim/lua/core/lsp.lua: reconfigures LSP/Mason state and defines usercommands; evaluate separately.
nvim/lua/core/fmt.lua: its ungroupedBufWritePostautocommand wouldduplicate save-time formatting.
nvim/lua/core/debugger.lua,nvim/lua/core/debug-kickstart.lua, andnvim/lua/core/snippets.lua:plugin state requires separate idempotency review.
Acceptance criteria
:ConfigReloadexists and does not callrequire("lazy").setup(...).:ConfigReloadtwice produces no errors or duplicate behavior.replacement.
<Esc><Esc>still enters terminal-normal mode.<leader>rstill runs command:checktime.:ConfigReloadcovers and whichchanges still require a Neovim restart.
the reloadable configuration twice.
Non-goals
that behavior.