From 4f62c30d80a52ea41a4c0d1f12195aa01c89c2eb Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Mon, 25 Nov 2024 21:05:07 +0100 Subject: [PATCH] fix: various `:RustAnalyzer target` regressions (#591) Co-authored-by: Marc Jakobi --- lua/rustaceanvim/lsp/init.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/rustaceanvim/lsp/init.lua b/lua/rustaceanvim/lsp/init.lua index d22837f5..1a60549a 100644 --- a/lua/rustaceanvim/lsp/init.lua +++ b/lua/rustaceanvim/lsp/init.lua @@ -311,12 +311,18 @@ M.set_target_arch = function(bufnr, target) restart(bufnr, { exclude_rustc_target = target }, function(client) rustc.with_rustc_target_architectures(function(rustc_targets) if rustc_targets[target] then - client.settings['rust-analyzer'].cargo.target = target + local ra = client.config.settings['rust-analyzer'] + ra.cargo = ra.cargo or {} + ra.cargo.target = target client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }) - vim.notify('Target architecture updated successfully to: ' .. target, vim.log.levels.INFO) + vim.schedule(function() + vim.notify('Target architecture updated successfully to: ' .. target, vim.log.levels.INFO) + end) return else - vim.notify('Invalid target architecture provided: ' .. tostring(target), vim.log.levels.ERROR) + vim.schedule(function() + vim.notify('Invalid target architecture provided: ' .. tostring(target), vim.log.levels.ERROR) + end) return end end) @@ -353,7 +359,7 @@ local function rust_analyzer_cmd(opts) M.reload_settings() elseif cmd == RustAnalyzerCmd.target then local target_arch = fargs[2] - M.set_target_arch(target_arch) + M.set_target_arch(nil, target_arch) end end