Skip to content

Commit d8a5829

Browse files
committed
feat(loader): when reloading, always re-source loaded vimscript files. See #445
1 parent 7f34cb8 commit d8a5829

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lua/lazy/core/loader.lua

+19
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,27 @@ function M.reload(plugin)
254254
end
255255
end
256256

257+
-- reload any vimscript files for this plugin
258+
local scripts = vim.fn.getscriptinfo({ name = ".vim" })
259+
local loaded_scripts = {}
260+
for _, s in ipairs(scripts) do
261+
---@type string
262+
local path = s.name
263+
if
264+
path:sub(-4) == ".vim"
265+
and path:find(plugin.dir, 1, true) == 1
266+
and not path:find("/plugin/", 1, true)
267+
and not path:find("/ftplugin/", 1, true)
268+
then
269+
loaded_scripts[#loaded_scripts + 1] = path
270+
end
271+
end
272+
257273
if load then
258274
M.load(plugin, { start = "reload" })
275+
for _, s in ipairs(loaded_scripts) do
276+
M.source(s)
277+
end
259278
end
260279
end
261280

0 commit comments

Comments
 (0)