Skip to content

fix: regression in root directory detection #725

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

Merged
merged 1 commit into from
Apr 6, 2025
Merged
Changes from all 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
10 changes: 7 additions & 3 deletions lua/rustaceanvim/cargo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ local function get_cargo_metadata(path, callback)
local ok, cargo_metadata_json = pcall(vim.fn.json_decode, sc.stdout)
if ok and cargo_metadata_json then
return callback and callback(cargo_crate_dir, cargo_metadata_json) or cargo_crate_dir, cargo_metadata_json
else
vim.notify(
"rustaceanvim: Could not decode 'cargo metadata' output:\n" .. (cargo_metadata_json or 'unown error'),
vim.log.levels.WARN
)
end
return callback and callback(cargo_crate_dir) or cargo_crate_dir
end
Expand All @@ -38,7 +43,7 @@ local function get_cargo_metadata(path, callback)
vim.uv.fs_stat(path, function(_, stat)
vim.system(cmd, {
cwd = stat and path or cargo_crate_dir or vim.fn.getcwd(),
}, on_exit)
}, vim.schedule_wrap(on_exit))
end)
else
local sc = vim
Expand Down Expand Up @@ -112,7 +117,7 @@ end
function cargo.get_config_root_dir(config, file_name, callback)
local reuse_active = get_mb_active_client_root(file_name)
if reuse_active then
return reuse_active
return callback and callback(reuse_active) or reuse_active
end
if type(config.root_dir) == 'function' then
local root_dir = config.root_dir(file_name, default_get_root_dir)
Expand All @@ -122,7 +127,6 @@ function cargo.get_config_root_dir(config, file_name, callback)
---@cast root_dir string
return callback and callback(root_dir) or root_dir
else
callback = callback and vim.schedule_wrap(callback)
return default_get_root_dir(file_name, callback)
end
end
Expand Down