neoformat icon indicating copy to clipboard operation
neoformat copied to clipboard

Getting E790 error after undoing the autoformat

Open rambhosale opened this issue 2 years ago • 3 comments

Getting an error when trying to save to a file after undoing the autosave changes and then saving again

Steps to reproduce Save a file undo changes by pressing u save a file

error msg

Error detected while processing BufWritePre Autocommands for "*":                                                                                                                                                    
E790: undojoin is not allowed after undo

file: go (go lang) Config used

vim.api.nvim_exec([[
    augroup fmt
      autocmd!
      autocmd BufWritePre * undojoin | Neoformat
    augroup END
]], false)

rambhosale avatar Dec 05 '21 07:12 rambhosale

I'm experiencing this too. Ended up just removing undojoin from my autocmd for now.

jesseleite avatar Jan 26 '22 18:01 jesseleite

I'm seeing the same thing. Just for further information:

  • macOS 11.6.2
  • vim 8.2.4227
  • neoformat is up to date with the main branch
  • The file was go.
  • Here's my autocommand: autocmd vim_config BufWritePre *.go undojoin | Neoformat.

telemachus avatar Jan 28 '22 14:01 telemachus

@telemachus thanks for your solution using the following au for

au BufWritePre * try | undojoin | Neoformat | catch /E790/ | Neoformat | endtry

autocommand solved the save error after undo but getting an error for the first save for a file type

Error in packer_compiled: ...vim/site/pack/packer/opt/packer.nvim/lua/packer/load.lua:83: Vim(catch):E603: :catch without :try                                                                                       
Please check your config for correctness

rambhosale avatar Mar 14 '22 04:03 rambhosale