From 73b15af55d3d095b49c81535c0a2601799c5aa56 Mon Sep 17 00:00:00 2001 From: James Bacon Date: Tue, 16 Sep 2025 19:25:31 +0800 Subject: [PATCH] add mapping for toggle term --- lua/plugins/astrocore.lua | 19 +++++++++++++++++++ lua/plugins/term.lua | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 lua/plugins/term.lua diff --git a/lua/plugins/astrocore.lua b/lua/plugins/astrocore.lua index 4549501..21c2617 100644 --- a/lua/plugins/astrocore.lua +++ b/lua/plugins/astrocore.lua @@ -56,7 +56,26 @@ return { -- setting a mapping to false will disable it -- [""] = false, + [""] = { "ToggleTerm size=20", desc = "Toggle terminal" }, + [",tt"] = { + function() + local size = vim.o.lines * 0.4 + require("toggleterm").toggle(nil, size) + end, + desc = "Toggle terminal", + }, + [",tn"] = { "ToggleTerm direction=tab", desc = "Toggle terminal" }, + }, + t = { [""] = { "ToggleTerm", desc = "Toggle terminal" }, + [",tt"] = { "ToggleTerm", desc = "Toggle terminal" }, + + [""] = { "resize +2", desc = "Resize terminal up" }, + [""] = { "resize -2", desc = "Resize terminal down" }, + + -- Navigate tabs + ["]t"] = { function() vim.cmd.tabnext() end, desc = "Next tab" }, + ["[t"] = { function() vim.cmd.tabprevious() end, desc = "Previous tab" }, }, }, }, diff --git a/lua/plugins/term.lua b/lua/plugins/term.lua new file mode 100644 index 0000000..5395a25 --- /dev/null +++ b/lua/plugins/term.lua @@ -0,0 +1,18 @@ +if true then return {} end + +---@type LazySpec +return { + "akinsho/toggleterm.nvim", + config = function(plugin, opts) + require("toggleterm").setup { + -- size can be a number or function which is passed the current terminal + size = function(term) + if term.direction == "horizontal" then + return vim.o.lines * 0.4 + elseif term.direction == "vertical" then + return vim.o.columns * 0.4 + end + end, + } --[[@type ToggleTermConfig]] + end, +}