The problem is that the code relies on #vim.lsp.buf_get_clients(), but vim.lsp.buf_get_clients() is an associative table and that operator doesn't work for that kind of table.
{
[3] = {
_on_attach = <function 1>,
callbacks = <1>{
["textDocument/declaration"] = <function 2>,
["textDocument/definition"] = <function 2>,
["textDocument/documentHighlight"] = <function 3>,
["textDocument/documentSymbol"] = <function 4>,
["textDocument/hover"] = <function 5>,
["textDocument/implementation"] = <function 2>,
["textDocument/publishDiagnostics"] = <function 6>,
["textDocument/references"] = <function 7>,
["textDocument/typeDefinition"] = <function 2>,
["window/logMessage"] = <function 8>,
["window/showMessage"] = <function 9>,
["workspace/configuration"] = <function 10>,
["workspace/symbol"] = <function 4>,
<metatable> = <2>{
__tostring = <function 11>
}
},
cancel_request = <function 12>,
config = {
_on_attach = <function 13>,
callbacks = <table 1>,
capabilities = {
callHierarchy = {
dynamicRegistration = false,
<metatable> = <table 2>
},
textDocument = {
codeAction = {
codeActionLiteralSupport = {
codeActionKind = {
valueSet = {},
<metatable> = <table 2>
},
<metatable> = <table 2>
},
dynamicRegistration = false,
<metatable> = <table 2>
},
completion = {
completionItem = {
commitCharactersSupport = false,
deprecatedSupport = false,
documentationFormat = { "markdown", "plaintext" },
preselectSupport = false,
snippetSupport = false,
<metatable> = <table 2>
...
The problem is that the code relies on #vim.lsp.buf_get_clients(), but vim.lsp.buf_get_clients() is an associative table and that operator doesn't work for that kind of table.
How to reproduce:
:lua vim.lsp.stop_client(vim.lsp.get_active_clients()):e!Some debugging information:
After restarting, here's the output of
print(vim.inspect(vim.lsp.buf_get_clients())):Notice how the key is
[3].