From 74d64eb80b81ef2fa8aeb1abbd36af2e6fc86819 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Fri, 16 Jan 2026 10:35:58 +0100 Subject: neovim: reformat code, keybindings für pytest, und spell=false MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nvim/lua/config/autocmds.lua | 24 +++++++++++------------- nvim/lua/config/keymaps.lua | 23 +++++++++++++++++++---- nvim/lua/config/options.lua | 2 +- 3 files changed, 31 insertions(+), 18 deletions(-) (limited to 'nvim/lua/config') diff --git a/nvim/lua/config/autocmds.lua b/nvim/lua/config/autocmds.lua index e11b231..647875d 100644 --- a/nvim/lua/config/autocmds.lua +++ b/nvim/lua/config/autocmds.lua @@ -1,10 +1,10 @@ -- https://github.com/nvim-treesitter/nvim-treesitter/blob/main/doc/nvim-treesitter.txt -vim.api.nvim_create_autocmd('FileType', { +vim.api.nvim_create_autocmd("FileType", { pattern = { "c", "cpp", "lua", "typescript" }, callback = function() vim.treesitter.start() - vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' - vim.wo.foldmethod = 'expr' + vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" + vim.wo.foldmethod = "expr" vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end, }) @@ -18,13 +18,11 @@ vim.api.nvim_create_autocmd("VimEnter", { -- buffer is a [No Name] local no_name = data.file == "" and vim.bo[data.buf].buftype == "" - if not real_file and not no_name then - return - end + if not real_file and not no_name then return end -- open the tree, find the file but don't focus it - require("nvim-tree.api").tree.toggle({ focus = false, find_file = true, }) - end + require("nvim-tree.api").tree.toggle({ focus = false, find_file = true }) + end, }) -- https://github.com/nvim-tree/nvim-tree.lua/wiki/Auto-Close @@ -35,16 +33,16 @@ vim.api.nvim_create_autocmd("QuitPre", { for _, w in ipairs(wins) do local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) - if bufname:match("NvimTree_") ~= nil then - table.insert(invalid_win, w) - end + if bufname:match("NvimTree_") ~= nil then table.insert(invalid_win, w) end end if #invalid_win == #wins - 1 then -- Should quit, so we close all invalid windows. - for _, w in ipairs(invalid_win) do vim.api.nvim_win_close(w, true) end + for _, w in ipairs(invalid_win) do + vim.api.nvim_win_close(w, true) + end end - end + end, }) vim.api.nvim_create_autocmd("LspAttach", { diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua index a665e82..4b280ef 100644 --- a/nvim/lua/config/keymaps.lua +++ b/nvim/lua/config/keymaps.lua @@ -22,9 +22,24 @@ function M.lsp(buffer, client) }) end, opts) - if client and client.name == "clangd" then - map("n", "hs", "ClangdSwitchSourceHeader", opts) + local function set_c_bindings() + if client and client.name == "clangd" then map("n", "hs", "ClangdSwitchSourceHeader", opts) end 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 + end + + set_c_bindings() + set_python_bindings() end function M.telescope() @@ -110,14 +125,14 @@ function M.global() map("n", "[e", function() vim.diagnostic.jump_prev({ severity = vim.diagnostic.severity.ERROR, - wrap = false + wrap = false, }) end, opts) map("n", "]e", function() vim.diagnostic.jump_next({ severity = vim.diagnostic.severity.ERROR, - wrap = false + wrap = false, }) end, opts) end diff --git a/nvim/lua/config/options.lua b/nvim/lua/config/options.lua index a00cc64..40ccf71 100644 --- a/nvim/lua/config/options.lua +++ b/nvim/lua/config/options.lua @@ -15,7 +15,7 @@ opt.showcmd = false -- Rechtschreibprüfung opt.spelllang = { "de", "en" } -opt.spell = true +opt.spell = false -- Optionen für ^n-Vervollständigung opt.complete = { ".", "w", "b", "u", "t", "i" } -- cgit v1.3