-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
perf: optimize target_arch switching #548
Conversation
Review ChecklistDoes this PR follow the Contribution Guidelines? Following is a partial checklist: Proper conventional commit scoping:
If applicable:
|
improved target switching and reduced nested callbacks @mrcjkb |
Head branch was pushed to by a user without write access
lua/rustaceanvim/rust_analyzer.lua
Outdated
if filter and filter.exclude_rustc_target then | ||
clients = vim.tbl_filter(function(client) | ||
local cargo_target = vim.tbl_get(client, 'config', 'settings', 'rust-analyzer', 'cargo', 'target') | ||
if filter.exclude_rustc_target == DEFAULT_RUSTC_TARGET and cargo_target == nil then |
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.
issue: DEFAULT_RUSTC_TARGET
is in the rustc
module (ditto for the other usages).
tip: If you have Nix installed, I recommend you enter a nix devShell (nix develop
) and run pre-commit run --all-files
.
It will run all the type checks and lints needed to catch these issues.
Otherwise, you can run luacheck
and the lua-language-server
CLI to get the lints without using Nix.
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! done
lua/rustaceanvim/lsp/init.lua
Outdated
local clients = rust_analyzer.get_active_rustaceanvim_clients(bufnr) | ||
local clients = rust_analyzer.get_active_rustaceanvim_clients( | ||
bufnr, | ||
{ exclude_rustc_target = exclude_rustc_target or DEFAULT_RUSTC_TARGET } |
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.
issue: The stop
function shouldn't set a rustc target by default, otherwise it will always try to filter, even when we don't need it to.
{ exclude_rustc_target = exclude_rustc_target or DEFAULT_RUSTC_TARGET } | |
{ exclude_rustc_target = exclude_rustc_target } |
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.
yeah make sense. thanks
lua/rustaceanvim/lsp/init.lua
Outdated
---@param target? string The target architecture. Defaults to nil(the current buffer's target if not provided). | ||
M.set_target_arch = function(bufnr, target) | ||
---@param exclude_rustc_target? string Cargo target triple (e.g., 'x86_64-unknown-linux-gnu') to filter rust-analyzer clients | ||
M.set_target_arch = function(bufnr, exclude_rustc_target) |
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.
issue: Here (just not in stop
/restart
), the parameter should be called target
, as it's the target we want to set, not a target we want to exclude.
#543