neovim / nvim-lspconfig

Quickstart configs for Nvim LSP
Apache License 2.0
10.75k stars 2.08k forks source link

attempt to index local 'self' (a number value) #2782

Closed swtch1 closed 1 year ago

swtch1 commented 1 year ago

Description

I updated to the latest version of nvim-lspconfig. Now when starting neovim I get the following error.

Here's the relevant snippet from my config

local lsp_installer = require("nvim-lsp-installer")
local cmp_lsp = require('cmp_nvim_lsp')
local lsp_installer_servers = require('nvim-lsp-installer.servers')
local requestedLSPServers = {
    bashls = {},
}
for lsp, opts in pairs(requestedLSPServers) do
    local capabilities = cmp_lsp.default_capabilities(vim.lsp.protocol.make_client_capabilities())
    local available, lsp_server = lsp_installer_servers.get_server(lsp)
    opts["on_attach"] = on_attach
    opts["capabilities"] = capabilities
    opts["flags"] = { debounce_text_changes = 150 }
    if available and not lsp_server:is_installed() then
        lsp_server:install()
    end
    lsp_server:on_ready(function()
        lsp_server:setup(opts)
    end)
end

Neovim version

NVIM v0.9.1 Build type: Release LuaJIT 2.1.0-beta3

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/local/Cellar/neovim/0.9.1/share/nvim"

Run :checkhealth for more info

Nvim-lspconfig version

1cfb96490c3889a2c57d1ef5e1acc59e9b47c455

Operating system and version

macOS 13.4

Affected language servers

all

Steps to reproduce

Apologies but I'm not good enough to create a minimal working config in the amount of time I have. I have added the relevant parts of my config below.

Actual behavior

Error detected while processing /Users/<me>/.config/nvim/init.vim:
line    6:
E5108: Error executing lua ...sh/.vim/plugged/nvim-lspconfig/lua/lspconfig/manager.lua:290: attempt to index local 'self' (a number value)
stack traceback:
        ...sh/.vim/plugged/nvim-lspconfig/lua/lspconfig/manager.lua:290: in function 'try_add_wrapper'
        ...ged/nvim-lsp-installer/lua/nvim-lsp-installer/server.lua:91: in function 'attach_buffers'
        ...ged/nvim-lsp-installer/lua/nvim-lsp-installer/server.lua:80: in function 'setup'
        /Users/<me>/.config/nvim/lua/lsp.lua:417: in function 'handler'
        ...ged/nvim-lsp-installer/lua/nvim-lsp-installer/server.lua:105: in function 'on_ready'
        /Users/<me>/.config/nvim/lua/lsp.lua:416: in main chunk
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk

Expected behavior

No error

Minimal config

This is the relevant snippet from my config.  Notice I'm using `nvim-lsp-installer`.

local lsp_installer = require("nvim-lsp-installer")
local cmp_lsp = require('cmp_nvim_lsp')
local lsp_installer_servers = require('nvim-lsp-installer.servers')
local requestedLSPServers = {
    bashls = {},
}
for lsp, opts in pairs(requestedLSPServers) do
    local capabilities = cmp_lsp.default_capabilities(vim.lsp.protocol.make_client_capabilities())
    local available, lsp_server = lsp_installer_servers.get_server(lsp)
    opts["on_attach"] = on_attach
    opts["capabilities"] = capabilities
    opts["flags"] = { debounce_text_changes = 150 }
    if available and not lsp_server:is_installed() then
        lsp_server:install()
    end
    lsp_server:on_ready(function()
        lsp_server:setup(opts)
    end)
end


### LSP log

https://gist.github.com/swtch1/8ede5e6eed6db66237ec99e97cddb82c
glepnir commented 1 year ago

issue in nvim-lsp-installer

sycbarry commented 1 year ago

Hi, I am also receiving the error. Just updated my nvim-lsp-installer last night.

felippemr commented 1 year ago

Ported over to https://github.com/williamboman/mason.nvim and the problem was fixed!