-- Remove trailing spaces on save, preserving cursor and search pattern local function strip_trailing_whitespace() if vim.list_contains({ "markdown", "diff" }, vim.bo.filetype) then return end local view = vim.fn.winsaveview() vim.cmd([[keeppatterns %s/\s\+$//e]]) vim.fn.winrestview(view) end vim.api.nvim_create_autocmd("BufWritePre", { pattern = "*", callback = strip_trailing_whitespace, }) -- Note: the colorscheme (with its "desert" fallback) is applied from -- lua/plugins/colorscheme.lua's own `config` function, not here — under -- lazy.nvim that's the natural place to react to "the plugin is now loaded". -- -- Note: the vimrc's "reload vimrc on save" autocmd has no clean Lua -- equivalent (module caching means `require()`-based configs aren't simply -- re-sourceable) and is deliberately not ported.