|
|
|
@ -9,17 +9,17 @@ local wk = require("which-key")
|
|
|
|
|
-- basic operation for write and quit
|
|
|
|
|
-- 文件写入退出基本操作
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<Leader>s", ":w!<CR>", desc = "Save File" },
|
|
|
|
|
{ "<Leader>q", ":qa<CR>", desc = "Quit All" },
|
|
|
|
|
{ "<Leader>S", ":wa<CR>", desc = "Save All" },
|
|
|
|
|
{ "<Leader>s", ":w!<CR>", desc = "Save File" },
|
|
|
|
|
{ "<Leader>q", ":qa<CR>", desc = "Quit All" },
|
|
|
|
|
{ "<Leader>S", ":wa<CR>", desc = "Save All" },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- iron related
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<leader>i", group = "Iron" },
|
|
|
|
|
{ "<leader>il", "<Cmd>lua require('iron.core').send_line()<CR>", desc = "Send line" },
|
|
|
|
|
{ "<leader>if", "<Cmd>lua require('iron.core').send_file()<CR>", desc = "Send file" },
|
|
|
|
|
{ "<leader>ic", "<Cmd>lua require('iron.core').send_until_cursor()<CR>", desc = "Send to cursor" },
|
|
|
|
|
{ "<leader>i", group = "Iron" },
|
|
|
|
|
{ "<leader>il", "<Cmd>lua require('iron.core').send_line()<CR>", desc = "Send line" },
|
|
|
|
|
{ "<leader>if", "<Cmd>lua require('iron.core').send_file()<CR>", desc = "Send file" },
|
|
|
|
|
{ "<leader>ic", "<Cmd>lua require('iron.core').send_until_cursor()<CR>", desc = "Send to cursor" },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- lsp 回调快捷键设置
|
|
|
|
@ -43,28 +43,28 @@ map("n", ",", ":Jaq<CR>", opt)
|
|
|
|
|
|
|
|
|
|
-- markdown related
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<Leader>m", ":MarkdownPreview<CR>", desc = "Markdown preview" },
|
|
|
|
|
{ "<Leader>m", ":RenderMarkdown toggle<CR>", desc = "Markdown preview" },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- git related
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<Leader>g", ":LazyGit<CR>", desc = "Open lazygit" },
|
|
|
|
|
{ "<Leader>g", ":LazyGit<CR>", desc = "Open lazygit" },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- file related
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<Leader><Tab>", "<C-^>", desc = "Last file" },
|
|
|
|
|
{ "<Leader><Tab>", "<C-^>", desc = "Last file" },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<Leader>f", group = "File" },
|
|
|
|
|
{ "<Leader>fp", ":Telescope projects<CR>", desc = "Open project" },
|
|
|
|
|
{ "<Leader>fr", ":Telescope oldfiles<CR>", desc = "Recent files" },
|
|
|
|
|
{ "<Leader>fb", ":Telescope file_browser<CR>", desc = "File browser" },
|
|
|
|
|
{ "<Leader>fn", ":AdvancedNewFile<CR>", desc = "New file" },
|
|
|
|
|
{ "<Leader>fs", ":Telescope live_grep<CR>", desc = "Search in project" },
|
|
|
|
|
{ "<Leader>ff", ":Telescope find_files<CR>", desc = "Search file" },
|
|
|
|
|
{ "<Leader>fc", ":source $MYVIMRC<CR>", desc = "Reload config file" },
|
|
|
|
|
{ "<Leader>f", group = "File" },
|
|
|
|
|
{ "<Leader>fp", ":Telescope projects<CR>", desc = "Open project" },
|
|
|
|
|
{ "<Leader>fr", ":Telescope oldfiles<CR>", desc = "Recent files" },
|
|
|
|
|
{ "<Leader>fb", ":Telescope file_browser<CR>", desc = "File browser" },
|
|
|
|
|
{ "<Leader>fn", ":AdvancedNewFile<CR>", desc = "New file" },
|
|
|
|
|
{ "<Leader>fs", ":Telescope live_grep<CR>", desc = "Search in project" },
|
|
|
|
|
{ "<Leader>ff", ":Telescope find_files<CR>", desc = "Search file" },
|
|
|
|
|
{ "<Leader>fc", ":source $MYVIMRC<CR>", desc = "Reload config file" },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- jk map to esc
|
|
|
|
@ -73,15 +73,15 @@ map("i", "jk", "<Esc>", opt)
|
|
|
|
|
|
|
|
|
|
-- window operate by which-key
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<Leader>w", group = "Window" },
|
|
|
|
|
{ "<Leader>wh", "<C-w>h", desc = "To left" },
|
|
|
|
|
{ "<Leader>wj", "<C-w>j", desc = "To up" },
|
|
|
|
|
{ "<Leader>wk", "<C-w>k", desc = "To down" },
|
|
|
|
|
{ "<Leader>wl", "<C-w>l", desc = "To right" },
|
|
|
|
|
{ "<Leader>ws", ":sp<CR>", desc = "Split window" },
|
|
|
|
|
{ "<Leader>wv", ":vsplit<CR>", desc = "Vsplit window" },
|
|
|
|
|
{ "<Leader>wd", ":close<CR>", desc = "Close window" },
|
|
|
|
|
{ "<Leader>wo", ":only<CR>", desc = "Close others" },
|
|
|
|
|
{ "<Leader>w", group = "Window" },
|
|
|
|
|
{ "<Leader>wh", "<C-w>h", desc = "To left" },
|
|
|
|
|
{ "<Leader>wj", "<C-w>j", desc = "To up" },
|
|
|
|
|
{ "<Leader>wk", "<C-w>k", desc = "To down" },
|
|
|
|
|
{ "<Leader>wl", "<C-w>l", desc = "To right" },
|
|
|
|
|
{ "<Leader>ws", ":sp<CR>", desc = "Split window" },
|
|
|
|
|
{ "<Leader>wv", ":vsplit<CR>", desc = "Vsplit window" },
|
|
|
|
|
{ "<Leader>wd", ":close<CR>", desc = "Close window" },
|
|
|
|
|
{ "<Leader>wo", ":only<CR>", desc = "Close others" },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- base operation for visual mode
|
|
|
|
@ -92,7 +92,6 @@ map("v", ">", ">gv", opt)
|
|
|
|
|
-- neoTree
|
|
|
|
|
map("n", "T", ":NeoTreeFocusToggle<CR>", opt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 定义开关quickfix窗口的函数
|
|
|
|
|
|
|
|
|
|
local function toggle_quickfix()
|
|
|
|
@ -114,31 +113,36 @@ end
|
|
|
|
|
|
|
|
|
|
-- Bufferline and buffer related
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<Leader>b", group = "Buffer" },
|
|
|
|
|
{ "<Leader>bk", ":bd!<CR>", desc = "Kill buffer" },
|
|
|
|
|
{ "<Leader>bo", ":BufferLineCloseRight<CR>:BufferLineCloseLeft<CR>", desc = "Close other buffer" },
|
|
|
|
|
{ "<Leader>bb", ":Telescope buffers<CR>", desc = "Open buffers" },
|
|
|
|
|
{ "<Leader>bn", ":ls<CR>", desc = "Buffer numbers" },
|
|
|
|
|
{ "<Leader>bc", ":noh<CR>", desc = "Cancel highlight" },
|
|
|
|
|
{ "<Leader>bC", ":call setqflist([], 'r')<CR>", desc = "Clear quickfix" },
|
|
|
|
|
{ "<Leader>bq", function() toggle_quickfix() end, desc = "Toggle quickfix" },
|
|
|
|
|
{ "<Leader>bs", ":Telescope current_buffer_fuzzy_find<CR>", desc = "Searching in buffer" },
|
|
|
|
|
{ "<Leader>b", group = "Buffer" },
|
|
|
|
|
{ "<Leader>bk", ":bd!<CR>", desc = "Kill buffer" },
|
|
|
|
|
{ "<Leader>bo", ":BufferLineCloseRight<CR>:BufferLineCloseLeft<CR>", desc = "Close other buffer" },
|
|
|
|
|
{ "<Leader>bb", ":Telescope buffers<CR>", desc = "Open buffers" },
|
|
|
|
|
{ "<Leader>bn", ":ls<CR>", desc = "Buffer numbers" },
|
|
|
|
|
{ "<Leader>bc", ":noh<CR>", desc = "Cancel highlight" },
|
|
|
|
|
{ "<Leader>bC", ":call setqflist([], 'r')<CR>", desc = "Clear quickfix" },
|
|
|
|
|
{
|
|
|
|
|
"<Leader>bq",
|
|
|
|
|
function()
|
|
|
|
|
toggle_quickfix()
|
|
|
|
|
end,
|
|
|
|
|
desc = "Toggle quickfix",
|
|
|
|
|
},
|
|
|
|
|
{ "<Leader>bs", ":Telescope current_buffer_fuzzy_find<CR>", desc = "Searching in buffer" },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<Leader>j", ":HopLineStart<CR>", desc = "Quick jump line" },
|
|
|
|
|
{ "<Leader>j", ":HopLineStart<CR>", desc = "Quick jump line" },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<Leader>c", group = "ChatGPT" },
|
|
|
|
|
{ "<Leader>cb", ":%GpAppend<CR>", desc = "gpt response by buffer" },
|
|
|
|
|
{ "<Leader>c", group = "GPT" },
|
|
|
|
|
{ "<Leader>ct", ":CodeCompanionChat Toggle<CR>", desc = "Code companion chat" },
|
|
|
|
|
{
|
|
|
|
|
mode = { "n", "v" }, -- NORMAL and VISUAL mode
|
|
|
|
|
{ "<leader>ca", "<cmd>CodeCompanionActions<cr>", desc = "Code companion actions" },
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- use gp to interact with chatgpt to write code
|
|
|
|
|
map("v", "<C-g>r", ":<C-u>'<,'>GpRewrite<cr>", opt)
|
|
|
|
|
map("v", "<C-g>a", ":<C-u>'<,'>GpAppend<cr>", opt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 快速切换主题
|
|
|
|
|
-- wk.register({
|
|
|
|
|
-- ["<Leader>c"] = { ":Telescope colorscheme<CR>", "Quick change colortheme" },
|
|
|
|
@ -158,24 +162,28 @@ map("i", "<C-l>", "<C-o>:BufferLineCycleNext<CR>", opt)
|
|
|
|
|
|
|
|
|
|
-- Mason
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<Leader>l", group = "Lsp" },
|
|
|
|
|
{ "<Leader>li", ":LspInstall<CR>", desc = "Install lsp" },
|
|
|
|
|
{ "<Leader>lI", ":MasonInstall ", desc = "Install any" },
|
|
|
|
|
{ "<Leader>lr", ":LspRestart<CR>", desc = "Lsp restart" },
|
|
|
|
|
{ "<Leader>lm", ":Mason<CR>", desc = "Mason info" },
|
|
|
|
|
{ "<Leader>lu", ":MasonUninstall<CR>", desc = "Uninstall lsp" },
|
|
|
|
|
{ "<Leader>lU", ":MasonUninstallAll<CR>", desc = "Unistall all" },
|
|
|
|
|
{ "<Leader>ll", ":LspInfo<CR>", desc = "Lsp infos" },
|
|
|
|
|
{ "<Leader>lR", vim.lsp.buf.rename, desc = "Buffer var rename" },
|
|
|
|
|
{ "<Leader>l", group = "Lsp" },
|
|
|
|
|
{ "<Leader>li", ":LspInstall<CR>", desc = "Install lsp" },
|
|
|
|
|
{ "<Leader>lI", ":MasonInstall ", desc = "Install any" },
|
|
|
|
|
{ "<Leader>lr", ":LspRestart<CR>", desc = "Lsp restart" },
|
|
|
|
|
{ "<Leader>lm", ":Mason<CR>", desc = "Mason info" },
|
|
|
|
|
{ "<Leader>lu", ":MasonUninstall<CR>", desc = "Uninstall lsp" },
|
|
|
|
|
{ "<Leader>lU", ":MasonUninstallAll<CR>", desc = "Unistall all" },
|
|
|
|
|
{ "<Leader>ll", ":LspInfo<CR>", desc = "Lsp infos" },
|
|
|
|
|
{ "<Leader>lR", vim.lsp.buf.rename, desc = "Buffer var rename" },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- dap keymaps
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<Leader>d", group = "Debug" },
|
|
|
|
|
{ "<Leader>dr", ":lua require('dap').continue()<CR>", desc = "Start debug" },
|
|
|
|
|
{ "<Leader>db", ":lua require('dap').toggle_breakpoint()<CR>", desc = "Set breakpoint" },
|
|
|
|
|
{ "<Leader>dc", ":lua require('dap').clear_breakpoints()<CR>", desc = "Clear breakpoint" },
|
|
|
|
|
{ "<Leader>de", ":lua require'dap'.close()<CR>:lua require'dap'.terminate()<CR>:lua require'dap.repl'.close()<CR>:lua require'dapui'.close()<CR>:DapVirtualTextDisable<CR><C-w>o<CR>", desc = "Stop debug" },
|
|
|
|
|
{ "<Leader>d", group = "Debug" },
|
|
|
|
|
{ "<Leader>dr", ":lua require('dap').continue()<CR>", desc = "Start debug" },
|
|
|
|
|
{ "<Leader>db", ":lua require('dap').toggle_breakpoint()<CR>", desc = "Set breakpoint" },
|
|
|
|
|
{ "<Leader>dc", ":lua require('dap').clear_breakpoints()<CR>", desc = "Clear breakpoint" },
|
|
|
|
|
{
|
|
|
|
|
"<Leader>de",
|
|
|
|
|
":lua require'dap'.close()<CR>:lua require'dap'.terminate()<CR>:lua require'dap.repl'.close()<CR>:lua require'dapui'.close()<CR>:DapVirtualTextDisable<CR><C-w>o<CR>",
|
|
|
|
|
desc = "Stop debug",
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- cmpeletion keys
|
|
|
|
@ -214,29 +222,29 @@ function SetKeybinds()
|
|
|
|
|
local opts = { prefix = "<localleader>", buffer = 0 }
|
|
|
|
|
|
|
|
|
|
if fileTy == "markdown" then
|
|
|
|
|
wk.register({
|
|
|
|
|
["t"] = { ":InsertNToc<CR>", "Insert table of content" },
|
|
|
|
|
["d"] = { ":HeaderDecrease<CR>", "All header decrease" },
|
|
|
|
|
["i"] = { ":HeaderIncrease<CR>", "All header increase" },
|
|
|
|
|
}, opts)
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<localleader>t", ":InsertNToc<CR>", desc = "Insert table of content", buffer = 0 },
|
|
|
|
|
{ "<localleader>d", ":HeaderDecrease<CR>", desc = "All header decrease", buffer = 0 },
|
|
|
|
|
{ "<localleader>i", ":HeaderIncrease<CR>", desc = "All header increase", buffer = 0 },
|
|
|
|
|
})
|
|
|
|
|
elseif fileTy == "python" then
|
|
|
|
|
wk.register({
|
|
|
|
|
["r"] = { ":MagmaEvaluateOperator<CR>", "Jupyter evaluate" },
|
|
|
|
|
["c"] = { ":MagmaEvaluateCell<CR>", "Jupyter evaluate cell" },
|
|
|
|
|
}, opts)
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<localleader>r", ":MagmaEvaluateOperator<CR>", desc = "Jupyter evaluate", buffer = 0 },
|
|
|
|
|
{ "<localleader>c", ":MagmaEvaluateCell<CR>", desc = "Jupyter evaluate cell", buffer = 0 },
|
|
|
|
|
})
|
|
|
|
|
elseif fileTy == "dart" then
|
|
|
|
|
wk.register({
|
|
|
|
|
["r"] = { ":FlutterRun<CR>", "FlutterRun" },
|
|
|
|
|
["q"] = { ":FlutterQuit<CR>", "FlutterQuit" },
|
|
|
|
|
["c"] = { ":FlutterCopyProfilerUrl<CR>", "FlutterCopyProfilerUrl" },
|
|
|
|
|
["w"] = { ":FlutterDevTools<CR>", "FlutterDevTools" },
|
|
|
|
|
}, opts)
|
|
|
|
|
|
|
|
|
|
wk.add({
|
|
|
|
|
{ "<localleader>r", ":FlutterRun<CR>", desc = "FlutterRun", buffer = 0 },
|
|
|
|
|
{ "<localleader>q", ":FlutterQuit<CR>", desc = "FlutterQuit", buffer = 0 },
|
|
|
|
|
{ "<localleader>c", ":FlutterCopyProfilerUrl<CR>", desc = "FlutterCopyProfilerUrl", buffer = 0 },
|
|
|
|
|
{ "<localleader>w", ":FlutterDevTools<CR>", desc = "FlutterDevTools", buffer = 0 },
|
|
|
|
|
})
|
|
|
|
|
-- elseif fileTy == "sh" then
|
|
|
|
|
-- wk.register({
|
|
|
|
|
-- ["W"] = { ":w<CR>", "test write" },
|
|
|
|
|
-- ["Q"] = { ":q<CR>", "test quit" },
|
|
|
|
|
-- }, opts)
|
|
|
|
|
-- wk.add({
|
|
|
|
|
-- { "<localleader>W", ":w<CR>", desc = "test write", buffer = 0 },
|
|
|
|
|
-- { "<localleader>Q", ":q<CR>", desc = "test quit", buffer = 0 },
|
|
|
|
|
-- })
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return pluginKeys
|
|
|
|
|