diff --git a/lua/keymap.lua b/lua/keymap.lua index aa0d4ba..3c2ed23 100644 --- a/lua/keymap.lua +++ b/lua/keymap.lua @@ -36,15 +36,22 @@ G.map({ { 'n', '', ':res +5' }, { 'n', '', ':vertical resize -5' }, { 'n', '', ':vertical resize +5' }, +}) - -- Reasonix AI agent:根据窗口宽高自适应方向(宽→上下分屏,高→左右分屏) - { 'n', '', function() - local ui = vim.api.nvim_list_uis()[1] +-- 终端 / Reasonix:根据窗口宽高自适应分屏方向(横屏→下方,竖屏→右侧) +do + local function split_term(ui, cmd) local wide = ui.width > ui.height local term = require('toggleterm.terminal').Terminal:new({ direction = wide and 'horizontal' or 'vertical', - cmd = 'reasonix', + cmd = cmd, }) term:toggle() - end, { noremap = true } }, -}) + end + + G.map({ + { 'n', '', function() split_term(vim.api.nvim_list_uis()[1]) end, { noremap = true } }, + { 'i', '', function() split_term(vim.api.nvim_list_uis()[1]) end, { noremap = true } }, + { 'n', '', function() split_term(vim.api.nvim_list_uis()[1], 'reasonix') end, { noremap = true } }, + }) +end diff --git a/lua/plugs/dev.lua b/lua/plugs/dev.lua index 1ee3e5b..b906bcc 100644 --- a/lua/plugs/dev.lua +++ b/lua/plugs/dev.lua @@ -32,22 +32,19 @@ return { dependencies = { "nvim-lua/plenary.nvim" }, }, { - -- 终端 + -- 终端(方向由 keymap.lua 自适应控制) 'akinsho/toggleterm.nvim', version = "*", config = function() require("toggleterm").setup { - -- size can be a number or function which is passed the current terminal size = 10, - open_mapping = [[]], - hide_numbers = true, -- hide the number column in toggleterm buffers + hide_numbers = true, shade_filetypes = {}, shade_terminals = true, - shading_factor = 1, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light + shading_factor = 1, start_in_insert = true, - insert_mappings = true, -- whether or not the open mapping applies in insert mode persist_size = true, - direction = 'horizontal', + -- direction 不写死,由 keymap 创建时动态决定 } end }