customize terminal

This commit is contained in:
2025-09-17 15:37:43 +08:00
parent 73b15af55d
commit 3ada39c7e0
4 changed files with 50 additions and 43 deletions

View File

@@ -1,18 +1,18 @@
{
"AstroNvim": { "branch": "main", "commit": "f9bce33cab08bd3c327f8a1619eba63c9b7262ae" },
"AstroNvim": { "branch": "main", "commit": "8379e70578bb2f4b2227d55ccc1ae4fd2ab8bb51" },
"LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" },
"aerial.nvim": { "branch": "master", "commit": "6ab1a0ce4874d21610fc5a67a6c82c7b943c635b" },
"astrocommunity": { "branch": "main", "commit": "4e6feff7aa400cf5742c72d03cc238163ed20be6" },
"astrocommunity": { "branch": "main", "commit": "5c9c55c0f2e5a944d265a0784859dce1bbf12b62" },
"astrocore": { "branch": "main", "commit": "c797dd5a592e2bd154f2503e231b8a4083659534" },
"astrolsp": { "branch": "main", "commit": "414775e4b49a46bd7105cc5498ea7bb312359bf2" },
"astrotheme": { "branch": "main", "commit": "0a3fb361f1e3d6a0cbb42e93f3d01fb5203b6752" },
"astrotheme": { "branch": "main", "commit": "4a2af93815e4e6adfe69c836e46047a9451de858" },
"astroui": { "branch": "main", "commit": "4943abbd42674b43249313afe83b91065a40e4be" },
"better-escape.nvim": { "branch": "master", "commit": "199dcc2643dec5d8dbdab4ec672cf405224dcb3b" },
"blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" },
"blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" },
"catppuccin": { "branch": "main", "commit": "30fa4d122d9b22ad8b2e0ab1b533c8c26c4dde86" },
"ccc.nvim": { "branch": "main", "commit": "9d1a256e006decc574789dfc7d628ca11644d4c2" },
"cmp-dap": { "branch": "master", "commit": "ea92773e84c0ad3288c3bc5e452ac91559669087" },
"copilot.vim": { "branch": "release", "commit": "c2c435419e081a87e909e8979c66d874e75e4155" },
"copilot.vim": { "branch": "release", "commit": "dfe0a3a1c256167d181488a73ec6ccab8d8931a9" },
"crates.nvim": { "branch": "main", "commit": "ac9fa498a9edb96dc3056724ff69d5f40b898453" },
"flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" },
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
@@ -38,7 +38,7 @@
"nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" },
"nvim-dap": { "branch": "master", "commit": "7891b01beedc37cef4eaf2e92563bd0a5b6e9c58" },
"nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" },
"nvim-dap-python": { "branch": "master", "commit": "030385d03363988370adaa5cf21fa465daddb088" },
"nvim-dap-python": { "branch": "master", "commit": "bfe572e4458e0ac876b9539a1e9f301c72db8ea0" },
"nvim-dap-ruby": { "branch": "main", "commit": "ba36f9905ca9c6d89e5af5467a52fceeb2bbbf6d" },
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" },
"nvim-highlight-colors": { "branch": "main", "commit": "1ce0a09bfc28c7274e649d20927cea51e440b65c" },
@@ -54,13 +54,13 @@
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"resession.nvim": { "branch": "master", "commit": "cc819b0489938d03e4f3532a583354f0287c015b" },
"rustaceanvim": { "branch": "master", "commit": "12504405821c05874d2d1f6b5ec919f9808e2c99" },
"schemastore.nvim": { "branch": "main", "commit": "05924b7383fa17f13f7a7e7ecc8ce83b3c340ce2" },
"schemastore.nvim": { "branch": "main", "commit": "0fccf9234acfd981867cbd42c4101829e6808790" },
"smart-splits.nvim": { "branch": "master", "commit": "ddb23c1a1cf1507bda487cda7f6e4690965ef9f5" },
"snacks.nvim": { "branch": "main", "commit": "5eac729fa290248acfe10916d92a5ed5e5c0f9ed" },
"snacks.nvim": { "branch": "main", "commit": "da230e3ca8146da4b73752daaf0a1d07d343c12d" },
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
"toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" },
"toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" },
"tsc.nvim": { "branch": "main", "commit": "8c1b4ec6a48d038a79ced8674cb15e7db6dd8ef0" },
"venv-selector.nvim": { "branch": "main", "commit": "b82a820194405f04344532a17fce8cc724627ffe" },
"venv-selector.nvim": { "branch": "main", "commit": "d6d03d9975630d3232201f227efd3682975742d9" },
"vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" },
"which-key.nvim": { "branch": "main", "commit": "fcbf4eea17cb299c02557d576f0d568878e354a4" }
}

View File

@@ -56,23 +56,8 @@ return {
-- setting a mapping to false will disable it
-- ["<C-S>"] = false,
["<M-h>"] = { "<Cmd>ToggleTerm size=20<CR>", desc = "Toggle terminal" },
[",tt"] = {
function()
local size = vim.o.lines * 0.4
require("toggleterm").toggle(nil, size)
end,
desc = "Toggle terminal",
},
[",tn"] = { "<Cmd>ToggleTerm direction=tab<CR>", desc = "Toggle terminal" },
},
t = {
["<M-h>"] = { "<Cmd>ToggleTerm<CR>", desc = "Toggle terminal" },
[",tt"] = { "<Cmd>ToggleTerm<CR>", desc = "Toggle terminal" },
["<C-Up>"] = { "<Cmd>resize +2<CR>", desc = "Resize terminal up" },
["<C-Down>"] = { "<Cmd>resize -2<CR>", desc = "Resize terminal down" },
-- Navigate tabs
["]t"] = { function() vim.cmd.tabnext() end, desc = "Next tab" },
["[t"] = { function() vim.cmd.tabprevious() end, desc = "Previous tab" },

View File

@@ -1,18 +0,0 @@
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,
}

40
lua/plugins/terminal.lua Normal file
View File

@@ -0,0 +1,40 @@
-- if true then return {} end
---@type LazySpec
return {
"akinsho/toggleterm.nvim",
cmd = { "ToggleTerm", "TermExec", "TermNew" },
version = false,
branch = "main",
keys = {
{ "<leader>tH", "<Cmd>TermNew size=20 direction=horizontal<CR>", desc = "New horizonal terminal" },
{ "<M-h>", "<Cmd>ToggleTerm size=20<CR>", desc = "Toggle terminal", mode = { "n", "t" } },
{
",tt",
function()
local size = vim.o.lines * 0.4
require("toggleterm").toggle(nil, size)
end,
mode = { "n", "t" },
desc = "Toggle terminal horizontal",
},
{ ",tn", "<Cmd>ToggleTerm direction=tab<CR>", desc = "Toggle terminal in tab" },
{ ",tN", "<Cmd>TermNew direction=tab<CR>", desc = "New terminal in tab" },
{ "<C-Up>", "<Cmd>resize +2<CR>", desc = "Resize terminal up", mode = "t" },
{ "<C-Down>", "<Cmd>resize -2<CR>", desc = "Resize terminal down", mode = "t" },
},
config = function(plugin, opts)
-- override size
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,
}