From d84b9285efa4498d7680cc000a5da42f3e4f287e Mon Sep 17 00:00:00 2001 From: ecosse3 Date: Sat, 14 May 2022 19:46:02 +0200 Subject: [PATCH] fix(lsp): fix lsp installer loading issues Fixes #47 --- lua/lsp/setup.lua | 8 ++++++-- lua/plugins.lua | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lua/lsp/setup.lua b/lua/lsp/setup.lua index 666ff827..50f7267c 100644 --- a/lua/lsp/setup.lua +++ b/lua/lsp/setup.lua @@ -1,7 +1,12 @@ -- Setup installer & lsp configs local typescript_ok, typescript = pcall(require, 'typescript') +local lsp_installer_ok, lsp_installer = pcall(require, 'nvim-lsp-installer') -require("nvim-lsp-installer").setup { +if not lsp_installer_ok then + return +end + +lsp_installer.setup { -- A list of servers to automatically install if they're not already installed ensure_installed = { "bashls", "cssls", "eslint", "graphql", "html", "jsonls", "sumneko_lua", "tailwindcss", "tsserver", "vetur", "vuels" }, -- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed @@ -26,7 +31,6 @@ end -- Order matters - -- It enables tsserver automatically so no need to call lspconfig.tsserver.setup if typescript_ok then typescript.setup({ diff --git a/lua/plugins.lua b/lua/plugins.lua index 1f632eea..7b483762 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -42,6 +42,7 @@ return require('packer').startup({ use { 'cljoly/telescope-repo.nvim' } -- LSP Base + use { 'williamboman/nvim-lsp-installer' } use { 'neovim/nvim-lspconfig' } -- LSP Cmp @@ -57,7 +58,6 @@ return require('packer').startup({ use { 'saadparwaiz1/cmp_luasnip', after = 'cmp-npm' } -- LSP Addons - use { 'williamboman/nvim-lsp-installer', event = 'BufEnter', after = 'cmp-nvim-lsp' } use { 'stevearc/dressing.nvim', requires = 'MunifTanjim/nui.nvim', config = "require('plugins.dressing')" } use { 'onsails/lspkind-nvim' } use { 'folke/lsp-trouble.nvim', config = "require('plugins.trouble')" }