feature request: De-duplicate tasks.
Did you check existing requests?
- [X] I have searched the existing issues
Describe the feature
When a task is added from some souce (such as resession.nvim, or preLaunchTask) it would be nice if there were an option to check for identical tasks (not just the same name, but same content), and de-duplicate the task.
Provide background
This would solve two problems I am having right now, first of which is that when loading a session more than once, identical tasks are loaded more than once, and second, when tasks are started from a preLuanchTask hook, the tasks will slowly build up to an annoying level.
There are many, many ways that this could be accomplished, and honestly it might already be possible with the current API, but I haven't been able to figure it out.
What is the significance of this feature?
nice to have
Additional details
No response
Check out the unique component. If you add that to your tasks, it will do name-based deduplication
That doesn't really solve either of my use cases. I want the deduplication to consider the entire task config, not just the name, and importantly I want that to apply to all tasks that overseer manages, regardless of their source or components. For example, I can't add that component to tasks created by the preLaunchTask hook afaict.
Your second concern I had too, but you can actually add the "unique" component to the overseer default components by adding this to your overseer config.
component_aliases = {
default = {
-- original default components
{ "display_duration", detail_level = 2 },
"on_output_summarize",
"on_exit_set_status",
"on_complete_notify",
{ "on_complete_dispose", require_view = { "SUCCESS", "FAILURE" } },
-- custom default components
"unique",
},
},
I have a more "manual" "fix":
local function shutdown_overseer(bundle_name)
overseer.save_task_bundle(bundle_name, {overwrite = true})
-- Nuke all the tasks, so the session doesn't get them
for _, task in ipairs(overseer.list_tasks({})) do
task:dispose(true)
end
-- Close any open windows
overseer.close()
-- For some reason, calling the above manually then closing the session works, but doing
-- it here in an autocmd has different behavior and makes a 'no name' buffer on next load
-- So, delete overseer's 'no name' buffer manually before saving
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_loaded(buf) and vim.api.nvim_buf_get_name(buf) == "" then
vim.api.nvim_buf_delete(buf, {})
end
end
end
This runs before my session saves (via https://github.com/folke/persistence.nvim), and fixes my problems.