-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
local Config = require("lazydev.config") | ||
|
||
local M = {} | ||
|
||
M.plugins = { | ||
["nvim-cmp"] = "cmp", | ||
["coq_nvim"] = "coq", | ||
lspconfig = "lspconfig", | ||
} | ||
|
||
---@type table<string, boolean> | ||
M.loaded = {} | ||
|
||
function M.setup() | ||
if package.loaded.lazy then | ||
local LazyConfig = require("lazy.core.config") | ||
vim.api.nvim_create_autocmd("User", { | ||
group = vim.api.nvim_create_augroup("lazydev-integrations", { clear = true }), | ||
pattern = "LazyLoad", | ||
callback = function(event) | ||
local name = M.plugins[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 is_loaded = plugin and plugin._.loaded | ||
if is_loaded then | ||
M.load(name) | ||
end | ||
end | ||
end | ||
else | ||
for name, enabled in pairs(Config.integrations) do | ||
if enabled then | ||
M.load(name) | ||
end | ||
end | ||
end | ||
end | ||
|
||
---@param name string | ||
function M.load(name) | ||
if not M.loaded[name] then | ||
M.loaded[name] = true | ||
require("lazydev.integrations." .. name).setup() | ||
end | ||
end | ||
|
||
return M |