Skip to content

Commit

Permalink
fix(integrations): correct mapping for loaded plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Nov 1, 2024
1 parent 491452c commit 2c09c87
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lua/lazydev/integrations/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@ local Config = require("lazydev.config")

local M = {}

M.plugins = {
-- plugin to integration
---@type table<string, string>
M.p2i = {
["nvim-cmp"] = "cmp",
["coq_nvim"] = "coq",
lspconfig = "lspconfig",
}

-- integration to plugin
---@type table<string, string>
M.i2p = {}
for k, v in pairs(M.p2i) do
M.i2p[v] = k
end

---@type table<string, boolean>
M.loaded = {}

Expand All @@ -18,15 +27,15 @@ function M.setup()
group = vim.api.nvim_create_augroup("lazydev-integrations", { clear = true }),
pattern = "LazyLoad",
callback = function(event)
local name = M.plugins[event.data]
local name = M.p2i[event.data]
if name then
M.load(name)
end
end,
})
for name, enabled in pairs(Config.integrations) do
if enabled then
local plugin = LazyConfig.plugins[M.plugins[name]]
local plugin = LazyConfig.plugins[M.i2p[name]]
local is_loaded = plugin and plugin._.loaded
if is_loaded then
M.load(name)
Expand Down

0 comments on commit 2c09c87

Please sign in to comment.