Skip to content

Commit

Permalink
feat(overseer): some useful ts templates
Browse files Browse the repository at this point in the history
  • Loading branch information
willruggiano committed Feb 28, 2024
1 parent 3b9dd32 commit d7ab45d
Showing 1 changed file with 47 additions and 9 deletions.
56 changes: 47 additions & 9 deletions plugins/overseer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ return function()
component_aliases = {
default = {
{ "display_duration", detail_level = 2 },
-- "on_output_summarize",
"on_exit_set_status",
"on_complete_notify",
},
Expand All @@ -18,12 +17,50 @@ return function()
}

o.register_template {
name = "Run File (ts-node)",
name = "build project",
builder = function()
local project = vim.fs.find("tsconfig.json", {
path = vim.fs.dirname(vim.api.nvim_buf_get_name(0)),
stop = vim.loop.cwd(),
type = "file",
upward = true,
})[1]

return {
cmd = { "tsc" },
args = { "-p", project },
components = {
"default",
{ "on_output_parse", problem_matcher = "$tsc" },
{ "on_result_diagnostics_quickfix", open = true },
},
strategy = {
"toggleterm",
open_on_start = false,
},
}
end,
condition = {
filetype = { "typescript" },
callback = function()
return #vim.fs.find("tsconfig.json", {
path = vim.fs.dirname(vim.api.nvim_buf_get_name(0)),
stop = vim.loop.cwd(),
type = "file",
upward = true,
}) > 0
end,
},
tags = { o.TAG.BUILD },
}

o.register_template {
name = "bun run",
builder = function()
local file = vim.fn.expand "%"
return {
cmd = { "ts-node" },
args = { "-T", file },
cmd = { "bun" },
args = { file },
strategy = {
"toggleterm",
open_on_start = true,
Expand All @@ -37,16 +74,16 @@ return function()
condition = {
filetype = { "typescript" },
},
tags = { o.TAG.RUN },
}

o.register_template {
name = "Run File (jest)",
name = "bun test",
builder = function()
local file = vim.fn.expand "%"
return {
cwd = vim.fn.expand "%:p:h",
cmd = { "jest" },
args = { file },
cmd = { "bun" },
args = { "test", file },
strategy = {
"toggleterm",
open_on_start = true,
Expand All @@ -60,10 +97,11 @@ return function()
condition = {
filetype = { "typescript" },
callback = function()
local file = vim.fn.expand "%" --[[@as string]]
local file = vim.fn.expand "%"
return vim.endswith(file, ".test.ts")
end,
},
tags = { o.TAG.TEST },
}

local nnoremaps = require("bombadil.lib.keymap").nnoremaps
Expand Down

0 comments on commit d7ab45d

Please sign in to comment.