local kmap = vim.keymap.set local keys = { -- ========== БАЗОВАЯ НАВИГАЦИЯ ========== { "", "", { desc = "Disable Space in normal mode" }, }, { "", "^", { desc = "Go to first non-blank character" }, }, { "", "$", { desc = "Go to end of line" }, }, { "", "^", { mode = "v", desc = "Go to first non-blank character (visual)" }, }, { "", "$", { mode = "v", desc = "Go to end of line (visual)" }, }, { "", "^", { mode = "i", desc = "Go to first non-blank character (insert)" }, }, { "", "$", { mode = "i", desc = "Go to end of line (insert)" }, }, -- ========== ВИЗУАЛЬНЫЙ РЕЖИМ ========== { "i", "", { mode = "v", desc = "Select inner object" }, }, { "a", "", { mode = "v", desc = "Select around object" }, }, { "J", ":m '>+1gv=gv", { mode = "v", desc = "Move selection down" }, }, { "K", ":m '<-2gv=gv", { mode = "v", desc = "Move selection up" }, }, { "<", "", ">gv", { mode = "v", desc = "Indent right and keep selection" }, }, -- ========== УПРАВЛЕНИЕ БУФЕРАМИ ========== { "bn", "bnext", { desc = "Next buffer" }, }, { "bp", "bprevious", { desc = "Previous buffer" }, }, { "bd", "bdelete", { desc = "Delete buffer" }, }, { "", "wa", { desc = "Save all files" }, }, { "q", "q", { desc = "Exit" }, }, { "vs", "vsplit", { desc = "Vertical split" }, }, -- ========== УПРАВЛЕНИЕ ВКЛАДКАМИ ========== { "", "tabnext", { desc = "Next tab" }, }, { "", "tabprevious", { desc = "Previous tab" }, }, { "", "tabnew", { desc = "New tab" }, }, { "", "tabclose", { desc = "Close tab" }, }, -- ========== NVIM-TREE (ФАЙЛОВЫЙ ЭКСПЛОРЕР) ========== { "", function() local api = require("nvim-tree.api") local global_cwd = vim.fn.getcwd(-1, -1) api.tree.change_root(global_cwd) end, { desc = "Change tree root to CWD" }, }, { "", "NvimTreeToggle", { desc = "Toggle file tree" }, }, -- ========== TELESCOPE (ПОИСК) ========== { "ff", "Telescope find_files", { desc = "Find files" }, }, { "fg", "Telescope live_grep", { desc = "Live grep" }, }, { "fb", "Telescope current_buffer_fuzzy_find", { desc = "Find in current buffer" }, }, { "", "Telescope buffers", { desc = "Find buffers" }, }, { "gc", "Telescope git_commits", { desc = "Git commits" }, }, { "gs", "Telescope git_status", { desc = "Git status" }, }, { "ch", "Telescope commands_history", { desc = "Commands history" }, }, { "e", "Telescope diagnostics", { desc = "Diagnostics" }, }, { "gi", "Telescope lsp_implementations", { desc = "LSP implementations" }, }, { "gr", "Telescope lsp_references", { desc = "LSP references" }, }, -- ========== LSP (ЯЗЫКОВОЙ СЕРВЕР) ========== { "d[", vim.diagnostic.goto_prev, { desc = "Previous diagnostic" }, }, { "d]", vim.diagnostic.goto_next, { desc = "Next diagnostic" }, }, { "gD", vim.lsp.buf.declaration, { desc = "Go to declaration" }, }, { "gd", vim.lsp.buf.definition, { desc = "Go to definition" }, }, { "K", vim.lsp.buf.hover, { desc = "Show documentation" }, }, { "", vim.lsp.buf.signature_help, { desc = "Signature help" }, }, { "sad", "ApidocsOpen", { desc = "Search Api Doc" }, }, { "wa", vim.lsp.buf.add_workspace_folder, { desc = "Add workspace folder" }, }, { "wr", vim.lsp.buf.remove_workspace_folder, { desc = "Remove workspace folder" }, }, { "im", function() require("telescope").extensions.goimpl.goimpl({}) end, { desc = "Generate stub for interface on a type for golang" }, }, { "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, { desc = "List workspace folders" }, }, { "", "Lspsaga code_action", { desc = "Code actions" }, }, { "", vim.lsp.buf.rename, { desc = "Rename symbol" }, }, { "", "gqip", { desc = "Reflow line" }, }, -- ========== ИЗМЕНЕНИЕ РАЗМЕРА ОКОН ========== { "", function() require("myplugins.resize").ResizeLeft() end, { desc = "Resize window left" }, }, { "", function() require("myplugins.resize").ResizeRight() end, { desc = "Resize window right" }, }, { "", function() require("myplugins.resize").ResizeUp() end, { desc = "Resize window up" }, }, { "", function() require("myplugins.resize").ResizeDown() end, { desc = "Resize window down" }, }, -- ========== DAP (ОТЛАДКА) ========== { "", function() require("dapui").toggle() end, { desc = "Toggle debug UI" }, }, { "dh", function() require("dap.ui.widgets").hover() end, { desc = "Debug hover" }, }, { "dp", function() require("dap.ui.widgets").preview() end, { desc = "Debug preview" }, }, { "dt", function() require("dap-go").debug_test() end, { desc = "Debug test" }, }, { "", function() local widgets = require("dap.ui.widgets") widgets.centered_float(widgets.scopes) end, { desc = "Debug scopes" }, }, { "", function() require("dap").continue() end, { desc = "Debug continue" }, }, { "", function() -- S-F5 require("dap").restart() end, { desc = "Debug restart" }, }, { "", function() -- C-F5 require("dap").terminate() end, { desc = "Debug terminate" }, }, { "", function() require("dap").step_over() end, { desc = "Debug step over" }, }, { "", function() require("dap").step_into() end, { desc = "Debug step into" }, }, { "", function() -- S-F7 require("dap").step_out() end, { desc = "Debug step out" }, }, { "", function() require("dap").toggle_breakpoint() end, { desc = "Toggle breakpoint" }, }, -- ========== ФОРМАТИРОВАНИЕ ========== { "mp", function() require("conform").format({ lsp_fallback = true, async = false, timeout_ms = 500 }) end, { desc = "Format file or range (in visual mode)" }, }, } -- Добавляем быстрый переход по вкладкам (1-9) for i = 1, 9 do table.insert(keys, { "", "tabn " .. i .. "", { desc = "Go to tab " .. i }, }) end -- Применяем все кеймапинги for _, mapping in ipairs(keys) do local key = mapping[1] local action = mapping[2] local opts = mapping[3] or {} -- Извлекаем режим или используем "n" по умолчанию local mode = opts.mode or "n" -- Удаляем mode из opts, так как он передается отдельно opts.mode = nil -- Устанавливаем silent = true по умолчанию if opts.silent == nil then opts.silent = true end kmap(mode, key, action, opts) end