local map = vim.keymap.set map("n", ";", ":", { desc = "CMD enter command mode" }) map("i", "jk", "") map("n", "", ":Telescope resume ", { desc = "Telescope resume" }) map("n", "", ":Telescope keymaps ", { desc = "Show (and search) all [k]eymaps" }) map("n", "", ":Telescope find_files ", { desc = "Find files" }) map("n", "", ":Telescope find_files follow=true no_ignore=true hidden=true ", { desc = "Find all files" }) map("n", "", ":Telescope live_grep ", { desc = "Live grep" }) map("n", "", ":Telescope buffers ", { desc = "Find buffers" }) map("n", "/", ":Telescope search_history ", { desc = "Search history" }) map("n", "//", ":noh", { desc = "Clear highlights" }) -- go to beginning and end map("i", "", "^i", { desc = "Beginning of line" }) map("i", "", "", { desc = "End of line" }) -- navigate within insert mode map("i", "", "", { desc = "Move left" }) map("i", "", "", { desc = "Move right" }) map("i", "", "", { desc = "Move down" }) map("i", "", "", { desc = "Move up" }) map("n", "", " w ", { desc = "Save file" }) map("n", "rr", ":source $MYVIMRC", { desc = "Reload config file" }) map("n", "", " noh ", { desc = "Clear highlights" }) -- switch between windows map("n", "", "h", { desc = "Window left" }) map("n", "", "l", { desc = "Window right" }) map("n", "", "j", { desc = "Window down" }) map("n", "", "k", { desc = "Window up" }) -- [""] = { " tab Git diff %", "Git diff this file" }, map("n", "", " DiffviewOpen -- %", { desc = "Git diff this file" }) map("n", "", " DiffviewFileHistory %", { desc = "Git history diff this file" }) map("n", "", " DiffviewClose", { desc = "Close git diff" }) -- [""] = { " tab Git diff", "Git diff global" }, map("n", "", " DiffviewOpen", { desc = "Git diff global" }) map("n", "", ":DiffviewOpen HEAD~", { desc = "Show last N commits" }) map("n", "gd", " DiffviewClose", { desc = "Git diff close" }) -- save map("n", "", " w ", { desc = "Save file" }) -- Quit map("n", "", " q! ", { desc = "Force quit window" }) -- line numbers -- map("n", "n", " set nu! ", { desc = "Toggle line number" }) -- map("n", "rn", " set rnu! ", { desc = "Toggle relative number" }) -- Movement -- Allow moving the cursor through wrapped lines with j, k, and -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ -- empty mode is same as using :map -- also don't use gmap("n", j|k,n in operator pending mode, {desc = so it doesn't alter d, y or c behaviou) -- map("n", "j", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { desc = "Move down", opts = { expr = true } }) -- map("n", "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { desc = "Move up", opts = { expr = true } }) -- map("n", "", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { desc = "Move up", opts = { expr = true } }) -- map("n", "", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { desc = "Move down", opts = { expr = true } }) -- Copy/pasting into /tmp -- map("n", "y", " :w! /tmp/vimtmp", { desc = "Save into a global tmp file" }) -- map("n", "p", " :r! cat /tmp/vimtmp", { desc = "Restore from the global tmp file" }) -- (Double) Trouble map("n", "tx", ":Trouble diagnostics toggle", { desc = "[T]rouble diagnostics" }) map("n", "tX", ":Trouble diagnostics toggle filter.buf=0", { desc = "[T]rouble buffer diagnostics" }) map("n", "ts", ":Trouble symbols toggle focus=false", { desc = "[T]rouble [S]ymbols" }) map( "n", "tl", ":Trouble lsp toggle focus=false win.position=right", { desc = "[T]rouble [L]sp def / ref / ..." } ) map("n", "tL", ":Trouble loclist toggle", { desc = "[T]rouble [L]oclist" }) map("n", "tQ", ":Trouble qflist toggle", { desc = "[T]rouble [Q]uickfix" }) -- DAP map("n", "dgg", ":lua require('dap').continue() ", { desc = "Continue debu[g]ging" }) map("n", "dg", ":lua require('dapui').toggle() ", { desc = "Toggle DAP ui" }) map("n", "dgw", ":lua require('dapui').eval() ", { desc = "Open floating windows about current [w]ord" }) map("n", "dgb", ":lua require('dap').toggle_breakpoint() ", { desc = "Toggle [b]reakpoint" }) map("n", "dgf", ":lua require('dap-python').test_method() ", { desc = "Debug [f]unction" }) map("n", "dgo", ":lua require('dap').step_over() ", { desc = "DAP step [o]ver method" }) map("n", "dgt", ":lua require('dap').step_into() ", { desc = "DAP step in[t]o method" }) map("n", "dgp", ":lua require('dap').step_back() ", { desc = "DAP step back ([p]revious)" }) map("n", "dgs", function() local widgets = require "dap.ui.widgets" local sidebar = widgets.sidebar(widgets.scopes) sidebar.open { widgth = "50%" } end, { desc = "DAP Show debugged [s]copes" }) map("v", "dgd", ":lua require('dap-python').debug_selection()", { desc = "DAP debug selection" }) map("v", "dgw", ":lua require('dap-python').eval()", { desc = "DAP eval selection" }) -- LSP map("n", "fm", function() vim.lsp.buf.format { async = true } end, { desc = "LSP formatting" }) map("t", "", vim.api.nvim_replace_termcodes("", true, true, true), { desc = "Escape terminal mode" }) -- Indentation map("v", "<", "", ">gv", { desc = "Indent line" }) -- Don't copy the replaced text after pasting in visual mode -- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#alternative_mapping_for_paste map("x", "p", 'p:let @+=@0:let @"=@0', { desc = "Dont copy replaced text" }) map("n", "", "o", { desc = "Insert new line below" }) map("n", "", "O", { desc = "Insert new line above" }) -- Vim fugitive map( "n", "", " vertical topleft Git vertical resize 50", { desc = "Show Git status on a left pane" } ) -- Fn shortcuts map("n", "", " tabprevious", { desc = "Previous tab" }) map("n", "", " tabnext", { desc = "Next tab" }) map("n", "", " Flog -all", { desc = "Show git tree" }) map("n", "", " tab Git show -", { desc = "Git show N last commits" }) map("n", "", " TagbarToggle", { desc = "Show tagbar" }) map("n", "ra", " call VrcQuery()", { desc = "Call REST endpoint" }) map("n", "dl", "0d$", { desc = "Delete line from start" }) -- Git stuffs map("n", "gpu", " Git pull", { desc = "Git pull" }) map("n", "gpf", ":Git push ", { desc = "Git push with option" }) map("n", "gmm", " Git merge master", { desc = "Git merge master" }) map("n", "gmi", ":Git merge ", { desc = "Git merge ..." }) map( "n", "ga", ":Git commit -a --amend --no-edit --no-verify", { desc = "Git commit -a --amend --no-edit --no-verify" } ) map("n", "gnb", ":Git checkout -b ", { desc = "Checkout to a new branch" }) map("n", "gri", ":Git rebase -i HEAD~", { desc = "Git rebase interactive from HEAD" }) map("n", "grm", ":Git rebase -i master", { desc = "Git rebase interactive from master" }) map("n", "grr", ":Git rebase -i ", { desc = "Git rebase interactive from