local map = vim.keymap.set -- Clear search highlighting on Escape map("n", "", "nohlsearch", { silent = true, desc = "Clear search highlight" }) -- Visual line navigation (move by display line over wrapped text) for _, mode in ipairs({ "n", "x" }) do map(mode, "j", "gj", { silent = true, desc = "Down (display line)" }) map(mode, "k", "gk", { silent = true, desc = "Up (display line)" }) end -- Hover: native LSP hover (press K again to focus the window). -- Border comes from the global `winborder` option. map("n", "K", function() vim.lsp.buf.hover({ max_width = 80 }) end, { desc = "LSP: hover docs" }) -- LSP (rename/code-action/references use native gr* defaults on 0.11+) map("n", "gf", function() require("conform").format({ lsp_format = "fallback" }) end, { desc = "LSP: format buffer" }) map("x", "gs", function() require("conform").format({ lsp_format = "fallback" }) end, { desc = "LSP: format selection" }) map("n", "gd", vim.lsp.buf.definition, { desc = "LSP: go to definition" }) map("n", "gD", vim.lsp.buf.declaration, { desc = "LSP: go to declaration" }) -- Trouble map("n", "xx", "Trouble diagnostics toggle focus=true", { desc = "Trouble: workspace diagnostics" }) map("n", "xX", "Trouble diagnostics toggle filter.buf=0 focus=true", { desc = "Trouble: buffer diagnostics" }) map("n", "xt", "Trouble todo toggle", { desc = "Trouble: todo list" }) -- Pickers / files map("n", "", "Pick files", { desc = "Find: files" }) map("n", "", "Pick grep_live", { desc = "Find: grep project (disk)" }) map("n", "", "Pick buf_lines scope='all'", { desc = "Find: grep open buffers" }) map("n", "", "Pick buffers", { desc = "Find: buffers" }) map("n", "", "Pick help", { desc = "Find: help tags" }) map("n", "", "Oil", { desc = "File explorer (Oil)" }) map("n", "", "Pick keymaps", { desc = "Find: keymaps" }) -- DAP map("n", "duo", function() require("dapui").open() end, { desc = "Debug: open UI" }) map("n", "duc", function() require("dapui").close() end, { desc = "Debug: close UI" }) map("n", "dbp", function() require("dap").toggle_breakpoint() end, { desc = "Debug: toggle breakpoint" }) map("n", "drc", function() require("dap").run_to_cursor() end, { desc = "Debug: run to cursor" }) -- Spell map("n", "sc", function() vim.wo.spell = not vim.wo.spell vim.notify("Spell: " .. (vim.wo.spell and "ON" or "OFF")) end, { desc = "Spell: toggle" }) map("n", "sl", function() local cur = vim.opt.spelllang:get()[1] or "" local new = cur == "en" and "de" or "en" vim.opt.spelllang = new vim.notify("Spell lang: " .. new) end, { desc = "Spell: switch language (en/de)" })