-- keymappings (view all the lunarvim keybinds with Lk or list every mapping with :map) lvim.leader = "space" -- Common shortcuts lvim.keys.normal_mode[""] = ":w" lvim.keys.insert_mode[""] = ":wi" lvim.keys.normal_mode[""] = ":undo" lvim.keys.normal_mode[""] = ":redo" -- Horizontal movements lvim.keys.normal_mode["H"] = "^" lvim.keys.normal_mode["L"] = "$" -- Moving through buffers lvim.keys.normal_mode[""] = ":BufferLineCycleNext" lvim.keys.normal_mode[""] = ":BufferLineCyclePrev" lvim.keys.normal_mode[""] = ":BufferLineMoveNext" lvim.keys.normal_mode[""] = ":BufferLineMovePrev" -- Opening various menus lvim.keys.normal_mode[""] = ":NvimTreeFindFileToggle" lvim.keys.normal_mode[""] = ":Lf" lvim.keys.normal_mode[""] = ":MinimapToggle" lvim.keys.normal_mode[""] = ":SymbolsOutline" -- Delete to void register lvim.keys.visual_mode[""] = '"_d' lvim.keys.normal_mode[""] = '"_d' lvim.keys.visual_mode[""] = '"_dP' lvim.keys.visual_mode["p"] = '"_dP' -- Remove highlight lvim.keys.normal_mode[""] = ":nohlsearch" -- Debugger lvim.keys.normal_mode[""] = ":DapToggleBreakpoint" lvim.keys.normal_mode[""] = ":DapContinue" lvim.keys.normal_mode[""] = ":DapToggleRepl" lvim.keys.normal_mode[""] = ":DapTerminate" lvim.keys.normal_mode[""] = ":DapStepOver" lvim.keys.normal_mode[""] = ":DapStepInto" lvim.keys.normal_mode[""] = ":DapStepOut" -- Quick word replacing (use . for next word) lvim.keys.normal_mode["cn"] = "*``cgn" lvim.keys.normal_mode["cN"] = "*``cgN" -- Quick replace all vim.api.nvim_set_keymap("n", "", "", { noremap = true, callback = function() vim.fn.inputsave() local query = vim.fn.input "To replace: " vim.fn.inputsave() local answer = vim.fn.input("Replace text: ", query) vim.api.nvim_command("%s/\\V" .. query:gsub("/", "\\/") .. "/" .. answer:gsub("/", "\\/") .. "/") vim.fn.inputrestore() vim.api.nvim_feedkeys("v", "n", false) end, }) vim.api.nvim_set_keymap("v", "", "", { noremap = true, callback = function() local getselection = function() return vim.fn.strcharpart(vim.fn.getline(vim.fn.line "."), vim.fn.min { vim.fn.charcol ".", vim.fn.charcol "v", } - 1, vim.fn.abs(vim.fn.charcol "." - vim.fn.charcol "v") + 1) end local query = getselection() vim.fn.inputsave() local answer = vim.fn.input("Replace text: ", query) vim.api.nvim_command("%s/\\V" .. query:gsub("/", "\\/") .. "/" .. answer:gsub("/", "\\/") .. "/") vim.fn.inputrestore() vim.api.nvim_feedkeys("v", "n", false) end, }) -- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode. -- we use protected-mode (pcall) just in case the plugin wasn't loaded yet. -- local _, actions = pcall(require, "telescope.actions") -- lvim.builtin.telescope.defaults.mappings = { -- -- for input mode -- i = { -- [""] = actions.move_selection_next, -- [""] = actions.move_selection_previous, -- [""] = actions.cycle_history_next, -- [""] = actions.cycle_history_prev, -- }, -- -- for normal mode -- n = { -- [""] = actions.move_selection_next, -- [""] = actions.move_selection_previous, -- }, -- } -- Use which-key to add extra bindings with the leader-key prefix -- lvim.builtin.which_key.mappings["P"] = { "Telescope projects", "Projects" } -- lvim.builtin.which_key.mappings["t"] = { -- name = "+Trouble", -- r = { "Trouble lsp_references", "References" }, -- f = { "Trouble lsp_definitions", "Definitions" }, -- d = { "Trouble document_diagnostics", "Diagnostics" }, -- q = { "Trouble quickfix", "QuickFix" }, -- l = { "Trouble loclist", "LocationList" }, -- w = { "Trouble workspace_diagnostics", "Workspace Diagnostics" }, -- }