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 when running ClangFormat in neovim #111

Open
obaranek opened this issue Nov 8, 2020 · 3 comments
Open

Error when running ClangFormat in neovim #111

obaranek opened this issue Nov 8, 2020 · 3 comments

Comments

@obaranek
Copy link

obaranek commented Nov 8, 2020

Hi, I get this error when i run ClangFormat:
Error detected while processing function clang_format#replace[6]..139_error_message:

@abertoldi
Copy link

I also see this error on neovim (nightly).

@MyNamehuh
Copy link

MyNamehuh commented Jul 24, 2021

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.

@sunbingfeng
Copy link

Yeah, it works.

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

4 participants