Skip to content

Commit

Permalink
fix(nvim-plug): avoid load plugin twice
Browse files Browse the repository at this point in the history
  • Loading branch information
wsdjeg committed Feb 9, 2025
1 parent f8b0abf commit 271c751
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
3 changes: 3 additions & 0 deletions bundle/nvim-plug/lua/plug/installer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ function H.build(plugSpec)
on_exit = function(id, data, single)
if data == 0 and single == 0 then
on_uidate(plugSpec.name, { build_done = true })
if plugSpec.autoload then
loader.load(plugSpec)
end
else
on_uidate(plugSpec.name, { build_done = false })
end
Expand Down
25 changes: 4 additions & 21 deletions bundle/nvim-plug/lua/plug/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ local M = {}
local config = require('plug.config')

local add_raw_rtp = false
local loaded_plugins = {}


--- @class PluginSpec
--- @field rtp string
Expand Down Expand Up @@ -105,29 +107,10 @@ function M.parser(plugSpec)
return plugSpec
end

-- {'loadconf': 1,
-- 'type': 'none',
-- 'overwrite': 1,
-- 'lazy': 0,
-- 'name': 'defx-git',
-- 'rtp': 'C:/Users/wsdjeg/.SpaceVim/bundle/defx-git',
-- 'normalized_name': 'defx-git',
-- 'local': 1,
-- 'sourced': 1,
-- 'orig_opts': {'repo': 'C:/Users/wsdjeg/.SpaceVim/bundle/defx-git',
-- 'loadconf': 1,
-- 'type': 'none',
-- 'merged': 0,
-- 'hook_source': 'call SpaceVim#util#loadConfig(''plugins/defx-git.vim'')',
-- 'overwrite': 1},
-- 'repo': 'C:/Users/wsdjeg/.SpaceVim/bundle/defx-git',
-- 'hook_source': 'call SpaceVim#util#loadConfig(''plugins/defx-git.vim'')',
-- 'called': {'''call SpaceVim#util#loadConfig(''''plugins/defx-git.vim'''')''': v:true},
-- 'merged': 0,
-- 'path': 'C:/Users/wsdjeg/.SpaceVim/bundle/defx-git'}
function M.load(plugSpec)
if plugSpec.rtp and vim.fn.isdirectory(plugSpec.rtp) == 1 then
if plugSpec.rtp and vim.fn.isdirectory(plugSpec.rtp) == 1 and not loaded_plugins[plugSpec.name] then
vim.opt.runtimepath:append(plugSpec.rtp)
loaded_plugins[plugSpec.name] = true
if type(plugSpec.config) == 'function' then
plugSpec.config()
end
Expand Down

0 comments on commit 271c751

Please sign in to comment.