Files
nvim/lua/keymaps.lua
T
2026-06-11 18:23:52 +02:00

58 lines
2.0 KiB
Lua

local map = vim.keymap.set
local silent = { silent = true }
-- Clear search highlighting on Escape
map("n", "<Esc>", "<cmd>nohlsearch<cr>", silent)
-- Visual line navigation
for _, mode in ipairs({ "n", "x" }) do
map(mode, "j", "gj", silent)
map(mode, "k", "gk", silent)
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" })
-- LSP (rename/code-action/references use native gr* defaults on 0.11+)
map("n", "<leader>gf",
function() require("conform").format({ lsp_format = "fallback" }) end,
{ desc = "Format buffer" })
map("n", "<leader>gd", vim.lsp.buf.definition)
map("n", "<leader>gD", vim.lsp.buf.declaration)
-- Trouble
map("n", "<leader>xx", "<cmd>Trouble diagnostics toggle focus=true<cr>",
{ desc = "Diagnostics (Trouble)" })
map("n", "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0 focus=true<cr>",
{ desc = "Buffer Diagnostics (Trouble)" })
map("n", "<leader>xt", "<cmd>Trouble todo toggle<cr>", { desc = "Todo (Trouble)" })
-- Pickers / files
map("n", "<C-f>", "<cmd>Pick files<cr>")
map("n", "<C-g>", "<cmd>Pick grep_live<cr>")
map("n", "<C-b>", "<cmd>Pick buffers<cr>")
map("n", "<C-h>", "<cmd>Pick help<cr>")
map("n", "<C-e>", "<cmd>Oil<cr>")
map("n", "<C-k>", "<cmd>Pick keymaps<cr>")
-- DAP
map("n", "<leader>duo", function() require("dapui").open() end)
map("n", "<leader>duc", function() require("dapui").close() end)
map("n", "<leader>dbp", function() require("dap").toggle_breakpoint() end)
map("n", "<leader>drc", function() require("dap").run_to_cursor() end)
-- Spell
map("n", "<leader>sc", function()
vim.wo.spell = not vim.wo.spell
vim.notify("Spell: " .. (vim.wo.spell and "ON" or "OFF"))
end, { desc = "Toggle spell" })
map("n", "<leader>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 = "Switch spell language" })