47 lines
1.8 KiB
Lua
47 lines
1.8 KiB
Lua
local ok, overseer = pcall(require, "overseer")
|
|
if not ok then return end
|
|
|
|
-- Register a directory-local, Python-only build task
|
|
overseer.register_template({
|
|
name = "Project: Build",
|
|
condition = {
|
|
dir = vim.fn.getcwd(), -- limit to this folder (Overseer exrc recipe)
|
|
filetype = {"python"} -- built-in filetype filter
|
|
},
|
|
builder = function()
|
|
return {
|
|
-- CHANGE ME: your build command (any tool is fine)
|
|
-- e.g. { "uv", "run", "ruff", "check" } or { "make" } or { "pytest", "-q" }
|
|
cmd = {"make"},
|
|
cwd = vim.fn.getcwd(),
|
|
-- Headless/silent (no terminal window)
|
|
strategy = {"jobstart", use_terminal = false},
|
|
components = {
|
|
-- Ensure a single instance; replace if one exists
|
|
{"unique", replace = true}, -- prevents duplicates
|
|
-- Kill old run and restart on every save
|
|
{"restart_on_save", delay = 150}, -- “newest save wins”
|
|
-- Send matches to quickfix; only open on real failures
|
|
{
|
|
"on_output_quickfix",
|
|
open_on_exit = "failure",
|
|
items_only = true
|
|
},
|
|
-- Set SUCCESS/FAILURE based on exit code & standard niceties
|
|
"on_exit_set_status", "default"
|
|
}
|
|
}
|
|
end
|
|
})
|
|
|
|
-- Start once on first save; restart_on_save handles subsequent saves
|
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
|
group = vim.api.nvim_create_augroup("ProjectOverseerAutostart",
|
|
{clear = true}),
|
|
callback = function()
|
|
if #overseer.list_tasks({name = "Project: Build"}) == 0 then
|
|
overseer.run_template({name = "Project: Build"})
|
|
end
|
|
end
|
|
})
|