Skip to content

Commit

Permalink
Check if StripWhitespaceOnCahngedLines exists before calling it
Browse files Browse the repository at this point in the history
  • Loading branch information
RhydianJenkins committed Feb 25, 2025
1 parent 8c2e775 commit 4ab792e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nvim/lua/rhydian/autocommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ vim.api.nvim_create_autocmd("TextYankPost", {
})

vim.api.nvim_create_autocmd("BufWritePre", {
desc = "Stop trailing whitespace",
desc = "Strip trailing whitespace",
group = vim.api.nvim_create_augroup("StripWhitespaceGroup", {}),
callback = function()
vim.cmd("StripWhitespaceOnChangedLines")
if vim.fn.exists(":StripWhitespaceOnChangedLines") == 2 then
vim.cmd("StripWhitespaceOnChangedLines")
end
end,
})

Expand Down

0 comments on commit 4ab792e

Please sign in to comment.