From 113e6f1bd64373ec20640ea46c9e9c3e4d898a75 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:33:42 +0100 Subject: [PATCH] lsp(rust): work around server cancelled request issue with latest rust Ref.: https://github.com/neovim/neovim/issues/30985#issuecomment-2447329525 --- lua/nxvim/lsp/plugins/mason/lspconfig.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/nxvim/lsp/plugins/mason/lspconfig.lua b/lua/nxvim/lsp/plugins/mason/lspconfig.lua index 4b70ffa..793ef56 100644 --- a/lua/nxvim/lsp/plugins/mason/lspconfig.lua +++ b/lua/nxvim/lsp/plugins/mason/lspconfig.lua @@ -42,6 +42,14 @@ mason_lspconfig.setup_handlers({ server_opts.root_dir = lspconfig.util.root_pattern("deno.json", "deno.jsonc") elseif server == "jsonls" then server_opts.init_options = { provideFormatter = false } -- Use prettierd as formatter. + elseif server == "rust_analyzer" then + 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 elseif server == "zls" then vim.g.zig_fmt_autosave = 0 end