Skip to content

Commit b44e5de

Browse files
committed
chore: slim overseer
1 parent be55ce0 commit b44e5de

File tree

1 file changed

+10
-135
lines changed

1 file changed

+10
-135
lines changed

plugins/overseer.lua

Lines changed: 10 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,16 @@
11
return function()
2-
local o = require "overseer"
2+
local overseer = require "overseer"
33

4-
---@diagnostic disable-next-line: missing-fields
5-
o.setup {
6-
component_aliases = {
7-
default = {
8-
{ "display_duration", detail_level = 2 },
9-
"on_exit_set_status",
10-
{ "on_complete_notify", system = "unfocused" },
11-
},
12-
default_vscode = {
13-
"default",
14-
{ "on_result_diagnostics_quickfix", open = true },
15-
},
16-
},
17-
}
4+
overseer.setup()
185

19-
o.register_template {
20-
name = "build project",
21-
builder = function()
22-
local project = vim.fs.find("tsconfig.json", {
23-
path = vim.fs.dirname(vim.api.nvim_buf_get_name(0)),
24-
stop = vim.loop.cwd(),
25-
type = "file",
26-
upward = true,
27-
})[1]
6+
vim.keymap.set("n", "<space><cr>", function()
7+
local tasks = overseer.list_tasks { recent_first = true }
8+
if not vim.tbl_isempty(tasks) then
9+
overseer.run_action(tasks[1], "restart")
10+
end
11+
end, { desc = "[overseer] run last" })
2812

29-
return {
30-
cmd = { "tsc" },
31-
args = { "-p", project },
32-
components = {
33-
"on_exit_set_status",
34-
{ "on_output_parse", problem_matcher = "$tsc" },
35-
{ "on_result_diagnostics_quickfix", open = true },
36-
},
37-
strategy = {
38-
"toggleterm",
39-
open_on_start = false,
40-
},
41-
}
42-
end,
43-
condition = {
44-
filetype = { "typescript" },
45-
callback = function()
46-
return #vim.fs.find("tsconfig.json", {
47-
path = vim.fs.dirname(vim.api.nvim_buf_get_name(0)),
48-
stop = vim.loop.cwd(),
49-
type = "file",
50-
upward = true,
51-
}) > 0
52-
end,
53-
},
54-
tags = { o.TAG.BUILD },
55-
}
13+
vim.keymap.set("n", "<space>r", "<cmd>OverseerRun<cr>", { desc = "[overseer] run" })
5614

57-
local function register_bun_template(name, args, opts)
58-
o.register_template(vim.tbl_deep_extend("force", {
59-
name = name,
60-
builder = function()
61-
local file = vim.fn.expand "%"
62-
return {
63-
cmd = { "bun" },
64-
args = { unpack(args), file },
65-
components = {
66-
{ "display_duration", detail_level = 2 },
67-
"on_exit_set_status",
68-
},
69-
strategy = {
70-
"toggleterm",
71-
open_on_start = true,
72-
direction = "horizontal",
73-
on_create = function()
74-
vim.cmd.stopinsert()
75-
end,
76-
},
77-
}
78-
end,
79-
condition = {
80-
filetype = { "typescript" },
81-
},
82-
tags = { o.TAG.RUN },
83-
}, opts or {}))
84-
end
85-
86-
register_bun_template("bun run", {})
87-
register_bun_template("bun test", { "test" }, {
88-
condition = {
89-
callback = function()
90-
local file = vim.fn.expand "%"
91-
return vim.endswith(file, ".test.ts")
92-
end,
93-
},
94-
priority = 10,
95-
tags = { o.TAG.TEST },
96-
})
97-
register_bun_template("bun test --update-snapshots", { "test", "--update-snapshots" }, {
98-
condition = {
99-
callback = function()
100-
local file = vim.fn.expand "%"
101-
return vim.endswith(file, ".test.ts")
102-
end,
103-
},
104-
priority = 11,
105-
tags = { o.TAG.TEST },
106-
})
107-
register_bun_template("bun test --only", { "test", "--only" }, {
108-
condition = {
109-
callback = function()
110-
local file = vim.fn.expand "%"
111-
return vim.endswith(file, ".test.ts")
112-
end,
113-
},
114-
priority = 12,
115-
tags = { o.TAG.TEST },
116-
})
117-
118-
local nnoremaps = require("bombadil.lib.keymap").nnoremaps
119-
120-
nnoremaps {
121-
["<space><cr>"] = {
122-
function()
123-
local tasks = o.list_tasks { recent_first = true }
124-
if vim.tbl_isempty(tasks) then
125-
vim.notify("No tasks found", vim.log.levels.WARN)
126-
else
127-
o.run_action(tasks[1], "restart")
128-
end
129-
end,
130-
{ desc = "RunLast" },
131-
},
132-
["<space>r"] = {
133-
"<cmd>OverseerRun<cr>",
134-
{ desc = "Run" },
135-
},
136-
["<space>t"] = {
137-
"<cmd>OverseerToggle bottom<cr>",
138-
{ desc = "Tasks" },
139-
},
140-
}
15+
vim.keymap.set("n", "<space>t", "<cmd>OverseerToggle bottom<cr>", { desc = "[overseer] toggle" })
14116
end

0 commit comments

Comments
 (0)