Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error detected while processing BufWritePre Autocommands for "*"..function <SNR>23_StripWhitespaceOnSave #160

Closed
asgeo1 opened this issue Dec 11, 2022 · 6 comments

Comments

@asgeo1
Copy link

asgeo1 commented Dec 11, 2022

I'm getting this error when saving a file in Vim:

Error detected while processing BufWritePre Autocommands for "*"..function 23_StripWhitespaceOnSave

I think about 2 weeks ago, I updated my plugins and everything was fine. And today I've updated them again, and now I get this error. It's weird, because looking at this repo, it doesn't look like anything has changed.

image

I've tried to isolate the issue by removing every plugin (other than vim-better-whitespace), and pretty much commenting out my entire Vim setup, other than packer.

I still get the same error, which is really weird. Any ideas?

This is how I am using this plugin in my packer setup:

    use {
        'ntpeters/vim-better-whitespace',
        config = function()
          vim.g.strip_whitespace_on_save = 1
          vim.g.better_whitespace_filetypes_blacklist = {
            'spectre_panel',
            'diff',
            'git',
            'gitcommit',
            'unite',
            'qf',
            'help',
            'markdown',
            'fugitive',
          }
          vim.g.strip_whitespace_confirm = 0
          vim.g.show_spaces_that_precede_tabs = 1
          vim.g.better_whitespace_operator = '_s'
          vim.g.strip_only_modified_lines = 1
        end,
      }
@Cimbali
Copy link
Collaborator

Cimbali commented Dec 12, 2022

Hi @asgeo1, can you give details of your platform, vim version, plugin manager, etc? Seeing the error and when it happens I think it could be your diff command that changed. You should be able to set it using vim.g.diff_binary

@kstevens715
Copy link

I get this same error. I thought I first saw it after upgrading to Neovim nightly. But I also just tried it and reproduced it with versions 0.7.2, 0.8.0 and 0.8.1.

I'm using a Mac and Packer as my plugin manager. Here's some info about my current Neovim version:

NVIM v0.9.0-dev-415+g282dda643-dirty
Build type: Release
LuaJIT 2.1.0-beta3

@Cimbali
Copy link
Collaborator

Cimbali commented Dec 24, 2022

Does the error disappear if you set g:strip_only_modified_lines=0 ? If so, what are the outputs of command diff --version and which -a diff ?

@kstevens715
Copy link

Yes, setting g:strip_only_modified_lines=0 does make the error go away.

Here's the output of those commands:

➜  dotfiles git:(master) ✗ command diff --version
Apple diff (based on FreeBSD diff)
➜  dotfiles git:(master) ✗ which -a diff
/usr/bin/diff

kstevens715 added a commit to kstevens715/dotfiles that referenced this issue Dec 24, 2022
I had this plugin turned off (at least in terms of automatically
removing whitespace on save). Based on the following issue, it's now
working as long as I remove all whitespace instead of just on changed
lines. Not ideal, but I think it'll be good enough for now.

See:
ntpeters/vim-better-whitespace#160 (comment)
@kstevens715
Copy link

If I replace Apple diff with GNU diffutils (brew install diffutils) the problem also goes away.

@Cimbali
Copy link
Collaborator

Cimbali commented Dec 24, 2022

yes so this is the same as #159. If you use GNU diff (brew install diffutils) then you’ll be able to keep strip_only_modified_lines=1. I’m not sure why this seems to change for several users at the same time.

kstevens715 added a commit to kstevens715/dotfiles that referenced this issue Dec 24, 2022
Apple's diff util appears to have changed recently and broken what
vim-better-whitespace is expecting. This changes to use GNU diffutils to
work around the problem.

See:
ntpeters/vim-better-whitespace#160
@Cimbali Cimbali closed this as not planned Won't fix, can't repro, duplicate, stale Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants