Reload A Neovim Plugin While You're Working On It
When using lazy, I set up a hotkey like this to save and reload the plugin I'm working on each time before running it:
vim.keymap.set({'n', 'i' }, '<M-S-x>', function()
vim.api.nvim_exec('write', false)
local plugin_name = 'neovim_command_runner'
require("lazy.core.loader").reload(
plugin_name .. ".nvim"
)
require(plugin_name).open_command_window()
end)
Notes
-
This assumes that the folder for the plugin ends with
.nvim
- I found the code for this here
- There's mention in the release notes that this is experimental.
- The plugin I'm working on are very simple and don't have any setup to it. If it did, I don't know if this approach would work without some more work
-- end of line --