local map = vim.keymap.set -- ========== Basics =========== -- map("n", ";", ":", { desc = "CMD enter command mode" }) map("i", "jk", "") map("t", "jk", "") map("n", "h", "s | terminal | i"); -- ========== Debug =========== -- map('n', 'db', 'DapToggleBreakpoint', { desc = 'Toggle breakpoint' }) map('n', 'dr', 'DapContinue', { desc = 'Start/continue debug' }) map('n', 'ds', 'DapStepOver', { desc = 'Step over' }) map('n', 'di', 'DapStepInto', { desc = 'Step into' }) map('n', 'do', 'DapStepOut', { desc = 'Step out' }) map('n', 'dq', 'DapTerminate', { desc = 'Stop debug' }) map('n', 'du', 'lua require("dapui").toggle()', { desc = 'Toggle DAP UI' }) -- ========== LSP =========== -- map('n', 'lo', 'lua vim.diagnostic.open_float()', { noremap = true, silent = true, desc = 'Open diagnostic' }) map("n", "ll", 'lua vim.lsp.buf.code_action()', { noremap = true, silent = true, desc = 'Show complete by lsp'}) map('n', '[l', 'DapContinue', { noremap = true, silent = true, desc = 'Go to prev diagnostic' }) map('n', ']l', 'DapStepOver', { noremap = true, silent = true, desc = 'Go to next diagnostic' }) map('n', 'lt', 'DapStepInto', { noremap = true, silent = true, desc = 'Open toggle' }) map("n", "ds", vim.diagnostic.setloclist, { desc = "LSP diagnostic loclist" }) map("n", "", "noh", { desc = "general clear highlights" }) -- ========== Sessions ============= -- map("n", "ss", ":SessionSave", {noremap = true, silent = true}) map("n", "sl", ":SessionLoad", {noremap = true, silent = true}) map("n", "st", ":Telescope persisted", {noremap = true, silent = true}) -- ========== Window moves ============= -- map("n", "", "h", { desc = "switch window left" }) map("n", "", "l", { desc = "switch window right" }) map("n", "", "j", { desc = "switch window down" }) map("n", "", "k", { desc = "switch window up" }) -- ========== Line moves ============= -- map("i", "", "^i", { desc = "move beginning of line" }) map("i", "", "", { desc = "move end of line" }) map("i", "", "", { desc = "move left" }) map("i", "", "", { desc = "move right" }) map("i", "", "", { desc = "move down" }) map("i", "", "", { desc = "move up" }) -- ========== Comments ============= -- map("n", "/", "gcc", { desc = "toggle comment", remap = true }) map("v", "/", "gc", { desc = "toggle comment", remap = true }) -- ========== Nvim-tree ============= -- map("n", "", "NvimTreeToggle", { desc = "nvimtree toggle window" }) map("n", "e", "NvimTreeFocus", { desc = "nvimtree focus window" }) -- ========== Telescope ============= -- map("n", "fw", "Telescope live_grep", { desc = "telescope live grep" }) map("n", "fb", "Telescope buffers", { desc = "telescope find buffers" }) map("n", "fh", "Telescope help_tags", { desc = "telescope help page" }) map("n", "ma", "Telescope marks", { desc = "telescope find marks" }) map("n", "fo", "Telescope oldfiles", { desc = "telescope find oldfiles" }) map("n", "fz", "Telescope current_buffer_fuzzy_find", { desc = "telescope find in current buffer" }) map("n", "cm", "Telescope git_commits", { desc = "telescope git commits" }) map("n", "gt", "Telescope git_status", { desc = "telescope git status" }) map("n", "pt", "Telescope terms", { desc = "telescope pick hidden term" }) map("n", "ff", "Telescope find_files", { desc = "telescope find files" }) map("n", "fa", "Telescope find_files follow=true no_ignore=true hidden=true", { desc = "telescope find all files" }) -- ========== Which-key ============= -- map("n", "wK", "WhichKey ", { desc = "whichkey all keymaps" }) -- ========== Buffers ============= -- map("n", "x", function() local bufnr = vim.api.nvim_get_current_buf() local buftype = vim.api.nvim_buf_get_option(bufnr, 'buftype') local modified = vim.api.nvim_buf_get_option(bufnr, 'modified') if buftype == 'terminal' then vim.cmd('bp | sp | bn | bd!') return end if modified then vim.notify("Changes not saved") else vim.cmd('bp | sp | bn | bd') end end, {desc = "Close buffer"}) map("n", "e", "enew", {desc = "Create buffer"}) map("n", "", "BufferLineCycleNext", {desc = "Go to next buffer"}) map("n", "", "BufferLineCyclePrev", {desc = "Go to prev buffer"}) -- ========== Git ============= -- map("n", "gb", "Gitsigns blame", {desc = "Open blame for file"}) map("n", "gl", "Gitsigns blame", {desc = "Open blame for file"}) map("n", "gco", "GitConflictChooseOurs", {desc = "Select the current changes"}) map("n", "gct", "GitConflictChooseTheirs", {desc = "Select the incoming changes"}) map("n", "gcn", "GitConflictNextConflict", {desc = "Move to the next conflict"}) map("n", "gcp", "GitConflictPrevConflict", {desc = "Move to the previous conflict"}) map("n", "ghn", "Gitsigns blame", {desc = "Show hunk in normal mode"}) map("n", "ghi", "Gitsigns blame", {desc = "Show hunk inline"}) map("n", "gd", "Gitsigns diffthis", {desc = "Show diff of buffer"}) map("n", "gs", "Gitsigns stage_buffer", {desc = "Stage this buffer"}) map("n", "gu", "Gitui", {desc = "Stage this buffer"}) -- ========== Target ============= -- map("n", "tt", "Build", {desc = "Build project"}) map("n", "tt", "Target", {desc = "Execute target"}) map("n", "tn", "TargetNew", {desc = "Create new target"}) map("n", "tl", "TargetList", {desc = "Show list of targets"}) map("n", "td", "TargetDelete", {desc = "Delete target from list"})