vim.g.mapleader = " " vim.keymap.set("n", "pv", vim.cmd.Ex) vim.keymap.set("n", "J", "mzJ`z") -- remap for vim-smoothie vim.cmd([[nnoremap call smoothie#do("\zz")]]) vim.cmd([[nnoremap call smoothie#do("\zz")]]) vim.cmd([[nnoremap gg call smoothie#do("gg")]]) vim.cmd([[nnoremap call smoothie#do("\zz")]]) -- recenter on next/previous search vim.keymap.set("n", "n", "nzzzv") vim.keymap.set("n", "N", "Nzzzv") --Toggle NERDCommenter with Ctrl + c vim.keymap.set("n", "", "NERDCommenterToggle") vim.keymap.set("n", "Q", "") -- reformats --vim.keymap.set("n", "f", vim.lsp.buf.format) -- global search and replace vim.keymap.set("n", "", ":%s///gI") -- single line search and replace vim.keymap.set("n", "", ":.,.s///g") -- toggle english spellcheck vim.keymap.set("n", "", ":set spell!", { silent = true }) -- make current file executable vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) -- Vimium Like Keybindings vim.keymap.set("n", "", ":tabnew", {}) -- tab keybindings vim.keymap.set("n", "", ":tabprevious", {}) vim.keymap.set("n", "", ":tabnext", {}) -- Use ctrl- [hl] to select the active split! vim.keymap.set("n", "", ":wincmd h", {}) vim.keymap.set("n", "", ":wincmd l", {}) -- remap Nvim_Tree toggle to leader+' vim.keymap.set("n", "'", ":NvimTreeToggle", {}) -- Use ctrl - [hl] to select the active split vim.keymap.set("n", "", ":wincmd h", {}) vim.keymap.set("n", "", ":wincmd l", {}) -- nv creates new vertical split vim.keymap.set("n", "nv", ":vnew", { silent = true }) -- shift + p invokes Lazy sync vim.keymap.set("n", "", ":Lazy sync", {}) -- control + t enable transparency vim.keymap.set("n", "t", ":lua ColorMyPencils()", {}) -- open :Mason using msn vim.keymap.set("n", "msn", ":Mason", { silent = true }) -- toggle relative line number with shift + x vim.keymap.set("n", "", ":set relativenumber! number", {}) -- toggle multi-corsor with control + j/k vim.cmd([[nmap ]]) vim.cmd([[nmap ]]) -- enable gitblame with ctrl + g vim.keymap.set("n", "", ":GitBlameToggle", { silent = true }) -- shift + m brings up markdown previewer vim.keymap.set("n", "", ":MarkdownPreview", {}) -- invoke neoformat with nf vim.keymap.set("n", "nf", ":Neoformat", { silent = true }) -- format C and C++ Code with cp vim.keymap.set("n", "cp", ":ClangFormat", { silent = true }) -- open fzf with ctrl + p vim.cmd([[nnoremap fzf :silent :FZFExplore]]) vim.keymap.set("n", "f", ":FZFExplore") -- vim.keymap.set("n", "", ":FZFExplore", {}) -- CtrlP: similar to fzf, but with a more simple interface vim.keymap.set("n", "", ":CtrlPMixed") -- open ripgrep vim.cmd([[nnoremap rg :silent :Rg]]) vim.keymap.set("n", "r", ":silent :Rg") -- restart lsp vim.cmd([[nnoremap lsp :silent :LspRestart]]) --toggle autocompletion vim.cmd([[nnoremap cmp :silent lua SetAutoCmp(Mode)]]) -- SudaWrite -- vim.cmd([[nnoremap sw :SudaWrite]]) -- vim.keymap.set("n", "sw", ":SudaWrite") -- appends backslash to end of specified number of lines (min 2) -- usage: 4b will append a backslash to the end of 4 lines -- note: useful for grabbing code snippets for chatting with codellama in terminal vim.cmd([[nnoremap b :.,+=v:count1norm A\]]) --toggle undotree vim.keymap.set("n", "u", ":UndotreeToggle") -- runs npm tests without having to leave vim -- vim.keymap.set("n", "t", ":w|!npm test") -- opens go to definition in new tab if not in current file vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts) -- toggles floating error messages vim.keymap.set("n", "e", "vim.diagnostic.open_float()", opts) vim.keymap.set("n", "gD", function() local org_path = vim.api.nvim_buf_get_name(0) -- Go to definition: vim.api.nvim_command("normal gd") -- Wait LSP server response vim.wait(100, function() end) local new_path = vim.api.nvim_buf_get_name(0) if not (org_path == new_path) then -- Create a new tab for the original file vim.api.nvim_command("0tabnew %") -- Restore the cursor position vim.api.nvim_command("b " .. org_path) vim.api.nvim_command('normal! `"') -- Switch to the original tab vim.api.nvim_command("normal! gt") end end, bufopts) -- dap Keybindings -- vim.keymap.set("n", "dbp", ":lua require'dap'.toggle_breakpoint()") -- vim.keymap.set("n", "dco", ":lua require'dap'.continue()") -- vim.keymap.set("n", "dov", ":lua require'dap'.step_over()") -- vim.keymap.set("n", "dso", ":lua require'dap'.step_out()") -- vim.keymap.set("n", "dsi", ":lua require'dap'.step_into()") -- vim.keymap.set("n", "dcl", ":lua require'dap'.close()") -- vim.keymap.set("n", "dui", ":lua require('dapui').toggle()") -- codeium remappings -- vim.keymap.set("i", "", function() -- return vim.fn["codeium#Accept"]() -- end, { expr = true }) -- vim.keymap.set("i", "", function() -- return vim.fn["codeium#CycleCompletions"](1) -- end, { expr = true }) -- vim.keymap.set("i", "", function() -- return vim.fn["codeium#CycleCompletions"](-2) -- end, { expr = true }) -- vim.keymap.set("i", "", function() -- return vim.fn["codeium#Clear"]() -- end, { expr = true }) --toggle codeium on/off -- function Toggle_codeium() -- vim.g.codeium_enabled = not vim.g.codeium_enabled -- end -- vim.keymap.set("n", "c", ":lua Toggle_codeium()", { noremap = true, silent = true }) ----toggle minuet on/off vim.keymap.set("n", "c", ":Minuet cmp toggle", { noremap = true, silent = true }) -- move single line or highlighted lines of text up cursor (alt + j/k) vim.keymap.set("n", "", ":m .-2==") vim.keymap.set("n", "", ":m .+1==") vim.keymap.set("v", "", ":m '>+1gv=gv") vim.keymap.set("v", "", ":m '<-2gv=gv") -- always paste text on new line -- below -- vim.api.nvim_set_keymap("n", "p", "op", { noremap = true, silent = true }) -- above -- vim.api.nvim_set_keymap("n", "P", "OP", { noremap = true, silent = true }) -- -- sets 'gx' to open with default browser vim.keymap.set("n", "gx", function() local url = vim.fn.expand("") vim.system({ "librewolf-bin", url }, { detach = true }) end, { silent = true })