Shatur / neovim-tasks

A statefull task manager focused on integration with build systems.
GNU General Public License v3.0
108 stars 10 forks source link

"auto" task not working when cargo not installed #17

Closed undyamon closed 1 year ago

undyamon commented 1 year ago

There seems to be an issue with the cargo.lua module.

Basically, loading the module requires cargo being installed:

This is a problem when using auto as the target module, since this will try to load every module to call the appropriate condition(), even when cargo is not installed.

Personally, I would check this in get_cargo_subcommands as

local cmd = 'cargo'
local ok, is_exe = pcall(vim.fn.executable, cmd)
if ok and 1 ~= is_exe then
  utils.notify('Unable to find "cargo" executable', vim.log.levels.WARN)
  return {}
end

local job = Job:new({
  command = cmd,
  args = { '--list' },
  enabled_recording = true,
})
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

Hope this helps!

Shatur commented 1 year ago

Makes sense to me. Could you open a PR?