From f1018e8b5a8c898887c67fc00cf60f42421df129 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Wed, 13 May 2026 17:21:37 +0200 Subject: neovim: Tastenmappings etwas überarbeitet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nvim/lua/config/keymaps.lua | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'nvim/lua/config') diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua index 29dee94..558742d 100644 --- a/nvim/lua/config/keymaps.lua +++ b/nvim/lua/config/keymaps.lua @@ -16,24 +16,40 @@ function M.lsp(buffer, client) map("n", "rn", vim.lsp.buf.rename, opts) map("n", "ca", vim.lsp.buf.code_action, opts) + local function run_in_terminal(cmd) + vim.cmd("botright split | terminal " .. cmd) + end + local function set_c_bindings() - if client and client.name == "clangd" then map("n", "hs", "ClangdSwitchSourceHeader", opts) end + map("n", "hs", "ClangdSwitchSourceHeader", opts) + + map("n", "", function() + vim.cmd("make") + vim.cmd("cwindow") + end, opts) + + map("n", "", function() run_in_terminal("gmake test") end, opts) end local function set_python_bindings() - if client and (client.name == "basedpyright" or client.name == "pyright" or client.name == "pylsp") then - local function run_pytest() - vim.cmd("botright split | terminal pytest") - end - - map("n", "", run_pytest, { - desc = "Run pytest (nur Python-Projekt)", - }) - end + map("n", "", function() run_in_terminal("pytest") end, opts) end - set_c_bindings() - set_python_bindings() + local function set_npm_bindings() + map("n", "", function() run_in_terminal("npm run build") end, opts) + map("n", "", function() run_in_terminal("npm test") end, opts) + map("n", "", function() run_in_terminal("npm start") end, opts) + end + + if client then + if client.name == "clangd" then + set_c_bindings() + elseif client.name == "basedpyright" or client.name == "pyright" or client.name == "pylsp" then + set_python_bindings() + elseif client.name == "tsserver" or client.name == "vtsls" or client.name == "typescript_tools" then + set_npm_bindings() + end + end end function M.gitsigns() @@ -103,8 +119,6 @@ function M.global() return vim.v.count == 0 and "gk" or "k" end, { expr = true, silent = true }) - map("n", "", "make", opts) - -- Kombinationen mit Leader-Key map("n", "K", function() vim.diagnostic.open_float({ scope = "cursor", border = "rounded" }) -- cgit v1.3