rhysd/vim-clang-format

stderr clang-format output got pasted into the source file

kulvait opened this issue · 0 comments

Thank you for the plugin!

I am running the plugin also on the system with incompatible .clang-format file with the version of clang-format. The behavior is that when I run
clang-format -i file.cpp
it formats the file and puts error message to the stderr, in my case

YAML:38:29: error: invalid boolean
BreakBeforeBinaryOperators: All 
                            ^~~
Error reading .clang-format: Invalid argument
Can't find usable .clang-format, using LLVM style

When I run :ClangFormat in vim, it inserts the output from stderr to the beginning of the source code causing its no longer valid C++ code. I think only stdout shall be pasted to the source otherwise it can break formatted code e.g. when someone do not notice or format on save.

System affected:
custom .clang-format file with
BreakBeforeBinaryOperators: All

clang-format -version
LLVM (http://llvm.org/):
  LLVM version 3.4.2
  Optimized build.
  Built Nov  1 2018 (15:06:24).
  Default target: x86_64-redhat-linux-gnu
  Host CPU: x86-64