Breaking Change : LSPInstaller is dead so use mason.nvim

(#1368)
This commit is contained in:
siduck 2022-07-25 13:49:33 +00:00
parent 5d4c51127c
commit a83ebc34e5
7 changed files with 64 additions and 65 deletions

View File

@ -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()"

View File

@ -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" }, {

View File

@ -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 = "<CR>",
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)

View File

@ -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"

View File

@ -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 = "<CR>",
install_server = "i",
update_server = "u",
check_server_version = "c",
update_all_servers = "U",
check_outdated_servers = "C",
uninstall_server = "X",
cancel_installation = "<C-c>",
},
},
max_concurrent_installers = 10,
}
options = require("core.utils").load_override(options, "williamboman/mason")
mason.setup(options)

View File

@ -49,7 +49,7 @@ M.blankline = function()
"lspinfo",
"TelescopePrompt",
"TelescopeResults",
"lsp-installer",
"Mason",
"",
},
buftype_exclude = { "terminal" },

View File

@ -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,