mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 09:49:48 +01:00
use separate dag for toggleterm
This commit is contained in:
parent
24b631f343
commit
f8ff3cd9fa
1 changed files with 45 additions and 38 deletions
|
@ -8,45 +8,52 @@ with builtins; let
|
||||||
cfg = config.vim.terminal.toggleterm;
|
cfg = config.vim.terminal.toggleterm;
|
||||||
toggleKey = "<c-t>";
|
toggleKey = "<c-t>";
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkMerge [
|
||||||
vim.startPlugins = [
|
(mkIf cfg.enable {
|
||||||
"toggleterm-nvim"
|
vim.startPlugins = [
|
||||||
];
|
"toggleterm-nvim"
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere (''
|
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
|
||||||
require("toggleterm").setup({
|
require("toggleterm").setup({
|
||||||
open_mapping = [[${toggleKey}]],
|
open_mapping = [[${toggleKey}]],
|
||||||
direction = '${toString cfg.direction}',
|
direction = '${toString cfg.direction}',
|
||||||
-- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it
|
-- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it
|
||||||
size = function(term)
|
size = function(term)
|
||||||
if term.direction == "horizontal" then
|
if term.direction == "horizontal" then
|
||||||
return 15
|
return 15
|
||||||
elseif term.direction == "vertical" then
|
elseif term.direction == "vertical" then
|
||||||
return vim.o.columns * 0.4
|
return vim.o.columns * 0.4
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
winbar = {
|
||||||
|
enabled = '${toString cfg.enable_winbar}',
|
||||||
|
name_formatter = function(term) -- term: Terminal
|
||||||
|
return term.name
|
||||||
|
end
|
||||||
|
},
|
||||||
|
})
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
)
|
||||||
|
(
|
||||||
|
mkIf (cfg.enable && cfg.lazygit.enable)
|
||||||
|
{
|
||||||
|
vim.luaConfigRC.toggleterm-lazygit = mkIf cfg.lazygit.enable nvim.dag.entryAfter ["toggleterm"] ''
|
||||||
|
local terminal = require 'toggleterm.terminal'
|
||||||
|
local lazygit = terminal.Terminal:new({
|
||||||
|
cmd = "lazygit",
|
||||||
|
direction = '${cfg.lazygit.direction}',
|
||||||
|
hidden = true,
|
||||||
|
on_open = function(term)
|
||||||
|
vim.cmd("startinsert!")
|
||||||
|
vim.keymap.set( 't', [[${toggleKey}]], function() term:toggle() end, {silent = true, noremap = true, buffer = term.bufnr})
|
||||||
end
|
end
|
||||||
end,
|
})
|
||||||
winbar = {
|
|
||||||
enabled = '${toString cfg.enable_winbar}',
|
|
||||||
name_formatter = function(term) -- term: Terminal
|
|
||||||
return term.name
|
|
||||||
end
|
|
||||||
},
|
|
||||||
})
|
|
||||||
''
|
|
||||||
+ optionalString cfg.lazygit.enable ''
|
|
||||||
|
|
||||||
local terminal = require 'toggleterm.terminal'
|
vim.keymap.set( 'n', [[<leader>gg]], function() lazygit:toggle() end, {silent = true, noremap = true})
|
||||||
local lazygit = terminal.Terminal:new({
|
'';
|
||||||
cmd = "lazygit",
|
}
|
||||||
direction = '${cfg.lazygit.direction}',
|
)
|
||||||
hidden = true,
|
];
|
||||||
on_open = function(term)
|
|
||||||
vim.cmd("startinsert!")
|
|
||||||
vim.keymap.set( 't', [[${toggleKey}]], function() term:toggle() end, {silent = true, noremap = true, buffer = term.bufnr})
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.keymap.set( 'n', [[<leader>gg]], function() lazygit:toggle() end, {silent = true, noremap = true})
|
|
||||||
'');
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue