LunarVim / Neovim-from-scratch

📚 A Neovim config designed from scratch to be understandable
https://www.chrisatmachine.com/
GNU General Public License v3.0
5.31k stars 1.17k forks source link

Mason to replace nvim-lsp-installer #248

Closed aquinjay closed 1 year ago

aquinjay commented 1 year ago

On my machine, mason does not function because it is not being called by require. It seems that replacing user/lsp/mason.lua line 1 from "nvim-lsp-installer" to "mason" will fix the issue. It seems that "nvim-lsp-installer" should not be used at all since the repo is no longer maintained.Will look into how to make a pr tonight.

aquinjay commented 1 year ago

I can't do any pushing here (first time ever trying to work on anyone else's repo). Seems like you will need something like this in the mason.lua file:

local status_ok, lsp_installer = pcall(require, "mason")
if not status_ok then
    return
end

local status_ok, lsp_config= pcall(require, "mason-lspconfig")
if not status_ok then
    return
end

lsp_installer.setup()

local lspconfig = require("lspconfig")

local servers = { "jsonls", "sumneko_lua", "pyright" }

lsp_config.setup({
    ensure_installed = servers,
})

for _, server in pairs(servers) do
    local opts = {
        on_attach = require("lsp.handlers").on_attach,
        capabilities = require("lsp.handlers").capabilities,
    }
    local has_custom_opts, server_custom_opts = pcall(require, "lsp.settings." .. server)
    if has_custom_opts then
        opts = vim.tbl_deep_extend("force", opts, server_custom_opts)
    end
    lspconfig[server].setup(opts)
end
gnmearacaun commented 1 year ago

Thanks for bringing this up. Should be fixed now.

aquinjay commented 1 year ago

Seems like the fix is causing messages to appear when you start up neovim. It says mason-lspconfig is automatically installing the specified servers in the mason file. Setting automatic_installation to false seems to fix it. There may be a better way to suppress those messages though.