nvim-lua / lsp-status.nvim

Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
MIT License
621 stars 41 forks source link

table index is nil in util.lua #69

Open gabysbrain opened 2 years ago

gabysbrain commented 2 years ago

I tried setting up lsp-status according to the example config in the readme but once my lsp loads I get an error (also see https://github.com/nvim-lua/lsp-status.nvim/issues/9#issuecomment-913260530 who seems to be having the same issue):

Error executing vim.schedule lua callback: .../start/lsp-status.nvim/lua/lsp-status/util.lua:62: table index is nil

My lsp/lsp-status config is here. It's basically the lsp-status config from the readme but integrated into the default config from lspconfig.

-- setup lsp status
local lsp_status = require('lsp-status')
lsp_status.config({
})
lsp_status.register_progress()

local nvim_lsp = require('lspconfig')

-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
  local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
  local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end

  -- Enable completion triggered by <c-x><c-o>
  buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')

-- key bindings

-- lsp_status
  lsp_status.on_attach(client)
end

-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'julials' }
for _, lsp in ipairs(servers) do
  nvim_lsp[lsp].setup {
    on_attach = on_attach,
    capabilities = lsp_status.capabilities,
    flags = {
      debounce_text_changes = 150,
    }
  }
end

From looking at the lsp-status source my guess is that id is never set but I can't figure out why.

scrouthtv commented 2 years ago

I have the same issue with a similar config, have you found a fix yet?

gabysbrain commented 2 years ago

Nope, I can't use this plugin until it's fixed unfortunuately.

On Fri, Dec 03, 2021 at 12:14:05AM -0800, scrouthtv wrote:

I have the same issue with a similar config, have you found a fix yet?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.*

wbthomason commented 2 years ago

Sorry for neglecting to get to this for so long. I've been unable to reproduce this issue with your config - do you see this error with servers other than JuliaLS, or just that server?

wbthomason commented 2 years ago

Also, if you're willing to help debug this, could you please try putting print calls with unique messages at the calls to util.ensure_init in lsp_status.messaging.register_client and lsp_status.messaging.progress_callback, so that we can narrow down where the nil value is occurring?

scrouthtv commented 2 years ago

I'm also not able to reproduce this issue anymore. I tried some things in my config, I guess the order in which plugins are loaded is relevant. The plugin is currently working for me.

gabysbrain commented 2 years ago

yes, it's working for me too now! lightline doesn't seem to support animations but that's fine.