From 1808edb36fb65525d87bd863e8024eeea7cc3393 Mon Sep 17 00:00:00 2001 From: Pratham Patel Date: Tue, 19 Mar 2024 17:10:40 +0530 Subject: [PATCH] nvim: add autocmd to remove trailing spaces, it is ugly --- .config/nvim/lua/autocmds.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.config/nvim/lua/autocmds.lua b/.config/nvim/lua/autocmds.lua index b065ff1..2dacbd8 100644 --- a/.config/nvim/lua/autocmds.lua +++ b/.config/nvim/lua/autocmds.lua @@ -16,3 +16,9 @@ vim.api.nvim_create_autocmd('BufWritePre', { pattern = {'*.rs'}, command = 'lua vim.lsp.buf.format(nil, 200)', }) +-- thank you, Prime +-- https://github.com/ThePrimeagen/neovimrc/blob/4d7a467091706a75684ee9a32b1e1e8f2e187e39/lua/theprimeagen/init.lua#L44-L48 +vim.api.nvim_create_autocmd('BufWritePre', { + pattern = "*", + command = [[%s/\s\+$//e]], +})