Skip to content

Commit

Permalink
feat(loader): when reloading, always re-source loaded vimscript files…
Browse files Browse the repository at this point in the history
…. See #445
  • Loading branch information
folke committed May 27, 2023
1 parent 7f34cb8 commit d8a5829
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lua/lazy/core/loader.lua
Expand Up @@ -254,8 +254,27 @@ function M.reload(plugin)
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
M.load(plugin, { start = "reload" })
for _, s in ipairs(loaded_scripts) do
M.source(s)
end
end
end

Expand Down

0 comments on commit d8a5829

Please sign in to comment.