feat(nvim): migrate from lsp-installer to mason and mason-lspconfig

This commit is contained in:
Stefan Imhoff
2022-08-10 13:53:21 +02:00
parent fa31dc836c
commit 7f84da2ae2
3 changed files with 27 additions and 16 deletions

View File

@@ -1,10 +1,10 @@
local status_ok, _ = pcall(require, 'lspconfig') local status_ok, _ = pcall(require, "lspconfig")
if not status_ok then if not status_ok then
return return
end end
require('kogakure.lsp.configs') require("kogakure.lsp.mason")
require('kogakure.lsp.handlers').setup() require("kogakure.lsp.handlers").setup()
require('kogakure.lsp.null-ls') require("kogakure.lsp.null-ls")
require('kogakure.lsp.trouble') require("kogakure.lsp.trouble")
require('kogakure.lsp.lightbulb') require("kogakure.lsp.lightbulb")

View File

@@ -1,9 +1,18 @@
local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer") local mason_status_ok, mason = pcall(require, "mason")
if not status_ok then local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
local mason_lsp_config_status_ok, mason_lspconfig = pcall(require, "mason-lspconfig")
if not mason_status_ok then
return return
end end
local lspconfig = require("lspconfig") if not lspconfig_status_ok then
return
end
if not mason_lsp_config_status_ok then
return
end
local servers = { local servers = {
"cssls", "cssls",
@@ -19,25 +28,26 @@ local servers = {
"stylelint_lsp", "stylelint_lsp",
"sumneko_lua", "sumneko_lua",
"svelte", "svelte",
"tailwindcss",
"theme_check", "theme_check",
"tsserver", "tsserver",
"vuels", "vuels",
-- "remark_ls", -- "remark_ls",
} }
lsp_installer.settings({ mason.setup({
ui = { ui = {
icons = { icons = {
server_installed = "", package_installed = "",
server_pending = "", package_pending = "",
server_uninstalled = "", package_uninstalled = "",
}, },
}, },
max_concurrent_installers = 4, max_concurrent_installers = 4,
}) })
lsp_installer.setup({ mason_lspconfig.setup({
ensure_installed = servers, ensure_installed = servers,
}) })

View File

@@ -70,7 +70,8 @@ return packer.startup(function(use)
-- LSP -- LSP
use("neovim/nvim-lspconfig") -- Enable LSP use("neovim/nvim-lspconfig") -- Enable LSP
use("williamboman/nvim-lsp-installer") -- Simple to use language server installer use("williamboman/mason.nvim") -- Manage LSP servers, DAP servers, linters, and formatters
use("williamboman/mason-lspconfig.nvim") -- Bridge betwen Mason and lspconfig
use("jose-elias-alvarez/null-ls.nvim") -- Inject LSP diagnostics, code actions, and more use("jose-elias-alvarez/null-ls.nvim") -- Inject LSP diagnostics, code actions, and more
use("folke/trouble.nvim") -- Diagnostics use("folke/trouble.nvim") -- Diagnostics
use("creativenull/diagnosticls-configs-nvim") -- Collection of linters and formatters use("creativenull/diagnosticls-configs-nvim") -- Collection of linters and formatters