I’ve been trying to setup an async formatter with LSP and multiple clients.
So looked into the runtime code, trying to understand what I need to change to fit my reqs.
then I came about this piece of code in lsp/buf.lua
: neovim/buf.lua at 2a3cb0893b03aeff4d8c0b2116cbddda53bba5a2 · neovim/neovim · GitHub
local result, err = client.request_sync(method, params, timeout_ms, bufnr)
if result and result.result then
util.apply_text_edits(result.result, bufnr, client.offset_encoding)
elseif err then
vim.notify(string.format('[LSP][%s] %s', client.name, err), vim.log.levels.WARN)
end
the problem is that request_sync
returns a single table result: neovim/lsp.lua at 2a3cb0893b03aeff4d8c0b2116cbddda53bba5a2 · neovim/neovim · GitHub
request_result = { err = err, result = result }
and then in line 1442
return request_result
since the code checks result and result.result
it’s obvious that the happy path was fixed,
but the error check is broken
should be elseif result.err
so… first time writing here. … is this a bug? if so, what’s next? report on github? or send a simple PR with the fix? (I’ve no idea how to run tests etc, so not sure how valid that wold be)
/V