2024-06-11 07:24:55 +02:00
|
|
|
# homepage: https://github.com/akinsho/toggleterm.nvim
|
|
|
|
|
# nixvim doc: https://nix-community.github.io/nixvim/plugins/toggleterm/index.html
|
|
|
|
|
_:
|
2024-07-01 18:35:34 +02:00
|
|
|
let
|
|
|
|
|
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/toggleterm.lua#L14-L19
|
|
|
|
|
lazygit_exec = ''
|
|
|
|
|
function()
|
|
|
|
|
local worktree = require("astrocore").file_worktree()
|
|
|
|
|
local flags = worktree and (" --work-tree=%s --git-dir=%s"):format(worktree.toplevel, worktree.gitdir)
|
|
|
|
|
or ""
|
2024-06-11 07:24:55 +02:00
|
|
|
|
2024-07-01 18:35:34 +02:00
|
|
|
require("astrocore").toggle_term_cmd(table.concat({"lazygit", flags}))
|
|
|
|
|
end
|
|
|
|
|
'';
|
|
|
|
|
in
|
2024-06-11 07:24:55 +02:00
|
|
|
{
|
|
|
|
|
opts = {
|
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
|
direction = "float";
|
|
|
|
|
float_opts.border = "rounded";
|
|
|
|
|
shading_factor = 2;
|
|
|
|
|
size = 10;
|
|
|
|
|
|
|
|
|
|
highlights = {
|
|
|
|
|
Normal.link = "Normal";
|
|
|
|
|
NormalNC.link = "NormalNC";
|
|
|
|
|
NormalFloat.link = "NormalFloat";
|
|
|
|
|
FloatBorder.link = "FloatBorder";
|
|
|
|
|
StatusLine.link = "StatusLine";
|
|
|
|
|
StatusLineNC.link = "StatusLineNC";
|
|
|
|
|
WinBar.link = "WinBar";
|
|
|
|
|
WinBarNC.link = "WinBarNC";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/toggleterm.lua#L66-L74
|
|
|
|
|
on_create = ''
|
|
|
|
|
function(t)
|
|
|
|
|
vim.opt_local.foldcolumn = "0"
|
|
|
|
|
vim.opt_local.signcolumn = "no"
|
|
|
|
|
if t.hidden then
|
|
|
|
|
vim.keymap.set({ "n", "t", "i" }, "<F7>", function() t:toggle() end, { desc = "Toggle terminal", buffer = t.bufnr })
|
|
|
|
|
end
|
2024-06-14 21:54:05 +02:00
|
|
|
local term_name = rndname()
|
|
|
|
|
vim.cmd(t.id .. "ToggleTermSetName " .. term_name)
|
2024-06-11 07:24:55 +02:00
|
|
|
end
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
rootOpts.keymaps = [
|
|
|
|
|
{
|
|
|
|
|
mode = "n";
|
|
|
|
|
key = "<Leader>tf";
|
|
|
|
|
action = "<Cmd>ToggleTerm direction=float<CR>";
|
|
|
|
|
options.desc = "Open floating terminal";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
mode = "n";
|
|
|
|
|
key = "<Leader>th";
|
|
|
|
|
action = "<Cmd>ToggleTerm size=10 direction=horizontal<CR>";
|
|
|
|
|
options.desc = "Open terminal in horizontal split";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
mode = "n";
|
|
|
|
|
key = "<Leader>tv";
|
|
|
|
|
action = "<Cmd>ToggleTerm size=80 direction=vertical<CR>";
|
|
|
|
|
options.desc = "Open terminal in vertical split";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
mode = "n";
|
|
|
|
|
key = "<F7>";
|
|
|
|
|
action = "<Cmd>execute v:count . 'ToggleTerm'<CR>";
|
|
|
|
|
options.desc = "Toggle terminal";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
mode = "t";
|
|
|
|
|
key = "<F7>";
|
|
|
|
|
action = "<Cmd>ToggleTerm<CR>";
|
|
|
|
|
options.desc = "Toggle terminal";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
mode = "i";
|
|
|
|
|
key = "<F7>";
|
|
|
|
|
action = "<Esc><Cmd>ToggleTerm<CR>";
|
|
|
|
|
options.desc = "Toggle terminal";
|
|
|
|
|
}
|
2024-06-12 08:08:57 +02:00
|
|
|
{
|
|
|
|
|
mode = "t";
|
|
|
|
|
key = "<Esc><Esc>";
|
|
|
|
|
action = "<C-\\><C-n>";
|
|
|
|
|
options.desc = "Switch to normal mode";
|
|
|
|
|
}
|
2024-06-12 12:04:00 +02:00
|
|
|
{
|
2024-09-09 14:30:54 +02:00
|
|
|
mode = [ "n" ];
|
2024-06-12 12:04:00 +02:00
|
|
|
key = "<Leader>tn";
|
|
|
|
|
action.__raw = ''
|
|
|
|
|
function()
|
|
|
|
|
local curterm = require("toggleterm.terminal").get_focused_id()
|
|
|
|
|
|
|
|
|
|
if curterm ~= nil then
|
|
|
|
|
vim.cmd(curterm .. "ToggleTermSetName")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
'';
|
|
|
|
|
options.desc = "Rename current terminal";
|
|
|
|
|
}
|
2024-06-14 21:34:31 +02:00
|
|
|
{
|
2024-09-09 14:30:54 +02:00
|
|
|
mode = [ "n" ];
|
2024-06-14 21:34:31 +02:00
|
|
|
key = "<Leader>tl";
|
|
|
|
|
action = "<cmd>TermSelect<cr>";
|
|
|
|
|
options.desc = "List terminals";
|
|
|
|
|
}
|
2024-07-01 18:35:34 +02:00
|
|
|
{
|
|
|
|
|
mode = "n";
|
|
|
|
|
key = "<Leader>gg";
|
|
|
|
|
action.__raw = lazygit_exec;
|
|
|
|
|
options.desc = "ToggleTerm lazygit";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
mode = "n";
|
|
|
|
|
key = "<Leader>tl";
|
|
|
|
|
action.__raw = lazygit_exec;
|
|
|
|
|
options.desc = "ToggleTerm lazygit";
|
|
|
|
|
}
|
2024-06-11 07:24:55 +02:00
|
|
|
];
|
|
|
|
|
}
|