stevearc / dressing.nvim

Neovim plugin to improve the default vim.ui interfaces
MIT License
1.82k stars 32 forks source link

Receiving error "attempt to index field 'ctx' (a nil value)" #128

Closed miversen33 closed 10 months ago

miversen33 commented 10 months ago

Describe the bug I am receiving an error when I attempt to execute vim.lsp.buf.code_action. At first I thought this was something broken in my configuration (which is probably still correct) but it seems that dressing assumes items (in dressing.select.telescope.custom_kind.codeaction will always have a context associated with them. Might be true, might not. I am unsure

A picture is worth a thousand words so here is a screenshot of the error image

System information

-- Paste your call to require("dressing").setup(...) in here
require("dressing").setup()

To Reproduce Steps to reproduce the behavior:

  1. Open a file that has a running LSP (that provides code actions). In my case I am using rust-analyzer but I have tested this with a few different LSPs
  2. Move cursor to a position that should have a code action available
  3. Execute :lua vim.lsp.buf.code_action

If possible, provide a minimal file that will trigger the issue (see tests/manual for examples of short ways to call vim.ui.*):

Given that you need a handful of things setup for this, I do not know that I can provide a simple configuration file to reliably trigger the issue (though you can always pull my dotfiles down and use them

Screenshots If applicable, add screenshots to help explain your problem.

Additional context This issue is localized to only "older" versions of the nightly release. I have tested on the following Neovim version

Might I suggest updating the following code snippet

-- https://github.com/stevearc/dressing.nvim/blob/master/lua/dressing/select/telescope.lua#L28C1-L32C10
      if vim.fn.has("nvim-0.10") == 1 then
        client_id = item.ctx.client_id
      else
        client_id = item[1]
      end

to something like?

    client_id = item.ctx and item.ctx.client_id or item[1]
ariel-frischer commented 10 months ago

Same

jamestrew commented 10 months ago

I had the same issue but updating neovim fixes this it seems. I'm on NVIM v0.10.0-dev-1532+gc23dd7c9e but it looks like it's been fixed for a few days https://github.com/stevearc/dressing.nvim/issues/126#issuecomment-1799470315

stevearc commented 10 months ago

This was caused by a backwards-incompatible change in nvim nightly. It was fixed in the linked issue, but that means that if you had an older version of nightly it would now error. If you update to the newest nightly and newest dressing it should be error-free