60 lines
1.8 KiB
Lua
60 lines
1.8 KiB
Lua
-- base
|
||
G.map({
|
||
{ 'n', '<leader>nh', ':nohlsearch<CR>' },
|
||
{ 'n', '<leader>rp', ':%s/' },
|
||
|
||
{ 'v', 'L', '$' },
|
||
{ 'v', 'H', '^' },
|
||
{ 'n', 'L', '$' },
|
||
{ 'n', 'H', '^' },
|
||
{ 'v', '>', '>gv' },
|
||
{ 'v', '<', '<gv' },
|
||
|
||
{ 'n', '>', '>>' },
|
||
{ 'n', '<', '<<' },
|
||
{ 'n', '?', ':set hlsearch<CR>?' },
|
||
{ 'n', '/', ':set hlsearch<CR>/' },
|
||
|
||
{ 'n', '<A-l>', ':tabn<CR>' },
|
||
{ 'n', '<A-h>', ':tabp<CR>' },
|
||
|
||
{ 'n', '<c-j>', '<c-w>j' },
|
||
{ 'n', '<c-h>', '<c-w>h' },
|
||
{ 'n', '<c-k>', '<c-w>k' },
|
||
{ 'n', '<c-l>', '<c-w>l' },
|
||
|
||
{ 'n', '<c-c>', ':q<CR>' },
|
||
{ 'n', '<c-S>', ':w !sudo tee %<CR>' },
|
||
{ 'n', '<c-q>', ':q!<CR>' },
|
||
{ 'v', '<cs-y>', '"+y' },
|
||
|
||
{ 'n', '<leader>y', 'ggyG' },
|
||
{ 'n', '<leader>p', 'ggpG' },
|
||
{ 'n', '<leader>v', 'ggVG' },
|
||
|
||
{ 'n', '<up>', ':res -5<CR>' },
|
||
{ 'n', '<down>', ':res +5<CR>' },
|
||
{ 'n', '<left>', ':vertical resize -5<CR>' },
|
||
{ 'n', '<right>', ':vertical resize +5<CR>' },
|
||
})
|
||
|
||
-- 终端 / Reasonix:横屏→右侧,竖屏→下方
|
||
do
|
||
local function split_term(ui, cmd)
|
||
local tall = ui.height > ui.width
|
||
local term = require('toggleterm.terminal').Terminal:new({
|
||
-- 横屏→右侧(垂直分屏);竖屏→下方(水平分屏)
|
||
direction = tall and 'horizontal' or 'vertical',
|
||
cmd = cmd,
|
||
size = tall and 10 or 40,
|
||
})
|
||
term:toggle()
|
||
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
|