-
Notifications
You must be signed in to change notification settings - Fork 10
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 cargo module load when executable is not present. #19
Conversation
lua/tasks/module/cargo.lua
Outdated
local cargo_subcommands = {} | ||
|
||
local ok, is_exe = pcall(vim.fn.executable, cmd) |
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.
Maybe put Job:new
here to avoid checking if it's an executable twice?
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.
You mean something like this?
local ok, job = pcall(Job.new, Job, {
command = 'cargo',
args = { '--list' },
enabled_recording = true,
})
if not ok then
utils.notify(job, vim.log.levels.WARN)
return {}
end
job:sync()
if job.code ~= 0 or job.signal ~= 0 then
utils.notify('Unable to get list of available cargo subcommands', vim.log.levels.WARN)
return {}
end
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.
Yep!
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.
I pushed so I could test the config in nixos. Hold on a sec.
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.
utils.notify(job, vim.log.levels.WARN)
This line dumps the stack trace as a warning the first time one uses auto
(and it realizes cargo
is not available). It is slightly annoying because it causes the classic Press ENTER or type command to continue
.
Do you have a better idea on how to handle this? Sometimes it could be useful to get the warning so I don't think we should discard it.
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.
I think it's fine if user uses auto
in a repo with Cargo.toml
? But instead of stacktrace I would write something like 'unable to execute "cargo"'.
cf00bbd
to
1a161da
Compare
Closes #17