add keybindings
This commit is contained in:
parent
d13b36024b
commit
1291acb250
@ -3,33 +3,38 @@ local pluginKeys = {}
|
|||||||
-- 设定映射函数
|
-- 设定映射函数
|
||||||
-- set map function
|
-- set map function
|
||||||
local map = vim.api.nvim_set_keymap
|
local map = vim.api.nvim_set_keymap
|
||||||
local opt = {noremap = true, silent = true }
|
local opt = { noremap = true, silent = true }
|
||||||
local wk = require("which-key")
|
local wk = require("which-key")
|
||||||
|
|
||||||
-- basic operation for write and quit
|
-- basic operation for write and quit
|
||||||
-- 文件写入退出基本操作
|
-- 文件写入退出基本操作
|
||||||
wk.register({
|
wk.register({
|
||||||
["<Leader>s"] = {":w<CR>", "Save File"},
|
["<Leader>s"] = { ":w<CR>", "Save File" },
|
||||||
["<Leader>q"] = {":qa<CR>", "Quit All"},
|
["<Leader>q"] = { ":qa<CR>", "Quit All" },
|
||||||
["<Leader>S"] = {":wa<CR>", "Save All"},
|
["<Leader>S"] = { ":wa<CR>", "Save All" },
|
||||||
})
|
})
|
||||||
|
|
||||||
-- code related
|
-- code related
|
||||||
-- 代码相关
|
-- 代码相关
|
||||||
map("n", ",", ":RunCode<CR>", opt)
|
map("n", ",", ":RunCode<CR>", opt)
|
||||||
|
|
||||||
|
-- git related
|
||||||
|
-- git 相关
|
||||||
|
wk.register({
|
||||||
|
["<Leader>g"] = { ":LazyGit<CR>", "Open lazygit" },
|
||||||
|
})
|
||||||
-- file related
|
-- file related
|
||||||
-- 文件相关操作
|
-- 文件相关操作
|
||||||
wk.register({
|
wk.register({
|
||||||
["<Leader><Tab>"] = {"<C-^>", "Last file"},
|
["<Leader><Tab>"] = { "<C-^>", "Last file" },
|
||||||
})
|
})
|
||||||
|
|
||||||
wk.register({
|
wk.register({
|
||||||
["<Leader>f"] = {
|
["<Leader>f"] = {
|
||||||
name = "+File",
|
name = "+File",
|
||||||
p = {":Telescope projects<CR>", "Open project"},
|
p = { ":Telescope projects<CR>", "Open project" },
|
||||||
r = {":Telescope oldfiles<CR>", "Recent files"},
|
r = { ":Telescope oldfiles<CR>", "Recent files" },
|
||||||
n = {":enew<CR>", "New file"},
|
n = { ":enew<CR>", "New file" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -42,14 +47,14 @@ map("i", "jk", "<Esc>", opt)
|
|||||||
wk.register({
|
wk.register({
|
||||||
["<Leader>w"] = {
|
["<Leader>w"] = {
|
||||||
name = "+Window",
|
name = "+Window",
|
||||||
h = {"<C-w>h", "To left"},
|
h = { "<C-w>h", "To left" },
|
||||||
j = {"<C-w>j", "To up"},
|
j = { "<C-w>j", "To up" },
|
||||||
k = {"<C-w>k", "To down"},
|
k = { "<C-w>k", "To down" },
|
||||||
l = {"<C-w>l", "To right"},
|
l = { "<C-w>l", "To right" },
|
||||||
s = {":sp<CR>", "Split window"},
|
s = { ":sp<CR>", "Split window" },
|
||||||
v = {":vsplit<CR>", "Vsplit window"},
|
v = { ":vsplit<CR>", "Vsplit window" },
|
||||||
d = {":close<CR>", "Close window"},
|
d = { ":close<CR>", "Close window" },
|
||||||
o = {":only<CR>", "Close others"},
|
o = { ":only<CR>", "Close others" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -61,8 +66,8 @@ wk.register({
|
|||||||
|
|
||||||
-- base operation for visual mode
|
-- base operation for visual mode
|
||||||
-- 可视模式下基本操作
|
-- 可视模式下基本操作
|
||||||
map('v', '<', '<gv', opt)
|
map("v", "<", "<gv", opt)
|
||||||
map('v', '>', '>gv', opt)
|
map("v", ">", ">gv", opt)
|
||||||
|
|
||||||
-- nvimTree
|
-- nvimTree
|
||||||
map("n", "n", ":NvimTreeToggle<CR>", opt)
|
map("n", "n", ":NvimTreeToggle<CR>", opt)
|
||||||
@ -71,9 +76,9 @@ map("n", "n", ":NvimTreeToggle<CR>", opt)
|
|||||||
wk.register({
|
wk.register({
|
||||||
["<Leader>p"] = {
|
["<Leader>p"] = {
|
||||||
name = "+Packer",
|
name = "+Packer",
|
||||||
i = {":PackerSync<CR>", "PackerSync"},
|
i = { ":PackerSync<CR>", "PackerSync" },
|
||||||
s = {":PackerStatus<CR>", "PackerStatus"},
|
s = { ":PackerStatus<CR>", "PackerStatus" },
|
||||||
c = {":PackerClean<CR>", "PackerClean"},
|
c = { ":PackerClean<CR>", "PackerClean" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -81,11 +86,11 @@ wk.register({
|
|||||||
wk.register({
|
wk.register({
|
||||||
["<Leader>b"] = {
|
["<Leader>b"] = {
|
||||||
name = "+Buffer",
|
name = "+Buffer",
|
||||||
k = {":bd!<CR>", "Kill buffer"},
|
k = { ":bd!<CR>", "Kill buffer" },
|
||||||
o = {":BufferLineCloseRight<CR>:BufferLineCloseLeft<CR>", "Close other buffer"},
|
o = { ":BufferLineCloseRight<CR>:BufferLineCloseLeft<CR>", "Close other buffer" },
|
||||||
b = {":bp<CR>", "Last buffer"},
|
b = { ":bp<CR>", "Last buffer" },
|
||||||
n = {":ls<CR>", "Buffer numbers"},
|
n = { ":ls<CR>", "Buffer numbers" },
|
||||||
t = {":b ", "To buffer"},
|
t = { ":b ", "To buffer" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
-- change left and right tab
|
-- change left and right tab
|
||||||
@ -97,32 +102,30 @@ map("n", "<C-l>", ":BufferLineCycleNext<CR>", opt)
|
|||||||
wk.register({
|
wk.register({
|
||||||
["<Leader>l"] = {
|
["<Leader>l"] = {
|
||||||
name = "+Lsp",
|
name = "+Lsp",
|
||||||
i = {":LspInstall<CR>", "Install lsp"},
|
i = { ":LspInstall<CR>", "Install lsp" },
|
||||||
I = {":MasonInstall ", "Install any"},
|
I = { ":MasonInstall ", "Install any" },
|
||||||
l = {":Mason<CR>", "Mason info"},
|
l = { ":Mason<CR>", "Mason info" },
|
||||||
u = {":MasonUninstall<CR>", "Uninstall lsp"},
|
u = { ":MasonUninstall<CR>", "Uninstall lsp" },
|
||||||
U = {":MasonUninstallAll<CR>", "Unistall all"},
|
U = { ":MasonUninstallAll<CR>", "Unistall all" },
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- Telescope
|
-- Telescope
|
||||||
map("n", "f", ":Telescope find_files<CR>", opt)
|
map("n", "f", ":Telescope find_files<CR>", opt)
|
||||||
|
|
||||||
|
|
||||||
-- cmpeletion keys
|
-- cmpeletion keys
|
||||||
-- 补全快捷键
|
-- 补全快捷键
|
||||||
pluginKeys.cmp = function(cmp)
|
pluginKeys.cmp = function(cmp)
|
||||||
return {
|
return {
|
||||||
-- next option
|
-- next option
|
||||||
-- 下一个
|
-- 下一个
|
||||||
['<Tab>'] = cmp.mapping.select_next_item(),
|
["<Tab>"] = cmp.mapping.select_next_item(),
|
||||||
['<Up>'] = cmp.mapping.select_prev_item(),
|
["<Up>"] = cmp.mapping.select_prev_item(),
|
||||||
|
|
||||||
['<CR>'] = cmp.mapping.confirm({
|
["<CR>"] = cmp.mapping.confirm({
|
||||||
select = true,
|
select = true,
|
||||||
behavior = cmp.ConfirmBehavior.Replace
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
})
|
}),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -130,20 +133,22 @@ end
|
|||||||
wk.register({
|
wk.register({
|
||||||
["<Leader>d"] = {
|
["<Leader>d"] = {
|
||||||
name = "+Debug",
|
name = "+Debug",
|
||||||
r = {":lua require('dap').continue()<CR>", "Start debug"},
|
r = { ":lua require('dap').continue()<CR>", "Start debug" },
|
||||||
b = {":lua require('dap').toggle_breakpoint()<CR>", "Set breakpoint"},
|
b = { ":lua require('dap').toggle_breakpoint()<CR>", "Set breakpoint" },
|
||||||
c = {":lua require('dap').clear_breakpoints()<CR>", "Clear breakpoint"},
|
c = { ":lua require('dap').clear_breakpoints()<CR>", "Clear breakpoint" },
|
||||||
e = {":lua require'dap'.close()<CR>"
|
e = {
|
||||||
|
":lua require'dap'.close()<CR>"
|
||||||
.. ":lua require'dap'.terminate()<CR>"
|
.. ":lua require'dap'.terminate()<CR>"
|
||||||
.. ":lua require'dap.repl'.close()<CR>"
|
.. ":lua require'dap.repl'.close()<CR>"
|
||||||
.. ":lua require'dapui'.close()<CR>"
|
.. ":lua require'dapui'.close()<CR>"
|
||||||
.. ":lua require('dap').clear_breakpoints()<CR>"
|
.. ":lua require('dap').clear_breakpoints()<CR>"
|
||||||
.. "<C-w>o<CR>", "Stop debug"},
|
.. "<C-w>o<CR>",
|
||||||
}
|
"Stop debug",
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
map("i", "<C-d>", ":lua require'dap'.continue()<CR>", opt)
|
map("i", "<C-d>", ":lua require'dap'.continue()<CR>", opt)
|
||||||
map("n", "<C-n>", ":lua require'dap'.step_into()<CR>", opt)
|
map("n", "<C-n>", ":lua require'dap'.step_into()<CR>", opt)
|
||||||
map("n", "<C-o>", ":lua require'dap'.step_over()<CR>", opt)
|
map("n", "<C-o>", ":lua require'dap'.step_over()<CR>", opt)
|
||||||
|
|
||||||
|
|
||||||
return pluginKeys
|
return pluginKeys
|
||||||
|
Loading…
Reference in New Issue
Block a user