blob: 7bc4f6bb4894655a85533f5e15d1208453a3e3da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
-- 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.
|