From a952d694e1304a41b6b0f905dfaabbd7247bdb99 Mon Sep 17 00:00:00 2001 From: ray-x Date: Tue, 5 Oct 2021 17:53:53 +1100 Subject: [PATCH] lazyload for lua-dev --- lua/navigator/lazyloader.lua | 50 ++++++++++++++--------------- lua/navigator/lspclient/clients.lua | 12 +++---- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lua/navigator/lazyloader.lua b/lua/navigator/lazyloader.lua index 8686c01..07e0066 100644 --- a/lua/navigator/lazyloader.lua +++ b/lua/navigator/lazyloader.lua @@ -1,35 +1,35 @@ return { init = function() -local loader = nil -local packer_plugins = packer_plugins or nil -- suppress warnings + 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 = { - ["nvim-lspconfig"] = "neovim/nvim-lspconfig", - ["guihua.lua"] = "ray-x/guihua.lua" - } + -- packer only + if packer_plugins ~= nil then -- packer install + local lazy_plugins = { + ["nvim-lspconfig"] = "neovim/nvim-lspconfig", + ["guihua.lua"] = "ray-x/guihua.lua" + } - if _NgConfigValues.lspinstall == true then - lazy_plugins["nvim-lspinstall"] = "kabouzeid/nvim-lspinstall" - end + if _NgConfigValues.lspinstall == true then + lazy_plugins["nvim-lspinstall"] = "kabouzeid/nvim-lspinstall" + end - -- 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 + -- 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 -- log("loading ", plugin) - loader(plugin) - end - end + loader(plugin) + end + end end - if _NgConfigValues.lspinstall == true then - local has_lspinst, lspinst = pcall(require, "lspinstall") + if _NgConfigValues.lspinstall == true then + local has_lspinst, lspinst = pcall(require, "lspinstall") log('lspinstall', has_lspinst) - if has_lspinst then - lspinst.setup() + if has_lspinst then + lspinst.setup() local configs = require "lspconfig/configs" local servers = require'lspinstall'.installed_servers() for _, server in pairs(servers) do @@ -39,9 +39,9 @@ if packer_plugins ~= nil then -- packer install lsp_inst_cfg = lsp_inst_cfg.document_config.default_config lsp_inst_cfg = vim.tbl_deep_extend('keep', lsp_inst_cfg, cfg) require'lspconfig'[server].setup(lsp_inst_cfg) - end - end -end + end + end + end end end, load = function(plugin_name, path) diff --git a/lua/navigator/lspclient/clients.lua b/lua/navigator/lspclient/clients.lua index 06c1487..0aee800 100644 --- a/lua/navigator/lspclient/clients.lua +++ b/lua/navigator/lspclient/clients.lua @@ -44,7 +44,7 @@ local luadevcfg = { } local luadev = {} -require'navigator.lazyloader'.load('lua-dev', 'folke/lua-dev.nvim') +require'navigator.lazyloader'.load('lua-dev.nvim', 'folke/lua-dev.nvim') local ok, l = pcall(require, "lua-dev") if ok and l then luadev = l.setup(luadevcfg) @@ -474,12 +474,12 @@ local function lsp_startup(ft, retry, user_lsp_opts) end if not _NG_Loaded['efm'] then - local efm_cfg = user_lsp_opts['efm'] - if efm_cfg then - lspconfig.efm.setup(efm_cfg) + local efm_cfg = user_lsp_opts['efm'] + if efm_cfg then + lspconfig.efm.setup(efm_cfg) log('efm loading') _NG_Loaded['efm'] = true - end + end end if not retry or ft == nil then return @@ -494,7 +494,7 @@ local function get_cfg(client) return ng_setup else return ng_cfg - end + end end local function setup(user_opts)