update
This commit is contained in:
parent
dc612b402c
commit
87f59ae9dd
36
lua/core/G.lua
Normal file
36
lua/core/G.lua
Normal file
@ -0,0 +1,36 @@
|
||||
local G = {}
|
||||
|
||||
G.g = vim.g
|
||||
G.b = vim.b
|
||||
G.o = vim.o
|
||||
G.fn = vim.fn
|
||||
G.api = vim.api
|
||||
|
||||
function G.map(maps)
|
||||
for _,map in pairs(maps) do
|
||||
G.api.nvim_set_keymap(map[1], map[2], map[3], map[4])
|
||||
end
|
||||
end
|
||||
|
||||
function G.hi(hls)
|
||||
for group,color in pairs(hls) do
|
||||
local fg = color.fg and ' ctermfg=' .. color.fg or ' ctermfg=NONE'
|
||||
local bg = color.bg and ' ctermbg=' .. color.bg or ' ctermbg=NONE'
|
||||
local sp = color.sp and ' cterm=' .. color.sp or ''
|
||||
G.api.nvim_command('highlight ' .. group .. fg .. bg .. sp)
|
||||
end
|
||||
end
|
||||
|
||||
function G.cmd(cmd)
|
||||
G.api.nvim_command(cmd)
|
||||
end
|
||||
|
||||
function G.exec(c)
|
||||
G.api.nvim_exec(c)
|
||||
end
|
||||
|
||||
function G.eval(c)
|
||||
return G.api.nvim_eval(c)
|
||||
end
|
||||
|
||||
return G
|
@ -1,63 +1,63 @@
|
||||
local map = vim.api.nvim_set_keymap
|
||||
local G,opt = require("G"), {noremap = true}
|
||||
|
||||
map('n', '<leader>y', '"+y', {noremap = true})
|
||||
map('n', '<leader>p', '"+p', {noremap = true})
|
||||
map('n', '<leader>d', '"+d', {noremap = true})
|
||||
G.map({
|
||||
{'n', '<leader>y', '"+y', opt},
|
||||
{'n', '<leader>p', '"+p', opt},
|
||||
{'n', '<leader>d', '"+d', opt},
|
||||
|
||||
map('v', '<leader>y', '"+y', {noremap = true})
|
||||
map('v', '<leader>p', '"+p', {noremap = true})
|
||||
map('v', '<leader>d', '"+d', {noremap = true})
|
||||
{'v', '<leader>y', '"+y', opt},
|
||||
{'v', '<leader>p', '"+p', opt},
|
||||
{'v', '<leader>d', '"+d', opt},
|
||||
|
||||
map('n', '<leader>nh', ':nohlsearch<CR>', {noremap = true})
|
||||
map('n', '<leader>rp',':%s/',{noremap = true})
|
||||
{'n', '<leader>nh', ':nohlsearch<CR>', opt},
|
||||
{'n', '<leader>rp',':%s/',opt},
|
||||
|
||||
map('n', 'L', '$', {noremap = true})
|
||||
map('n', 'H', '^', {noremap = true})
|
||||
map('n', '>', '>>', {noremap = true})
|
||||
map('n', '<', '<<', {noremap = true})
|
||||
map('n', 'Q', ':q!<CR>', {noremap = true})
|
||||
map('n', '?', ':set hlsearch<CR>?', {noremap = true})
|
||||
map('n', '/', ':set hlsearch<CR>/', {noremap = true})
|
||||
{'v', 'L', '$', opt},
|
||||
{'v', 'H', '^', opt},
|
||||
{'n', 'L', '$', opt},
|
||||
{'n', 'H', '^', opt},
|
||||
|
||||
map('n', '<A-l>', ':tabn<CR>', {noremap = true})
|
||||
map('n', '<A-h>', ':tabp<CR>', {noremap = true})
|
||||
{'n', '>', '>>', opt},
|
||||
{'n', '<', '<<', opt},
|
||||
{'n', 'Q', ':q!<CR>', opt},
|
||||
{'n', '?', ':set hlsearch<CR>?', opt},
|
||||
{'n', '/', ':set hlsearch<CR>/', opt},
|
||||
|
||||
{'n', '<A-l>', ':tabn<CR>', opt},
|
||||
{'n', '<A-h>', ':tabp<CR>', opt},
|
||||
|
||||
|
||||
map('n', '<c-j>', '<c-w>j', {noremap = true})
|
||||
map('n', '<c-h>', '<c-w>h', {noremap = true})
|
||||
map('n', '<c-k>', '<c-w>k', {noremap = true})
|
||||
map('n', '<c-l>', '<c-w>l', {noremap = true})
|
||||
map('n', '<c-c>', ':wq<CR>', {noremap = true})
|
||||
{'n', '<c-j>', '<c-w>j', opt},
|
||||
{'n', '<c-h>', '<c-w>h', opt},
|
||||
{'n', '<c-k>', '<c-w>k', opt},
|
||||
{'n', '<c-l>', '<c-w>l', opt},
|
||||
{'n', '<c-c>', ':wq<CR>', opt},
|
||||
|
||||
|
||||
map('n', '<leader><leader>y', 'ggyG', {noremap = true})
|
||||
map('n', '<leader><leader>p', 'ggpG', {noremap = true})
|
||||
map('n', '<leader><leader>v', 'ggVG', {noremap = true})
|
||||
{'n', '<leader><leader>y', 'ggyG', opt},
|
||||
{'n', '<leader><leader>p', 'ggpG', opt},
|
||||
{'n', '<leader><leader>v', 'ggVG', opt},
|
||||
|
||||
map('n', '<up>', ':res -5<CR>', {noremap = true})
|
||||
map('n', '<down>', ':res +5<CR>', {noremap = true})
|
||||
map('n', '<left>', ':vertical resize -5<CR>', {noremap = true})
|
||||
map('n', '<right>', ':vertical resize +5<CR>', {noremap = true})
|
||||
{'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},
|
||||
|
||||
-- 快速注释
|
||||
map('n', '<leader>/', '<leader>c<spaces>', {noremap = false})
|
||||
|
||||
|
||||
-- easymotion
|
||||
map('v', '<leader>f', '<Plug>(easymotion-bd-f)', {})
|
||||
map('n', '<leader>f', '<Plug>(easymotion-overwin-f)', {})
|
||||
map('n', 's', '<Plug>(easymotion-overwin-f2)',{})
|
||||
|
||||
-- lazygit
|
||||
map('n', '<leader>g', ':w<CR>:LazyGit<CR>', {})
|
||||
|
||||
{'n', '<leader>g', ':w<CR>:LazyGit<CR>', {}},
|
||||
|
||||
--EasyAlign
|
||||
map("v", "ga", ":EasyAlign<CR>", {silent = true})
|
||||
|
||||
|
||||
|
||||
|
||||
{"v", "ga", ":EasyAlign<CR>", {silent = true}},
|
||||
|
||||
})
|
||||
|
||||
G.map({
|
||||
-- easymotion
|
||||
{'v', '<leader>f', '<Plug>(easymotion-bd-f)', {}},
|
||||
{'n', '<leader>f', '<Plug>(easymotion-overwin-f)', {}},
|
||||
{'n', 's', '<Plug>(easymotion-overwin-f2)',{}},
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user