Bad interaction with vim-gitgutter
pjt opened this issue · comments
When using vim-cljfmt with vim-gitgutter (https://github.com/airblade/vim-gitgutter), saving a file raises an error along the lines of "undefined variable l:cljfmt_output" when processing a vim-gitgutter function, & overwrites the file with the empty string.
Versions of each plugin:
- vim-cljfmt: 325a787
- vim-gitgutter: e5efbaffc066ababc9ae0d689c7050fa5d6591bd
Sorry for the non-verbatim error message & short report, but I had to uninstall & get back to work today, but wanted to get the info out about the error & bad failure condition – an overwritten file.
Yeah, this looks very similar to the other issue I've got open right now #6 - not sure what's going on with l:cljfmt_output but that looks to be the root of the problem. More diagnostics to follow.
I believe 50e47e0 should fix this. Please update and let me know if you're still experiencing the issue.
Updated & new behavior is: I save the file, message flashes in status line then disappears (I couldn't read it or figure out how to get it back – nothing was in :messages
), then file is overwritten with the empty string.
Just out of curiosity, what makes you think that it's vim-gitgutter that's interfering with vim-cljfmt here? vim-cljfmt does attempt to format the file on write, so my suspicion is that it's not a vim-gitgutter problem.
Rather, what I mean is that I suspect vim-cljfmt may be to blame in isolation from any activity on vim-gitgutter's part.
Good question, & turns out you're right to suspect that. I disabled vim-gitgutter & saw the same results: file is overwritten upon save.
I suspected vim-gitgutter before b/c of the error message. Now, as I mentioned, I can't glimpse the error message so can't report.
The file I'm testing with is my project.clj
. If I run lein cljfmt check project.clj
, it reports: "All source files formatted correctly."
@pjt - I think the latest commit should have fixed this. Would you mind pulling and giving it a try?
Sorry for the delay. Running against this commit does indeed seem to solve the problem. I no longer get a wiped buffer or an overwritten file.
I tried running :Cljfmt
with a mis-configured nREPL running (no cljfmt
in my ~/.lein/profiles.clj
), & I see the good same behavior of the buffer getting wiped. However, if possible it'd be nice to see an explanatory Vim error message ("Cljfmt encountered problems formatting file; please make sure cljfmt is in your project dependencies" or some such). Otherwise the behavior (no change to file) is indistinguishable from :Cljfmt
running on an already well formatted file.
Thanks for the attention to this!
Finally got around to fixing this. Let me know if you encounter any other issues :)