navigator.lua/lua/navigator/lazyloader.lua

66 lines
2.1 KiB
Lua
Raw Normal View History

2021-09-24 01:54:03 +00:00
return {
init = function()
2021-10-05 06:53:53 +00:00
local loader = nil
local packer_plugins = packer_plugins or nil -- suppress warnings
2021-09-24 01:54:03 +00:00
local log = require'navigator.util'.log
2021-10-05 06:53:53 +00:00
-- packer only
if packer_plugins ~= nil then -- packer install
local lazy_plugins = {
["nvim-lspconfig"] = "neovim/nvim-lspconfig",
["guihua.lua"] = "ray-x/guihua.lua"
}
2021-09-27 22:24:22 +00:00
2021-10-05 06:53:53 +00:00
if _NgConfigValues.lspinstall == true then
lazy_plugins["nvim-lspinstall"] = "kabouzeid/nvim-lspinstall"
end
2021-08-06 07:24:03 +00:00
2021-10-05 06:53:53 +00:00
-- packer installed
loader = require"packer".loader
for plugin, url in pairs(lazy_plugins) do
if not packer_plugins[url] or not packer_plugins[url].loaded then
2021-09-24 01:54:03 +00:00
-- log("loading ", plugin)
2021-10-05 06:53:53 +00:00
loader(plugin)
end
end
2021-08-06 07:24:03 +00:00
end
2021-10-05 06:53:53 +00:00
if _NgConfigValues.lspinstall == true then
local has_lspinst, lspinst = pcall(require, "lspinstall")
2021-09-24 01:54:03 +00:00
log('lspinstall', has_lspinst)
2021-10-05 06:53:53 +00:00
if has_lspinst then
lspinst.setup()
2021-09-24 01:54:03 +00:00
local configs = require "lspconfig/configs"
local servers = require'lspinstall'.installed_servers()
for _, server in pairs(servers) do
local cfg = require'navigator.lspclient.clients'.get_cfg(server)
local lsp_inst_cfg = configs[server]
if lsp_inst_cfg and lsp_inst_cfg.document_config.default_config then
lsp_inst_cfg = lsp_inst_cfg.document_config.default_config
2021-09-27 22:24:22 +00:00
lsp_inst_cfg = vim.tbl_deep_extend('keep', lsp_inst_cfg, cfg)
2021-09-24 01:54:03 +00:00
require'lspconfig'[server].setup(lsp_inst_cfg)
2021-10-05 06:53:53 +00:00
end
end
end
end
2021-10-04 22:48:46 +00:00
end,
load = function(plugin_name, path)
local loader = nil
local packer_plugins = packer_plugins or nil -- suppress warnings
local log = require'navigator.util'.log
-- packer only
if packer_plugins ~= nil then -- packer install
local lazy_plugins = {}
lazy_plugins[plugin_name] = path
loader = require"packer".loader
for plugin, url in pairs(lazy_plugins) do
if not packer_plugins[url] or not packer_plugins[url].loaded then
-- log("loading ", plugin)
loader(plugin)
end
end
end
2021-08-06 07:24:03 +00:00
end
2021-09-24 01:54:03 +00:00
}