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
|
2022-02-21 03:57:36 +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 = {
|
2022-02-21 03:57:36 +00:00
|
|
|
['nvim-lspconfig'] = 'neovim/nvim-lspconfig',
|
|
|
|
['guihua.lua'] = 'ray-x/guihua.lua',
|
2021-10-05 06:53:53 +00:00
|
|
|
}
|
2021-09-27 22:24:22 +00:00
|
|
|
|
2021-10-17 23:46:21 +00:00
|
|
|
if _NgConfigValues.lsp_installer == true then
|
2022-02-21 03:57:36 +00:00
|
|
|
lazy_plugins['nvim-lsp-installer'] = 'williamboman/nvim-lsp-installer'
|
2021-10-05 06:53:53 +00:00
|
|
|
end
|
2021-08-06 07:24:03 +00:00
|
|
|
|
2021-10-05 06:53:53 +00:00
|
|
|
-- packer installed
|
2022-02-21 03:57:36 +00:00
|
|
|
loader = require('packer').loader
|
2021-10-05 06:53:53 +00:00
|
|
|
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-17 23:46:21 +00:00
|
|
|
if _NgConfigValues.lsp_installer == true then
|
2022-05-17 13:15:16 +00:00
|
|
|
local has_lspinst, lspinst = pcall(require, 'nvim-lsp-installer')
|
2021-10-18 00:56:39 +00:00
|
|
|
log('lsp_installer installed', has_lspinst)
|
2021-10-05 06:53:53 +00:00
|
|
|
if has_lspinst then
|
|
|
|
lspinst.setup()
|
2022-02-21 03:57:36 +00:00
|
|
|
local configs = require('lspconfig/configs')
|
|
|
|
local servers = require('nvim-lsp-installer').get_installed_servers()
|
2021-09-24 01:54:03 +00:00
|
|
|
for _, server in pairs(servers) do
|
2022-02-21 03:57:36 +00:00
|
|
|
local cfg = require('navigator.lspclient.clients').get_cfg(server)
|
2021-09-24 01:54:03 +00:00
|
|
|
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)
|
2022-02-21 03:57:36 +00:00
|
|
|
require('lspconfig')[server].setup(lsp_inst_cfg)
|
2021-10-05 06:53:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-08-27 00:25:48 +00:00
|
|
|
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
|
|
|
|
-- packer only
|
|
|
|
if packer_plugins ~= nil then -- packer install
|
|
|
|
local lazy_plugins = {}
|
|
|
|
lazy_plugins[plugin_name] = path
|
2022-02-21 03:57:36 +00:00
|
|
|
loader = require('packer').loader
|
2022-06-01 15:41:26 +00:00
|
|
|
for plugin, _ in pairs(lazy_plugins) do
|
2021-10-05 23:57:03 +00:00
|
|
|
if packer_plugins[plugin] and packer_plugins[plugin].loaded == false then
|
2021-10-04 22:48:46 +00:00
|
|
|
-- log("loading ", plugin)
|
2021-10-05 23:57:03 +00:00
|
|
|
pcall(loader, plugin)
|
2021-10-04 22:48:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-02-21 03:57:36 +00:00
|
|
|
end,
|
2021-09-24 01:54:03 +00:00
|
|
|
}
|