Skip to content

Commit 2a71933

Browse files
feat(loader): handle hyphens in file names when deactivating
## Description When deactivating plugins `vim.g.loaded_` variables are cleared based on a common pattern plugins use to use avoid multiple initializing. The current logic handles most cases, except when a lua file has a hyphen in which case it is unlikely to clear the correct variable. For example: - [nvim-treesitter.lua](https://github.com/nvim-treesitter/nvim-treesitter/blob/main/plugin/nvim-treesitter.lua) - variable used: `vim.g.loaded_nvim_treesitter` - current logic clears: `vim.g.loaded_nvim-treesitter`
1 parent e6a8824 commit 2a71933

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lua/lazy/core/loader.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function M.deactivate(plugin)
238238
-- clear vim.g.loaded_ for plugins
239239
Util.ls(plugin.dir .. "/plugin", function(_, name, type)
240240
if type == "file" then
241-
vim.g["loaded_" .. name:gsub("%..*", "")] = nil
241+
vim.g["loaded_" .. name:gsub("%..*", ""):gsub("-", "_")] = nil
242242
end
243243
end)
244244
-- set as not loaded

0 commit comments

Comments
 (0)