Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: various :RustAnalyzer target regressions #591

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lua/rustaceanvim/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,20 @@ 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
-- NOTE: It is not guaranteed that the 'cargo' subkey exists (atleast rustaceanvim does
-- not configure it by default).
local ra = client.config.settings['rust-analyzer']
ra.cargo = ra.cargo or {} -- Initialize the cargo subkey if necessary
mrcjkb marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand Down Expand Up @@ -353,7 +361,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

Expand Down