feat: <c-t> adaptive split same as Reasonix, works in both n/i modes
This commit is contained in:
parent
3c5fa11ef1
commit
3253a2b20f
|
|
@ -36,15 +36,22 @@ G.map({
|
||||||
{ 'n', '<down>', ':res +5<CR>' },
|
{ 'n', '<down>', ':res +5<CR>' },
|
||||||
{ 'n', '<left>', ':vertical resize -5<CR>' },
|
{ 'n', '<left>', ':vertical resize -5<CR>' },
|
||||||
{ 'n', '<right>', ':vertical resize +5<CR>' },
|
{ 'n', '<right>', ':vertical resize +5<CR>' },
|
||||||
|
})
|
||||||
|
|
||||||
-- Reasonix AI agent:根据窗口宽高自适应方向(宽→上下分屏,高→左右分屏)
|
-- 终端 / Reasonix:根据窗口宽高自适应分屏方向(横屏→下方,竖屏→右侧)
|
||||||
{ 'n', '<C-i>', function()
|
do
|
||||||
local ui = vim.api.nvim_list_uis()[1]
|
local function split_term(ui, cmd)
|
||||||
local wide = ui.width > ui.height
|
local wide = ui.width > ui.height
|
||||||
local term = require('toggleterm.terminal').Terminal:new({
|
local term = require('toggleterm.terminal').Terminal:new({
|
||||||
direction = wide and 'horizontal' or 'vertical',
|
direction = wide and 'horizontal' or 'vertical',
|
||||||
cmd = 'reasonix',
|
cmd = cmd,
|
||||||
})
|
})
|
||||||
term:toggle()
|
term:toggle()
|
||||||
end, { noremap = true } },
|
end
|
||||||
})
|
|
||||||
|
G.map({
|
||||||
|
{ 'n', '<c-t>', function() split_term(vim.api.nvim_list_uis()[1]) end, { noremap = true } },
|
||||||
|
{ 'i', '<c-t>', function() split_term(vim.api.nvim_list_uis()[1]) end, { noremap = true } },
|
||||||
|
{ 'n', '<C-i>', function() split_term(vim.api.nvim_list_uis()[1], 'reasonix') end, { noremap = true } },
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -32,22 +32,19 @@ return {
|
||||||
dependencies = { "nvim-lua/plenary.nvim" },
|
dependencies = { "nvim-lua/plenary.nvim" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
-- 终端
|
-- 终端(方向由 keymap.lua <c-t> 自适应控制)
|
||||||
'akinsho/toggleterm.nvim',
|
'akinsho/toggleterm.nvim',
|
||||||
version = "*",
|
version = "*",
|
||||||
config = function()
|
config = function()
|
||||||
require("toggleterm").setup {
|
require("toggleterm").setup {
|
||||||
-- size can be a number or function which is passed the current terminal
|
|
||||||
size = 10,
|
size = 10,
|
||||||
open_mapping = [[<c-t>]],
|
hide_numbers = true,
|
||||||
hide_numbers = true, -- hide the number column in toggleterm buffers
|
|
||||||
shade_filetypes = {},
|
shade_filetypes = {},
|
||||||
shade_terminals = true,
|
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,
|
start_in_insert = true,
|
||||||
insert_mappings = true, -- whether or not the open mapping applies in insert mode
|
|
||||||
persist_size = true,
|
persist_size = true,
|
||||||
direction = 'horizontal',
|
-- direction 不写死,由 keymap 创建时动态决定
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue