mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-05 20:43:28 +00:00
rust-analyzer.tests.neovim-lsp: fix race condition
This commit is contained in:
parent
69b095e77f
commit
21d8efad89
@ -9,20 +9,33 @@ runCommand "test-neovim-rust-analyzer" {
|
||||
}
|
||||
'';
|
||||
|
||||
# NB. Wait for server done type calculations before sending `hover` request,
|
||||
# otherwise it would return `{unknown}`.
|
||||
# Ref: https://github.com/rust-lang/rust-analyzer/blob/7b11fdeb681c12002861b9804a388efde81c9647/docs/dev/lsp-extensions.md#server-status
|
||||
nvimConfig = /* lua */ ''
|
||||
local caps = vim.lsp.protocol.make_client_capabilities()
|
||||
caps["experimental"] = { serverStatusNotification = true }
|
||||
vim.lsp.buf_attach_client(vim.api.nvim_get_current_buf(), vim.lsp.start_client({
|
||||
cmd = { "rust-analyzer" },
|
||||
capabilities = caps,
|
||||
handlers = {
|
||||
["$/progress"] = function(_, msg, ctx)
|
||||
if msg.token == "rustAnalyzer/Indexing" and msg.value.kind == "end" then
|
||||
vim.cmd("goto 23") -- let mut |var =...
|
||||
vim.lsp.buf.hover()
|
||||
["experimental/serverStatus"] = function(_, msg, ctx)
|
||||
if msg.health == "ok" then
|
||||
if msg.quiescent then
|
||||
vim.cmd("goto 23") -- let mut |var =...
|
||||
vim.lsp.buf.hover()
|
||||
end
|
||||
else
|
||||
print("error: server status is not ok: ")
|
||||
vim.cmd("q")
|
||||
end
|
||||
end,
|
||||
["textDocument/hover"] = function(_, msg, ctx)
|
||||
-- Keep newlines.
|
||||
io.write(msg.contents.value)
|
||||
vim.cmd("q")
|
||||
if msg then
|
||||
-- Keep newlines.
|
||||
io.write(msg.contents.value)
|
||||
vim.cmd("q")
|
||||
end
|
||||
end,
|
||||
},
|
||||
on_error = function(code)
|
||||
|
Loading…
Reference in New Issue
Block a user