local map = vim.keymap.set -- ========== Basics =========== -- map("n", ";", ":", { desc = "CMD enter command mode" }) map("i", "jk", "") map("n", "t", "terminal", { desc = "Create new terminal" }) map("t", "jk", "") map("n", "h", "s | terminal | i"); -- ========== Undotree =========== -- vim.cmd("packadd nvim.undotree") map("n", "u", require("undotree").open) -- ========== 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', function() vim.diagnostic.jump({ count = -1 }) end, { noremap = true, silent = true, desc = 'Go to prev diagnostic' }) map('n', ']l', function() vim.diagnostic.jump({ count = 1 }) end, { noremap = true, silent = true, desc = 'Go to next diagnostic' }) map('n', 'lt', vim.diagnostic.setloclist, { noremap = true, silent = true, desc = 'Toggle diagnostics list' }) map("n", "ls", vim.diagnostic.setloclist, { desc = "LSP diagnostic loclist" }) map('n', 'lu', function() vim.diagnostic.enable(not vim.diagnostic.is_enabled()) end, { desc = "Toggle Diagnostics" }) 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 }) -- ========== Neotree ============= -- map("n", "", "Neotree toggle", { desc = "nvimtree toggle window" }) map("n", "e", "Neotree focus", { 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.bo[bufnr].buftype local modified = vim.bo[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", "n", "enew", { desc = "Create buffer" }) map("n", "", "BufferLineCycleNext", { desc = "Go to next buffer" }) map("n", "", "BufferLineCyclePrev", { desc = "Go to prev buffer" }) map("n", "bt", "BufferLineGroupToggle tests", { desc = "Toggle 'tests' group" }) map("n", "bc", "BufferLineGroupToggle code", { desc = "Toggle 'code' group" }) map("n", "bp", "BufferLineGroupToggle tornado", { desc = "Toggle 'tornado' group" }) map("n", "bg", "BufferLineGroupToggle gornado", { desc = "Toggle 'gornado' group" }) -- ========== 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", "gcb", "GitConflictChooseBoth", { desc = "Seletct both 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 preview_hunk", { desc = "Show hunk in normal mode" }) map("n", "ghi", "Gitsigns preview_hunk_inline", { 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" })