feat(loader): when reloading, always re-source loaded vimscript files. See #445

This commit is contained in:
Folke Lemaitre 2023-05-27 15:19:11 +02:00
parent 7f34cb892b
commit d8a5829fda
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 19 additions and 0 deletions

View File

@ -254,8 +254,27 @@ function M.reload(plugin)
end end
end end
-- reload any vimscript files for this plugin
local scripts = vim.fn.getscriptinfo({ name = ".vim" })
local loaded_scripts = {}
for _, s in ipairs(scripts) do
---@type string
local path = s.name
if
path:sub(-4) == ".vim"
and path:find(plugin.dir, 1, true) == 1
and not path:find("/plugin/", 1, true)
and not path:find("/ftplugin/", 1, true)
then
loaded_scripts[#loaded_scripts + 1] = path
end
end
if load then if load then
M.load(plugin, { start = "reload" }) M.load(plugin, { start = "reload" })
for _, s in ipairs(loaded_scripts) do
M.source(s)
end
end end
end end