From d7ab45d92335d331cd915efdbb33fafea3104d3b Mon Sep 17 00:00:00 2001 From: Will Ruggiano Date: Wed, 28 Feb 2024 14:37:21 -0700 Subject: [PATCH] feat(overseer): some useful ts templates --- plugins/overseer.lua | 56 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/plugins/overseer.lua b/plugins/overseer.lua index 8538c26..c52a6e8 100644 --- a/plugins/overseer.lua +++ b/plugins/overseer.lua @@ -6,7 +6,6 @@ return function() component_aliases = { default = { { "display_duration", detail_level = 2 }, - -- "on_output_summarize", "on_exit_set_status", "on_complete_notify", }, @@ -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, @@ -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, @@ -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