From e8bd36899b88285c94c850f0dfce0754d94cfe24 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Mon, 22 Dec 2025 17:37:13 +0100 Subject: Neovim: Neue Konfiguration --- nvim/lua/config/keymaps.lua | 94 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 nvim/lua/config/keymaps.lua (limited to 'nvim/lua/config/keymaps.lua') diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..c54247c --- /dev/null +++ b/nvim/lua/config/keymaps.lua @@ -0,0 +1,94 @@ +local M = {} + +local map = vim.keymap.set + +function M.lsp(buffer, client) + local opts = { + buffer = buffer, + noremap = true, + silent = true, + } + + map("n", "gd", vim.lsp.buf.definition, opts) + map("n", "gD", vim.lsp.buf.declaration, opts) + map("n", "gr", vim.lsp.buf.references, opts) + map("n", "gi", vim.lsp.buf.implementation, opts) + map("n", "K", vim.lsp.buf.hover, opts) + map("n", "rn", vim.lsp.buf.rename, opts) + map("n", "ca", vim.lsp.buf.code_action, opts) + map("n", "cf", function() vim.lsp.buf.format({ async = true; }) end, opts) + + if client and client.name == "clangd" then + map("n", "hs", "ClangdSwitchSourceHeader", opts) + end +end + +function M.telescope() + local opts = { + noremap = true, + silent = true, + } + + map("n", "ff", function() + require("telescope.builtin").find_files() + end, opts) + + map("n", "fg", function() + require("telescope.builtin").live_grep() + end, opts) + + map("n", "fb", function() + require("telescope.builtin").buffers() + end, opts) + + map("n", "fh", function() + require("telescope.builtin").help_tags() + end, opts) + + map("n", "dd", function() + require("telescope.builtin").diagnostics() + end, opts) +end + +function M.global() + local opts = { + noremap = true, + silent = true, + } + + map("n", "ö", "}", opts) + map("n", "ä", "{", opts) + + map("n", "K", function() + vim.diagnostic.open_float({ scope = "cursor", border = "rounded" }) + end, opts) + map("n", "q", vim.diagnostic.setloclist, opts) + + map("n", "[d", function() + vim.diagnostic.jump_prev({ wrap = false }) + end, opts) + + map("n", "]d", function() + vim.diagnostic.jump_next({ wrap = false }) + end, opts) + + map("n", "[e", function() + vim.diagnostic.jump_prev({ + severity = vim.diagnostic.severity.ERROR, + wrap = false + }) + end, opts) + + map("n", "]e", function() + vim.diagnostic.jump_next({ + severity = vim.diagnostic.severity.ERROR, + wrap = false + }) + end, opts) + + vim.keymap.set("n", "ts", function() + vim.opt_local.spell = not vim.opt_local.spell:get() + end, { desc = "Toggle spell checking" }) +end + +return M -- cgit v1.3