ray-x / lsp_signature.nvim

LSP signature hint as you type
Apache License 2.0
1.98k stars 53 forks source link

Attempt to call field 'get_clients' (a nil value) #311

Closed fnune closed 4 months ago

fnune commented 4 months ago

Hi! I'm getting this exception after the lsp_signature pop-up has appeared, but immediately after I type a character while the pop-up is open:

Error detected while processing function CursorHoldI_Cb[5]..CursorHoldI Autocommands for "<buffer=6>":
E5108: Error executing lua .../nvim/lazy/lsp_signature.nvim/lua/lsp_signature/init.lua:1028: attempt to call field 'get_clients' (a nil value)
stack traceback:
        .../nvim/lazy/lsp_signature.nvim/lua/lsp_signature/init.lua:1028: in function 'check_signature_should_close'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue

lsp_signature version: https://github.com/ray-x/lsp_signature.nvim/commit/fc7231f3cf387177c010eae032e0b43499e42709

Blake-John commented 4 months ago

I met this problem, too. It seems that the function get_clients is not supported. So I went to the ~/.local/share/nvim/lazy/lsp_signature.nvim/lua/lsp_signature/init.lua file, and change the 1028 line from local clients = vim.lsp.get_clients({ bufnr = bufnr }) to local clients = vim.lsp.get_active_clients ({bufnr = bufnr}), and it works !

fnune commented 4 months ago

Looks like get_clients is Neovim 0.10+ only. 0.9 (stable) Neovim only provides get_active_clients.

So lsp_signature needs to check the Neovim version and use one of either.

See https://neovim.io/doc/user/news.html

image

ray-x commented 4 months ago

Thanks for the quick fix.