2025-10-10 15:11:54 -04:00
|
|
|
--- Terminal configurations using toggleterm
|
|
|
|
|
--- This module provides terminal toggle functions for various CLI tools
|
|
|
|
|
--- @module config.terminals
|
|
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
|
|
--- Check if toggleterm is available
|
|
|
|
|
--- @return boolean available Whether toggleterm is loaded
|
|
|
|
|
local function is_toggleterm_available()
|
|
|
|
|
local ok, _ = pcall(require, "toggleterm.terminal")
|
|
|
|
|
return ok
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- Initialize all terminal configurations
|
|
|
|
|
--- Only runs if toggleterm is available
|
|
|
|
|
function M.setup()
|
|
|
|
|
if not is_toggleterm_available() then
|
|
|
|
|
vim.notify("toggleterm not available, skipping terminal setup", vim.log.levels.WARN)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local Terminal = require("toggleterm.terminal").Terminal
|
|
|
|
|
-- Scooter find and replace terminal
|
2025-10-20 13:57:09 -04:00
|
|
|
local smartCommit = Terminal:new {
|
|
|
|
|
cmd = "smartcommit",
|
2025-10-10 15:11:54 -04:00
|
|
|
hidden = true,
|
2025-10-20 13:57:09 -04:00
|
|
|
direction = "vertical",
|
|
|
|
|
close_on_exit = true,
|
2025-10-10 15:11:54 -04:00
|
|
|
on_open = function(term)
|
2025-10-13 09:42:03 -04:00
|
|
|
vim.cmd "startinsert!"
|
2025-10-10 15:11:54 -04:00
|
|
|
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
|
|
|
|
|
end,
|
2025-10-13 09:42:03 -04:00
|
|
|
}
|
2025-10-20 13:57:09 -04:00
|
|
|
|
|
|
|
|
-- Scooter find and replace terminal
|
|
|
|
|
local scooter = Terminal:new {
|
|
|
|
|
cmd = "scooter",
|
|
|
|
|
hidden = true,
|
|
|
|
|
direction = "vertical",
|
|
|
|
|
close_on_exit = true,
|
|
|
|
|
on_open = function(term)
|
|
|
|
|
vim.cmd "startinsert!"
|
|
|
|
|
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-10 15:11:54 -04:00
|
|
|
-- Mk (make) terminal
|
2025-10-13 09:42:03 -04:00
|
|
|
local mk = Terminal:new {
|
2025-10-13 14:17:57 -04:00
|
|
|
cmd = "task",
|
2025-10-10 15:11:54 -04:00
|
|
|
hidden = true,
|
2025-10-16 13:48:36 -04:00
|
|
|
direction = "horizontal",
|
|
|
|
|
on_open = function(term)
|
|
|
|
|
vim.cmd "startinsert!"
|
|
|
|
|
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
|
|
|
|
|
end,
|
|
|
|
|
}
|
2025-10-20 13:57:09 -04:00
|
|
|
|
2025-10-16 13:48:36 -04:00
|
|
|
-- Mk (make) terminal
|
|
|
|
|
local lazygit = Terminal:new {
|
|
|
|
|
cmd = "lazygit",
|
|
|
|
|
hidden = true,
|
|
|
|
|
direction = "float",
|
2025-10-10 15:11:54 -04:00
|
|
|
on_open = function(term)
|
2025-10-13 09:42:03 -04:00
|
|
|
vim.cmd "startinsert!"
|
2025-10-10 15:11:54 -04:00
|
|
|
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
|
|
|
|
|
end,
|
2025-10-13 09:42:03 -04:00
|
|
|
}
|
2025-10-10 15:11:54 -04:00
|
|
|
|
2025-10-27 20:26:41 -04:00
|
|
|
-- Scratch terminal
|
|
|
|
|
local scratch = Terminal:new {
|
|
|
|
|
cmd = "zsh",
|
|
|
|
|
hidden = true,
|
|
|
|
|
direction = "horizontal",
|
|
|
|
|
on_open = function(term)
|
|
|
|
|
vim.cmd "startinsert!"
|
|
|
|
|
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
|
|
|
|
|
end,
|
|
|
|
|
}
|
2025-10-10 15:11:54 -04:00
|
|
|
-- Export toggle functions to module instead of global namespace
|
|
|
|
|
M.scooter_toggle = function() scooter:toggle() end
|
|
|
|
|
M.mk_toggle = function() mk:toggle() end
|
2025-10-16 13:48:36 -04:00
|
|
|
M.lazygit_toggle = function() lazygit:toggle() end
|
2025-10-20 13:57:09 -04:00
|
|
|
M.smartCommit_toggle = function() smartCommit:toggle() end
|
2025-10-27 20:26:41 -04:00
|
|
|
M.scratch_toggle = function() scratch:toggle() end
|
2025-10-10 15:11:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return M
|