vim.g.mapleader = " " vim.g.maplocalleader = " " local map = vim.keymap local noreopt = { noremap = true, silent = true } -- save map.set({ "n", "i" }, "", "w", noreopt) -- format map.set({ "n", "v", "x" }, "=", "lua vim.lsp.buf.format()", noreopt) -- fine cmdline map.set("n", ":", "FineCmdline", noreopt) -- telescope map.set("n", "ff", "Telescope find_files") -- find files within current working directory, respects .gitignore map.set("n", "fs", "Telescope live_grep") -- find string in current working directory as you type map.set("n", "fc", "Telescope grep_string") -- find string under cursor in current working directory map.set("n", "fb", "Telescope buffers") -- list open buffers in current neovim instance map.set("n", "fh", "Telescope help_tags") -- list available help tags map.set("n", "lds", "Telescope lsp_document_symbols") -- list all functions/structs/classes/modules in the current buffer -- 重置窗口大小 map.set("n", "", ":resize -2", noreopt) map.set("n", "", ":resize +2", noreopt) map.set("n", "", ":vertical resize -2", noreopt) map.set("n", "", ":vertical resize +2", noreopt) -- 窗口切换 map.set("n", "", "h", noreopt) map.set("n", "", "j", noreopt) map.set("n", "", "k", noreopt) map.set("n", "", "l", noreopt) -- 分屏 map.set("n", "sv", ":vsp", noreopt) map.set("n", "sh", ":sp", noreopt) -- 代码块选择和移动 map.set({ "n", "v" }, "L", "$", noreopt) -- 快速行尾 map.set({ "n", "v" }, "H", "^", noreopt) -- 快速行首 map.set({ "n", "v", "i" }, "", "ggG", noreopt) -- 全选 map.set("n", "", ":m .+1==gi", noreopt) map.set("n", "", ":m .-2==gi", noreopt) map.set("v", "<", "", ">gv", noreopt) map.set("v", "", ":m .+1==", noreopt) map.set("v", "", ":m .-2==", noreopt) map.set("x", "J", ":move '>+1gv-gv", noreopt) map.set("x", "K", ":move '<-2gv-gv", noreopt) map.set("x", "", ":move '>+1gv-gv", noreopt) map.set("x", "", ":move '<-2gv-gv", noreopt) -- 快所退出 map.set("n", "q", ":wq", noreopt) map.set("n", "qn", ":q!", noreopt) map.set("n", "qq", ":qa!", noreopt) map.set("i", "jk", "", noreopt) -- 文件页切换 map.set("n", "bl", ":BufferLineCyclePrev", noreopt) map.set("n", "br", ":BufferLineCycleNext", noreopt) map.set("n", "bpi", ":BufferLineTogglePin", noreopt) map.set("n", "bcl", ":BufferLineCloseLeft", noreopt) map.set("n", "bcr", ":BufferLineCloseRight", noreopt) map.set("n", "bp", ":BufferLinePick", noreopt) -- 开关文件树 map.set("n", "t", ":NvimTreeToggle", noreopt) -- git lazy map.set("n", "lg", ":LazyGit", noreopt) -- 错误列表UI map.set("n", "xx", "TroubleToggle", noreopt) map.set("n", "xw", "TroubleToggle workspace_diagnostics", noreopt) map.set("n", "xd", "TroubleToggle document_diagnostics", noreopt) map.set("n", "xl", "TroubleToggle loclist", noreopt) map.set("n", "xq", "TroubleToggle quickfix", noreopt) map.set("n", "gR", "TroubleToggle lsp_references", noreopt) -- 高亮跳转 map.set("n", "n", "n:Beacon", noreopt) map.set("n", "N", "N:Beacon", noreopt) map.set("n", "*", "*:Beacon", noreopt) map.set("n", "#", "#:Beacon", noreopt) -- markdown map.set("n", "mp", ":MarkdownPreviewToggle", noreopt) -- lspsage function _G.set_lspsage_keymaps() local keymap = vim.keymap.set keymap("n", "cf", "Lspsaga lsp_finder") -- Code action keymap({ "n", "v" }, "ca", "Lspsaga code_action") -- Rename all occurrences of the hovered word for the entire file keymap("n", "rn", "Lspsaga rename") -- Rename all occurrences of the hovered word for the selected files keymap("n", "rn", "Lspsaga rename ++project") -- Peek definition -- You can edit the file containing the definition in the floating window -- It also supports open/vsplit/etc operations, do refer to "definition_action_keys" -- It also supports tagstack -- Use to jump back keymap("n", "gd", "Lspsaga peek_definition") -- Peek type definition -- You can edit the file containing the type definition in the floating window -- It also supports open/vsplit/etc operations, do refer to "definition_action_keys" -- It also supports tagstack -- Use to jump back keymap("n", "gt", "Lspsaga peek_type_definition") -- Show line diagnostics -- You can pass argument ++unfocus to -- unfocus the show_line_diagnostics floating window keymap("n", "sl", "Lspsaga show_line_diagnostics") -- Show cursor diagnostics -- Like show_line_diagnostics, it supports passing the ++unfocus argument keymap("n", "sc", "Lspsaga show_cursor_diagnostics") -- Show buffer diagnostics keymap("n", "sb", "Lspsaga show_buf_diagnostics") -- Diagnostic jump -- You can use to jump back to your previous location keymap("n", "[e", "Lspsaga diagnostic_jump_prev") keymap("n", "]e", "Lspsaga diagnostic_jump_next") -- Diagnostic jump with filters such as only jumping to an error keymap("n", "[E", function() require("lspsaga.diagnostic"):goto_prev({ severity = vim.diagnostic.severity.ERROR }) end) keymap("n", "]E", function() require("lspsaga.diagnostic"):goto_next({ severity = vim.diagnostic.severity.ERROR }) end) -- Toggle outline keymap("n", "o", "Lspsaga outline") -- Hover Doc -- If there is no hover doc, -- there will be a notification stating that -- there is no information available. -- To disable it just use ":Lspsaga hover_doc ++quiet" -- Pressing the key twice will enter the hover window keymap("n", "K", "Lspsaga hover_doc") -- If you want to keep the hover window in the top right hand corner, -- you can pass the ++keep argument -- Note that if you use hover with ++keep, pressing this key again will -- close the hover window. If you want to jump to the hover window -- you should use the wincmd command "w" -- keymap("n", "K", "Lspsaga hover_doc ++keep") -- Call hierarchy keymap("n", "ci", "Lspsaga incoming_calls") keymap("n", "co", "Lspsaga outgoing_calls") -- Floating terminal keymap({ "n", "t" }, "", "Lspsaga term_toggle") end vim.cmd("lua set_lspsage_keymaps()")