-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
feat(lsp): target architecture switching command for RustAnalyzer
#541
Conversation
Review ChecklistDoes this PR follow the Contribution Guidelines? Following is a partial checklist: Proper conventional commit scoping:
If applicable:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks great 🙏 😄
lua/rustaceanvim/lsp/targets.lua
Outdated
return rustc_targets_cache | ||
end | ||
|
||
local result = vim.system({ 'rustc', '--print', 'target-list' }):wait() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: vim.system():wait()
blocks Neovim's event loop.
It's generally better to use vim.system
and pass in a callback, which is a function(result)
where result
is a vim.SystemCompleted
.
This means that this function has to be changed, e.g. to with_rustc_targets(callback: fun(targets))
.
It's a bit of a refactor, but I think it's doable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@mrcjkb I worked on the improvement fixes. |
RustAnalyzer
target_switch3.mp4
By default, RustAnalyzer uses the system architecture when analyzing and building projects. However, we often need to work with alternative targets, such as WebAssembly (wasm32-unknown-unknown). Without the ability to switch targets easily, we must manually reconfigure our
rust-analyzer.config.target
which can be inefficient.Changes Made
ref: https://doc.rust-lang.org/rustc/targets/built-in.html