refactor: textwidth=0, simplify G.map/delmap, drop redundant opt, reduce lualine refresh
This commit is contained in:
parent
bc435e499e
commit
2ffc088aa2
16
lua/G.lua
16
lua/G.lua
|
|
@ -15,25 +15,13 @@ G.cgp = vim.nvim_create_augroup
|
||||||
|
|
||||||
function G.map(maps)
|
function G.map(maps)
|
||||||
for _, map in pairs(maps) do
|
for _, map in pairs(maps) do
|
||||||
if #map == 3 then
|
vim.keymap.set(map[1], map[2], map[3], map[4] or { noremap = true })
|
||||||
vim.keymap.set(map[1], map[2], map[3], { noremap = true })
|
|
||||||
elseif #map == 4 then
|
|
||||||
vim.keymap.set(map[1], map[2], map[3], map[4])
|
|
||||||
else
|
|
||||||
print("太多变量了")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function G.delmap(maps)
|
function G.delmap(maps)
|
||||||
for _, map in pairs(maps) do
|
for _, map in pairs(maps) do
|
||||||
if #map == 2 then
|
vim.keymap.del(map[1], map[2], map[3] or {})
|
||||||
vim.keymap.del(map[1], map[2], {})
|
|
||||||
elseif #map == 3 then
|
|
||||||
vim.keymap.del(map[1], map[2], map[3])
|
|
||||||
else
|
|
||||||
print("太多变量了")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,39 @@
|
||||||
local opt = { noremap = true }
|
|
||||||
|
|
||||||
-- base
|
-- base
|
||||||
G.map({
|
G.map({
|
||||||
{ 'n', '<leader>nh', ':nohlsearch<CR>', opt },
|
{ 'n', '<leader>nh', ':nohlsearch<CR>' },
|
||||||
{ 'n', '<leader>rp', ':%s/', opt },
|
{ 'n', '<leader>rp', ':%s/' },
|
||||||
|
|
||||||
{ 'v', 'L', '$', opt },
|
{ 'v', 'L', '$' },
|
||||||
{ 'v', 'H', '^', opt },
|
{ 'v', 'H', '^' },
|
||||||
{ 'n', 'L', '$', opt },
|
{ 'n', 'L', '$' },
|
||||||
{ 'n', 'H', '^', opt },
|
{ 'n', 'H', '^' },
|
||||||
{ 'v', '>', '>gv', opt },
|
{ 'v', '>', '>gv' },
|
||||||
{ 'v', '<', '<gv', opt },
|
{ 'v', '<', '<gv' },
|
||||||
|
|
||||||
{ 'n', '>', '>>', opt },
|
{ 'n', '>', '>>' },
|
||||||
{ 'n', '<', '<<', opt },
|
{ 'n', '<', '<<' },
|
||||||
{ 'n', '?', ':set hlsearch<CR>?', opt },
|
{ 'n', '?', ':set hlsearch<CR>?' },
|
||||||
{ 'n', '/', ':set hlsearch<CR>/', opt },
|
{ 'n', '/', ':set hlsearch<CR>/' },
|
||||||
|
|
||||||
{ 'n', '<A-l>', ':tabn<CR>', opt },
|
{ 'n', '<A-l>', ':tabn<CR>' },
|
||||||
{ 'n', '<A-h>', ':tabp<CR>', opt },
|
{ 'n', '<A-h>', ':tabp<CR>' },
|
||||||
|
|
||||||
{ 'n', '<c-j>', '<c-w>j', opt },
|
{ 'n', '<c-j>', '<c-w>j' },
|
||||||
{ 'n', '<c-h>', '<c-w>h', opt },
|
{ 'n', '<c-h>', '<c-w>h' },
|
||||||
{ 'n', '<c-k>', '<c-w>k', opt },
|
{ 'n', '<c-k>', '<c-w>k' },
|
||||||
{ 'n', '<c-l>', '<c-w>l', opt },
|
{ 'n', '<c-l>', '<c-w>l' },
|
||||||
|
|
||||||
{ 'n', '<c-c>', ':q<CR>', opt },
|
{ 'n', '<c-c>', ':q<CR>' },
|
||||||
{ 'n', '<c-S>', ':w !sudo tee %<CR>', opt },
|
{ 'n', '<c-S>', ':w !sudo tee %<CR>' },
|
||||||
{ 'n', '<c-q>', ':q!<CR>', opt },
|
{ 'n', '<c-q>', ':q!<CR>' },
|
||||||
{ 'v', '<cs-y>', '"+y', opt },
|
{ 'v', '<cs-y>', '"+y' },
|
||||||
|
|
||||||
{ 'n', '<leader>y', 'ggyG', opt },
|
{ 'n', '<leader>y', 'ggyG' },
|
||||||
{ 'n', '<leader>p', 'ggpG', opt },
|
{ 'n', '<leader>p', 'ggpG' },
|
||||||
{ 'n', '<leader>v', 'ggVG', opt },
|
{ 'n', '<leader>v', 'ggVG' },
|
||||||
|
|
||||||
{ 'n', '<up>', ':res -5<CR>', opt },
|
|
||||||
{ 'n', '<down>', ':res +5<CR>', opt },
|
|
||||||
{ 'n', '<left>', ':vertical resize -5<CR>', opt },
|
|
||||||
{ 'n', '<right>', ':vertical resize +5<CR>', opt },
|
|
||||||
|
|
||||||
|
{ 'n', '<up>', ':res -5<CR>' },
|
||||||
|
{ 'n', '<down>', ':res +5<CR>' },
|
||||||
|
{ 'n', '<left>', ':vertical resize -5<CR>' },
|
||||||
|
{ 'n', '<right>', ':vertical resize +5<CR>' },
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ G.opt.ignorecase = true
|
||||||
G.opt.incsearch = true
|
G.opt.incsearch = true
|
||||||
|
|
||||||
-- 不换行
|
-- 不换行
|
||||||
G.opt.textwidth = 999
|
G.opt.textwidth = 0
|
||||||
G.opt.wrap = false
|
G.opt.wrap = false
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ return {
|
||||||
always_divide_middle = true,
|
always_divide_middle = true,
|
||||||
globalstatus = false,
|
globalstatus = false,
|
||||||
refresh = {
|
refresh = {
|
||||||
statusline = 1000,
|
statusline = 2000,
|
||||||
tabline = 1000,
|
tabline = 2000,
|
||||||
winbar = 1000,
|
winbar = 2000,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue