Skip to content

Commit

Permalink
feat(lsp): make lsp work when mason-lspconfig is disabled. Fixed #445
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Mar 17, 2023
1 parent f0b548a commit c10e550
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions lua/lazyvim/plugins/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,8 @@ return {
require("lspconfig")[server].setup(server_opts)
end

-- temp fix for lspconfig rename
-- https://github.com/neovim/nvim-lspconfig/pull/2439
local mappings = require("mason-lspconfig.mappings.server")
if not mappings.lspconfig_to_package.lua_ls then
mappings.lspconfig_to_package.lua_ls = "lua-language-server"
mappings.package_to_lspconfig["lua-language-server"] = "lua_ls"
end

local mlsp = require("mason-lspconfig")
local available = mlsp.get_available_servers()
local have_mason, mlsp = pcall(require, "mason-lspconfig")
local available = have_mason and mlsp.get_available_servers() or {}

local ensure_installed = {} ---@type string[]
for server, server_opts in pairs(servers) do
Expand All @@ -125,8 +117,10 @@ return {
end
end

require("mason-lspconfig").setup({ ensure_installed = ensure_installed })
require("mason-lspconfig").setup_handlers({ setup })
if have_mason then
mlsp.setup({ ensure_installed = ensure_installed })
mlsp.setup_handlers({ setup })
end
end,
},

Expand Down

0 comments on commit c10e550

Please sign in to comment.