refactor kiro/codex startup

This commit is contained in:
sgraves committed 2026-10-13 15:22:19 +00:00
1 parent b154bdbbab
commit 3879bf8751
2 files changed
+33 -39

No files matched your search

+4 -32
View File
@@ -268,18 +268,7 @@ function M.codex()
km.map(
km.leader "rc",
function()
vim.ui.input(
{prompt = "Codex prompt: "},
function(prompt)
local command = "codex chat --tui --resume"
if prompt and prompt ~= "" then
command = command .. " " .. vim.fn.shellescape(prompt)
end
vim.cmd("botright vertical split")
vim.cmd("terminal " .. command)
end
)
utils.single_instance_term("codex", "codex")
end,
opts
)
@@ -519,9 +508,7 @@ function M.git_blame(bufnr)
km.leader2 "tb",
function()
NV_DARCULA_ENABLE_GIT_LINE_BLAME = not NV_DARCULA_ENABLE_GIT_LINE_BLAME
require("darcula.git.blame").toggle(
NV_DARCULA_ENABLE_GIT_LINE_BLAME
)
require("darcula.git.blame").toggle(NV_DARCULA_ENABLE_GIT_LINE_BLAME)
utils.notify_setting_enabled(
"Git line blame",
NV_DARCULA_ENABLE_GIT_LINE_BLAME
@@ -530,11 +517,7 @@ function M.git_blame(bufnr)
opts
)
km.nmap(
km.leader "bl",
require("darcula.git.blame").blame_line,
opts
)
km.nmap(km.leader "bl", require("darcula.git.blame").blame_line, opts)
end
function M.gui()
@@ -586,18 +569,7 @@ function M.kiro()
km.map(
km.leader "rk",
function()
vim.ui.input(
{prompt = "Kiro prompt: "},
function(prompt)
local command = "kiro-cli chat --tui --resume --v3"
if prompt and prompt ~= "" then
command = command .. " " .. vim.fn.shellescape(prompt)
end
vim.cmd("botright vertical split")
vim.cmd("terminal " .. command)
end
)
utils.single_instance_term("kiro", "kiro-cli chat --tui --resume --v3")
end,
opts
)
+29 -7
View File
@@ -17,6 +17,8 @@
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--
local single_inst_terms = {}
local cword = function()
---@diagnostic disable-next-line: missing-parameter
return vim.fn.expand("<cword>")
@@ -158,12 +160,11 @@ end
local detect_termguicolors = function()
local term = (vim.env.TERM or ""):lower()
if term == "ansi" or
term == "cons25" or
term == "dumb" or
term == "linux" or
term:match("^vt%d+$") or
term:find("16color", 1, true) then
if
term == "ansi" or term == "cons25" or term == "dumb" or term == "linux" or
term:match("^vt%d+$") or
term:find("16color", 1, true)
then
return false
end
@@ -242,6 +243,26 @@ local notify_setting_enabled = function(text, enabled)
)
end
local function single_instance_term(name, command)
local buf = single_inst_terms[name]
if buf and vim.api.nvim_buf_is_valid(buf) then
local win = vim.fn.bufwinid(buf)
if win ~= -1 then
vim.api.nvim_set_current_win(win)
else
vim.cmd("botright vertical split")
vim.api.nvim_set_current_buf(buf)
end
vim.cmd("startinsert")
return
end
vim.cmd("botright vertical split")
vim.cmd("terminal " .. command)
single_inst_terms[name] = vim.api.nvim_get_current_buf()
vim.cmd("startinsert")
end
return {
augroup_with_autocmd = augroup_with_autocmd,
augroup_with_autocmd_buffer = augroup_with_autocmd_buffer,
@@ -260,5 +281,6 @@ return {
is_c_family_file = is_c_family_file,
notify_setting_enabled = notify_setting_enabled,
parse_env = parse_env,
parse_env_list = parse_env_list
parse_env_list = parse_env_list,
single_instance_term = single_instance_term
}