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

perf: optimize target_arch switching #548

Merged
merged 9 commits into from
Oct 28, 2024

Conversation

borngraced
Copy link
Contributor

Copy link
Contributor

Review Checklist

Does this PR follow the Contribution Guidelines? Following is a partial checklist:

Proper conventional commit scoping:

  • For example, fix(lsp): some lsp-related bugfix

  • Pull request title has the appropriate conventional commit prefix.

If applicable:

  • Tested
    • Tests have been added.
    • Tested manually (Steps to reproduce in PR description).
  • Updated documentation.

lua/rustaceanvim/lsp/init.lua Outdated Show resolved Hide resolved
lua/rustaceanvim/lsp/init.lua Outdated Show resolved Hide resolved
lua/rustaceanvim/rust_analyzer.lua Outdated Show resolved Hide resolved
lua/rustaceanvim/rust_analyzer.lua Outdated Show resolved Hide resolved
lua/rustaceanvim/rust_analyzer.lua Outdated Show resolved Hide resolved
lua/rustaceanvim/rust_analyzer.lua Outdated Show resolved Hide resolved
lua/rustaceanvim/rust_analyzer.lua Outdated Show resolved Hide resolved
@borngraced
Copy link
Contributor Author

improved target switching and reduced nested callbacks @mrcjkb

@mrcjkb mrcjkb enabled auto-merge (squash) October 20, 2024 00:13
lua/rustaceanvim/lsp/init.lua Outdated Show resolved Hide resolved
auto-merge was automatically disabled October 27, 2024 03:56

Head branch was pushed to by a user without write access

lua/rustaceanvim/lsp/init.lua Outdated Show resolved Hide resolved
lua/rustaceanvim/lsp/init.lua Show resolved Hide resolved
lua/rustaceanvim/rust_analyzer.lua Show resolved Hide resolved
lua/rustaceanvim/rust_analyzer.lua Outdated Show resolved Hide resolved
@mrcjkb mrcjkb changed the title enhancement: optimize target_arch switching perf: optimize target_arch switching Oct 27, 2024
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
Copy link
Owner

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.

Copy link
Contributor Author

@borngraced borngraced Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! done

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 }
Copy link
Owner

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.

Suggested change
{ exclude_rustc_target = exclude_rustc_target or DEFAULT_RUSTC_TARGET }
{ exclude_rustc_target = exclude_rustc_target }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah make sense. thanks

---@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)
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants