mirror of
https://github.com/chenasraf/vim-matchup.git
synced 2026-05-17 17:38:01 +00:00
29 lines
627 B
Lua
29 lines
627 B
Lua
-- From https://github.com/nvim-lua/plenary.nvim
|
|
-- MIT License
|
|
-- Copyright (c) 2020 TJ DeVries
|
|
|
|
|
|
local reload = {}
|
|
|
|
reload.reload_module = function(module_name, starts_with_only)
|
|
-- TODO: Might need to handle cpath / compiled lua packages? Not sure.
|
|
local matcher
|
|
if not starts_with_only then
|
|
matcher = function(pack)
|
|
return string.find(pack, module_name, 1, true)
|
|
end
|
|
else
|
|
matcher = function(pack)
|
|
return string.find(pack, '^' .. module_name)
|
|
end
|
|
end
|
|
|
|
for pack, _ in pairs(package.loaded) do
|
|
if matcher(pack) then
|
|
package.loaded[pack] = nil
|
|
end
|
|
end
|
|
end
|
|
|
|
return reload
|