--[[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣷⣦⣄⡀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠚⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠗⢀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣄⡉⠓⠦⣌⡙⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⢋⣡⠴⠚⢉⣠⣤⣀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⣶⣿⣿⣿⣿⣿⣷⣦⣄⡉⠓⠦⣌⡙⠻⢿⣿⣿⣿⣿⣿⣿⡿⠟⢋⣡⠴⠚⢉⣠⣴⣾⣿⣿⣿⣿⣿⣶⣤ ⠀⠀⠀⠀⠀⠀⠀⠀⠐⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠓⠦⣌⡙⠻⠟⢋⣡⠴⠚⢉⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⠂ ⠀⠀⠀⠀⢀⣠⣴⣆⡈⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠃⠘⢉⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢁⣰⣦⣄⡀ ⠀⠀⠐⠾⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠷⠂ ⠀⢸⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⡇ ⠀⢸⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⡇ ⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⡆⢰⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉ ⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠃⠘⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⡇⢸⣿⣿⣿⣿⠿⠛⠉ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⡇⢸⠿⠛⠉ __ _ _ / _|___ ___| |_ __ _ ___| | __ | ||_ /____/ __| __/ _` |/ __| |/ / | _/ /_____\__ \ || (_| | (__| < |_|/___| |___/\__\__,_|\___|_|\_\ Neovim v0.12 configuration (C) Frank Zechert 2026 ]] local create_group = vim.api.nvim_create_augroup local create_cmd = vim.api.nvim_create_autocmd -- briefly highlight text that is yanked create_cmd("TextYankPost", { desc = "Highlight yanked text", group = create_group("cmd-highlight-yank", { clear = true }), callback = function() vim.hl.on_yank() end }) -- disable list chars in specific file types, e.g. netrw create_cmd("FileType", { desc = "Disable list characters for some filetypes", group = create_group("cmd-disable-listchars", { clear = true }), pattern = { "netrw" }, callback = function(args) vim.opt_local.list = false end }) -- when recognizing a bash shebang, switch filetype to bash create_cmd({"BufRead", "BufNewFile"}, { desc = "Recognize bash shebang as bash filetype", group = create_group("cmd-recognize-bash-filetype", { clear = true }), pattern = "*", callback = function(args) local buf = args.buf local first_line = vim.api.nvim_buf_get_lines(buf, 0, 1, false)[1] or "" if first_line:match("^#!.*/bash") then vim.bo[buf].filetype = "bash" end end }) -- when saving a file, remove trailing whitespace create_cmd("BufWritePre", { desc = "Remove trailing whitespace before saving a file", group = create_group("cmd-remove-trailing-whitespace", { clear = true }), pattern = "*", callback = function(args) vim.api.nvim_buf_call(args.buf, function() local cursor = vim.api.nvim_win_get_cursor(0) vim.cmd([[keepjumps keeppatterns silent! %s/\s\+$//e]]) vim.api.nvim_win_set_cursor(0, cursor) end) end }) -- highlight trailing whitespace when in normal mode local trailing_hl_group = create_group("cmd-highlight-trailing-whitespace", { clear = true }) local trailing_hl_match_ids = {} -- Remove highlight in all non-normal modes create_cmd({"InsertEnter", "CmdlineEnter", "TermEnter" }, { desc = "Remove trailing whitespace highlight in non-normal mode", group = trailing_hl_group, callback = function() local window = vim.api.nvim_get_current_win() local id = trailing_hl_match_ids[window] if id then pcall(vim.fn.matchdelete, id) trailing_hl_match_ids[window] = nil end end }) -- Apply highlight in normal mode create_cmd({"InsertLeave", "CmdlineLeave", "TermLeave", "BufEnter", "WinEnter" }, { desc = "Add trailing whitespace highlight in normal mode", group = trailing_hl_group, callback = function() if vim.fn.mode() ~= "n" then return end local window = vim.api.nvim_get_current_win() local id = trailing_hl_match_ids[window] if id then pcall(vim.fn.matchdelete, id) end trailing_hl_match_ids[window] = vim.fn.matchadd("TrailingWhitespace", [[\s\+$]]) end }) -- Open Trouble Quickfix list automatically create_cmd("QuickFixCmdPost", { desc = "Automatically open Quickfix List in Trouble", group = create_group("cmd-quickfix-open-trouble", { clear = true }), callback = function() vim.cmd([[Trouble qflist open]]) end }) -- Automatically open diagnostic float when hovering with cursor vim.api.nvim_create_autocmd("CursorHold", { callback = function() if not vim.api.nvim_get_current_win() then return end vim.diagnostic.open_float(nil, { focus = false, scope = "cursor" }) end, }) vim.api.nvim_create_autocmd("CursorMoved", { callback = function() for _, win in ipairs(vim.api.nvim_list_wins()) do local config = vim.api.nvim_win_get_config(win) if config.relative ~= "" then vim.api.nvim_win_close(win, false) end end end, })