Closed vikulikov closed 3 days ago
Hmm I can't reproduce this using rust-analyzer 1.84.0-nightly (1e4f10ba 2024-10-29) and master Neovim. Are you sure that no further settings are needed?
https://github.com/user-attachments/assets/f0df20f4-76b3-4387-bfe8-352dec59acc7
rust-analyzer 0.0.0 (468b5cd43 2024-10-29)
https://github.com/user-attachments/assets/4d6a6048-25ab-473f-82d5-05d24ecca966
Sorry, thought gif from glepnir was enough. I guess something fast should happen to trigger cancellation of the previous request to the server. fast typing or typing before server has indexed the project
And the configuration is really basic as attached in the issue description
Workaround to ignore the ServerCancelled
error:
for _, method in ipairs({ 'textDocument/diagnostic', 'workspace/diagnostic' }) do
local default_diagnostic_handler = vim.lsp.handlers[method]
vim.lsp.handlers[method] = function(err, result, context, config)
if err ~= nil and err.code == -32802 then
return
end
return default_diagnostic_handler(err, result, context, config)
end
end
I can confirm that this issue affects me too. Using Arch and the problem was introduced after doing pacman -Suy
.
The workaround of @Jesse-Bakker worked for me, thanks!
For now I have downgraded version of rust-analyzer to 2024-10-14
Where would one put this workaround?
I added that into the section of init.lua
that installs an OnAttach
hook for the LSP subsystem. I add all per-buffer LSP setup in the callback for that hook.
Where would one put this workaround?
I put it in my ftplugin/rust: https://github.com/praveenperera/dotfiles/commit/3cd2a6d3c1cc05f3c8f6245e3d918e350859a33a
seem the lua script that put in init.lua not work on astronvim. Downgrade is seem work for me.
@getcisher im using astronvim and putting it in after works, see comment above.
I have the same on today's Rust and today's Neovim.
In :LspLog
I see errors like this:
2024-11-20T10:32:20.078245832Z ERROR synthetic syntax
Not sure if it's related?
Same here, but it will be gone seconds later.
I use nvim-lspconfig
and cmp
in my config instead and it's simpler:
local lspconfig = require("lspconfig")
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local function default_config(t)
for _, name in ipairs(t) do
lspconfig[name].setup {
capabilities = capabilities,
}
end
end
default_config({
-- SNIP --
"rust_analyzer",
-- SNIP --
})
Please do not add duplicate problem descriptions! Issue reports already have a clear minimal reproduce config to reproduce the problem and before comments has a workaround as temporary solution.
Same is happening to me, downgrading to 2024-10-14 seems to remove the problem 👍🏼
Problem
editor is being interrupted with message
rust_analyzer: -32802: server cancelled the request
while typing on every keystroke after the latest updates of rust-analyzerSteps to reproduce using "nvim -u minimal_init.lua"
Just start typing in
main.rs
insidefn main() {|}
ofcargo new --bin test_project
Expected behavior
There is no this message with interrupt
Nvim version (nvim -v)
NVIM v0.10.2 Build type: Release LuaJIT 2.1.1727870382
Language server name/version
rust-analyzer 0.0.0 (3b3a87fe9 2024-10-27)
Operating system/version
macos 15.1
Log file
No response