Allow to disable trailing spaces removal for certain languages

This commit is contained in:
2026-05-01 13:51:33 +02:00
parent d0d56f76dd
commit b5c4a01b94
+9 -5
View File
@@ -40,12 +40,16 @@ vim.opt.updatetime = 300
vim.opt.list = true vim.opt.list = true
vim.opt.listchars = { trail = '·', tab = ' ', nbsp = '¬' } vim.opt.listchars = { trail = '·', tab = ' ', nbsp = '¬' }
-- Auto remove trailing spaces -- Auto remove trailing spaces for allowed files
vim.g.trim_trailing_spaces_exclude = {}
vim.api.nvim_create_autocmd({'BufWritePre'}, { vim.api.nvim_create_autocmd({'BufWritePre'}, {
pattern = {'*'}, pattern = {'*'},
callback = function(ev) callback = function(ev)
vim.cmd('%s/\\s\\+$//e') local excludes = vim.g.trim_trailing_spaces_exclude or {}
end if not vim.tbl_contains(excludes, vim.bo.filetype) then
vim.cmd('%s/\\s\\+$//e')
end
end
}) })
-- COLOR -- -- COLOR --