Error when running ClangFormat in neovim
obaranek opened this issue · 3 comments
Hi, I get this error when i run ClangFormat:
Error detected while processing function clang_format#replace[6]..139_error_message:
I also see this error on neovim (nightly).
I found solution to this issue.
My error message was a little bit different(number_error_message) so, I am not sure if this will help.
Reason:
I found that clang_format.vim(plugin) search for .clang-format in your system, So it give error when there is no .clang-format file
Or
In my case .clang-format file had error which lead to this error.
Solution:
Firstly clang-format needs a config file called .clang-format .
Which i recommend you to create in home directory.
mkdir ~/.clang-format
Then you can copy example config from official website.
---
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left
---
Language: JavaScript
# Use 100 columns for JS.
ColumnLimit: 100
---
Language: Proto
# Don't format .proto files.
DisableFormat: true
---
Language: CSharp
# Use 100 columns for C#.
ColumnLimit: 100
...
I recommend configuring things yourself but you can just use example config.
After that check for any error in .clang-format file by typing given command in terminal.
clang-format -dump-config
If there are no errors in output you are good to go, however if there are errors you will have resolve them in .clang-format,
I recommend using official documentation on style options as a reference.
Edit: Also you should keep .clang-format in home directory so that its globally accessable.
Checkout clang-format documentation here.
Yeah, it works.