From a83ebc34e547c0e28022e2a5f414deaba22c485f Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 25 Jul 2022 13:49:33 +0000 Subject: [PATCH] Breaking Change : LSPInstaller is dead so use mason.nvim (#1368) --- lua/core/init.lua | 3 +++ lua/core/lazy_load.lua | 37 ++++++++++++--------------- lua/plugins/configs/lsp_installer.lua | 36 -------------------------- lua/plugins/configs/lspconfig.lua | 1 - lua/plugins/configs/mason.lua | 36 ++++++++++++++++++++++++++ lua/plugins/configs/others.lua | 2 +- lua/plugins/init.lua | 14 +++++----- 7 files changed, 64 insertions(+), 65 deletions(-) delete mode 100644 lua/plugins/configs/lsp_installer.lua create mode 100644 lua/plugins/configs/mason.lua diff --git a/lua/core/init.lua b/lua/core/init.lua index 4ec415e..1dbb4c3 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -1,3 +1,6 @@ +-- add binaries installed by mason.nvim to path +vim.env.PATH = vim.env.PATH .. ":" .. vim.fn.stdpath "data" .. "/mason/bin" + -- commands vim.cmd "silent! command! NvChadUpdate lua require('nvchad').update_nvchad()" vim.cmd "silent! command! NvChadSnapshotCreate lua require('nvchad').snap_create()" diff --git a/lua/core/lazy_load.lua b/lua/core/lazy_load.lua index a4018b0..68b9df9 100644 --- a/lua/core/lazy_load.lua +++ b/lua/core/lazy_load.lua @@ -1,11 +1,11 @@ local M = {} local autocmd = vim.api.nvim_create_autocmd +-- require("packer").loader(tb.plugins) -- This must be used for plugins that need to be loaded just after a file -- ex : treesitter, lspconfig etc M.lazy_load = function(tb) autocmd(tb.events, { - pattern = "*", group = vim.api.nvim_create_augroup(tb.augroup_name, {}), callback = function() if tb.condition() then @@ -13,12 +13,15 @@ M.lazy_load = function(tb) -- dont defer for treesitter as it will show slow highlighting -- This deferring only happens only when we do "nvim filename" - if tb.plugins ~= "nvim-treesitter" then + if tb.plugin ~= "nvim-treesitter" then vim.defer_fn(function() - vim.cmd("PackerLoad " .. tb.plugins) + require("packer").loader(tb.plugin) + if tb.plugin == "nvim-lspconfig" then + vim.cmd "silent! e %" + end end, 0) else - vim.cmd("PackerLoad " .. tb.plugins) + require("packer").loader(tb.plugin) end end end, @@ -33,7 +36,7 @@ M.on_file_open = function(plugin_name) M.lazy_load { events = { "BufRead", "BufWinEnter", "BufNewFile" }, augroup_name = "BeLazyOnFileOpen" .. plugin_name, - plugins = plugin_name, + plugin = plugin_name, condition = function() local file = vim.fn.expand "%" return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= "" @@ -41,22 +44,6 @@ M.on_file_open = function(plugin_name) } end --- lspinstaller & lspconfig cmds for lazyloading -M.lsp_cmds = { - "LspInfo", - "LspStart", - "LspRestart", - "LspStop", - "LspInstall", - "LspUnInstall", - "LspUnInstallAll", - "LspInstall", - "LspInstallInfo", - "LspInstallLog", - "LspLog", - "LspPrintInstalled", -} - M.treesitter_cmds = { "TSInstall", "TSBufEnable", @@ -66,6 +53,14 @@ M.treesitter_cmds = { "TSModuleInfo", } +M.mason_cmds = { + "Mason", + "MasonInstall", + "MasonUninstall", + "MasonUninstallAll", + "MasonLog", +} + M.gitsigns = function() -- taken from https://github.com/max397574 autocmd({ "BufRead" }, { diff --git a/lua/plugins/configs/lsp_installer.lua b/lua/plugins/configs/lsp_installer.lua deleted file mode 100644 index 3afe108..0000000 --- a/lua/plugins/configs/lsp_installer.lua +++ /dev/null @@ -1,36 +0,0 @@ -local present, lsp_installer = pcall(require, "nvim-lsp-installer") - -if not present then - return -end - -local options = { - -- ensure_installed is not needed as automatic_installation is enabled - -- then any lsp server you setup by lspconfig is going to get installed automatically! - - -- ensure_installed = { "lua" }, - automatic_installation = true, - - ui = { - icons = { - server_installed = " ", - server_pending = " ", - server_uninstalled = " ﮊ", - }, - keymaps = { - toggle_server_expand = "", - install_server = "i", - update_server = "u", - check_server_version = "c", - update_all_servers = "U", - check_outdated_servers = "C", - uninstall_server = "X", - }, - }, - - max_concurrent_installers = 10, -} - -options = require("core.utils").load_override(options, "williamboman/nvim-lsp-installer") - -lsp_installer.setup(options) diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index ecb376a..f69c5c3 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -6,7 +6,6 @@ end require("base46").load_highlight "lsp" require "nvchad_ui.lsp" -require "plugins.configs.lsp_installer" local M = {} local utils = require "core.utils" diff --git a/lua/plugins/configs/mason.lua b/lua/plugins/configs/mason.lua new file mode 100644 index 0000000..6c2a800 --- /dev/null +++ b/lua/plugins/configs/mason.lua @@ -0,0 +1,36 @@ +local present, mason = pcall(require, "mason") + +if not present then + return +end + +require("base46").load_highlight "mason" + +local options = { + ensure_installed = { "pyright" }, + + ui = { + icons = { + package_pending = " ", + package_installed = " ", + package_uninstalled = " ﮊ", + }, + + keymaps = { + toggle_server_expand = "", + install_server = "i", + update_server = "u", + check_server_version = "c", + update_all_servers = "U", + check_outdated_servers = "C", + uninstall_server = "X", + cancel_installation = "", + }, + }, + + max_concurrent_installers = 10, +} + +options = require("core.utils").load_override(options, "williamboman/mason") + +mason.setup(options) diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index 3272f8a..a8d4283 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -49,7 +49,7 @@ M.blankline = function() "lspinfo", "TelescopePrompt", "TelescopeResults", - "lsp-installer", + "Mason", "", }, buftype_exclude = { "terminal" }, diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 729c0de..3757141 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -82,16 +82,18 @@ local plugins = { -- lsp stuff - ["williamboman/nvim-lsp-installer"] = { - cmd = require("core.lazy_load").lsp_cmds, - setup = function() - require("core.lazy_load").on_file_open "nvim-lsp-installer" + ["williamboman/mason.nvim"] = { + cmd = require("core.lazy_load").mason_cmds, + config = function() + require "plugins.configs.mason" end, }, ["neovim/nvim-lspconfig"] = { - after = "nvim-lsp-installer", - module = "lspconfig", + opt = true, + setup = function() + require("core.lazy_load").on_file_open "nvim-lspconfig" + end, config = function() require "plugins.configs.lspconfig" end,