Skip to content

lua/lsp-status/messaging.lua:24: attempt to index a nil value #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lithammer opened this issue Jun 1, 2020 · 3 comments
Closed

lua/lsp-status/messaging.lua:24: attempt to index a nil value #6

lithammer opened this issue Jun 1, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@lithammer
Copy link

lithammer commented Jun 1, 2020

I get this error when opening Rust file using rust-analyzer.

Error executing vim.schedule lua callback: .../opt/lsp-status.nvim/lua/lsp-status/messaging.lua:24: attempt to index a nil value

Did some print debugging, and I suspect that maybe goes wrong because of the global messages table in lua/lsp-status/messaging.lua and there's two messages in parallel (rustAnalyzer/cargoWatcher and rustAnalyzer/startup). But that's just a hunch.

client_id = 1
msg.token = rustAnalyzer/cargoWatcher
messages =  { {
    messages = {},
    name = "rust_analyzer",
    progress = {
      ["rustAnalyzer/startup"] = {
        message = "0/10 packages",
        percentage = 0,
        spinner = 1,
        title = "rust-analyzer"
      }
    },
    status = {}
  } }
Error executing vim.schedule lua callback: ...ackager/opt/lsp-status.nvim/lua/lsp-status/messaging.lua:24: attempt to index a nil value
client_id = 1
msg.token = rustAnalyzer/startup
messages =  { {
    messages = {},
    name = "rust_analyzer",
    progress = {
      ["rustAnalyzer/startup"] = {
        message = "9/10 packages",
        percentage = 90,
        spinner = 10,
        title = "rust-analyzer"
      }
    },
    status = {}
  } }
client_id = 1
msg.token = rustAnalyzer/cargoWatcher
messages =  { {
    messages = {},
    name = "rust_analyzer",
    progress = {
      ["rustAnalyzer/cargoWatcher"] = {
        spinner = 1,
        title = "Running `cargo check`"
      }
    },
    status = {}
  } }

As you can see in the first message msg.token is rustAnalyzer/cargoWatcher, but the progress table only contains rustAnalyzer/startup causing a lookup error on this line:

https://github.com/wbthomason/lsp-status.nvim/blob/d6ad84228c7a30dc6295afde110edb31bc331bdb/lua/lsp-status/messaging.lua#L24

@wbthomason
Copy link
Collaborator

Thanks for the report! I'll try to replicate the error.

@wbthomason wbthomason added the bug Something isn't working label Jun 1, 2020
@wbthomason
Copy link
Collaborator

Ah. So, this looks to be because rust-analyzer sends that rustAnalyzer/cargoWatcher message as an "end" kind without a corresponding "begin" first.

It looks like this might be a known rust-analyzer bug: rust-lang/rust-analyzer#4384

However, I should still add code to check that we have info for a token before trying to update it.

@lithammer
Copy link
Author

Thanks for the quick response and fix! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants