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

There's a problem with formatting #116

Open
jphz opened this issue Jul 16, 2021 · 1 comment
Open

There's a problem with formatting #116

jphz opened this issue Jul 16, 2021 · 1 comment

Comments

@jphz
Copy link

jphz commented Jul 16, 2021

this is .vimrc file
let g:clang_format#command = 'clang-format'
autocmd FileType c,cpp ClangFormatAutoEnable

I edit and format the .cc file first,Then edit the proto file and send an error when saving it。

Error detected while processing function clang_format#replace[6]..105_error_message:
line 1:

@MyNamehuh
Copy link

I posted solution on #111
still here it is.

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.

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

2 participants