nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.29k stars 114 forks source link

[BUG] Watcher fails to find the lsp client after update to latest neotest with nio #383

Open sovetnik opened 6 months ago

sovetnik commented 6 months ago

NeoVim Version NVIM v0.9.5 Build type: Release LuaJIT 2.1.1710088188

Describe the bug After update with nio dependency, watcher fails to start.

E5108: Error executing lua ...e/nvim/site/pack/packer/start/nvim-nio/lua/nio/tasks.lua:95: Async task failed without callback: The coroutine failed with this message:
...acker/start/neotest/lua/neotest/consumers/watch/init.lua:50: attempt to call field 'client' (a nil value)
stack traceback:
        ...acker/start/neotest/lua/neotest/consumers/watch/init.lua: in function 'get_lsp_client'
        ...acker/start/neotest/lua/neotest/consumers/watch/init.lua:107: in function 'watch'
        ...acker/start/neotest/lua/neotest/consumers/watch/init.lua:157: in function 'func'
        ...e/nvim/site/pack/packer/start/nvim-nio/lua/nio/tasks.lua:168: in function <...e/nvim/site/pack/packer/start/nvim-nio/lua/nio/tasks.lua:167>
stack traceback:
        [C]: in function 'error'
        ...e/nvim/site/pack/packer/start/nvim-nio/lua/nio/tasks.lua:95: in function 'close_task'
        ...e/nvim/site/pack/packer/start/nvim-nio/lua/nio/tasks.lua:117: in function 'step'
        ...e/nvim/site/pack/packer/start/nvim-nio/lua/nio/tasks.lua:145: in function 'toggle'
        [string ":lua"]:1: in main chunk

To Reproduce Open any .exs file and fire watch via <Cmd>lua require('neotest').watch.toggle(vim.fn.expand('%'))<CR> hotkey

Expected behavior Watcher should start watching and provide test output as in previous version.

Additional info For buffer for example 7, i found a response with elixirls. Both commands below give the same result.

vim.print(vim.lsp.get_active_clients({bufnr = 7}))
vim.print(require("nio").lsp.get_clients({ name = "elixirls" }))
{
    ...
      cmd = { "/opt/homebrew/bin/elixir-ls" },
      cmd_cwd = "/Users/sovetnik/dev/umwelt_ex",
      filetypes = { "elixir", "eelixir", "heex", "surface" },
      flags = {},
      get_language_id = <function 3>,
      handlers = <1>{},
      init_options = vim.empty_dict(),
      log_level = 2,
      message_level = 2,
      name = "elixirls",

}
zopu commented 6 months ago

I'm seeing the same error on stock lazyvim go config when hitting "w" in the neotest summary:

E5108: Error executing lua: ...username/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:95: Async task failed without callback: The coroutine failed with this message: ...e/nvim/lazy/neotest/lua/neotest/consumers/watch/init.lua:50: attempt to call field 'client' (a nil value) stack traceback: ...e/nvim/lazy/neotest/lua/neotest/consumers/watch/init.lua: in function 'get_lsp_client' ...e/nvim/lazy/neotest/lua/neotest/consumers/watch/init.lua:107: in function 'watch' ...e/nvim/lazy/neotest/lua/neotest/consumers/watch/init.lua:157: in function 'toggle' ...lazy/neotest/lua/neotest/consumers/summary/component.lua:184: in function <...lazy/neotest/lua/neotest/consumers/summary/component.lua:183> stack traceback: [C]: in function 'error' ...perrow/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:95: in function 'close_task' ...perrow/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:117: in function 'step' ...perrow/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:145: in function 'run' ...lazy/neotest/lua/neotest/consumers/summary/component.lua:38: in function 'callback' ...im/lazy/neotest/lua/neotest/consumers/summary/canvas.lua:135: in function <...im/lazy/neotest/lua/neotest/consumers/summary/canvas.lua:133>

rcarriga commented 6 months ago

Thanks for the report, should be fixed now :smile:

sovetnik commented 6 months ago

Thanks for blazing fast fix, man!

zopu commented 6 months ago

Thanks!