rhysd / vim-clang-format

Vim plugin for clang-format, a formatter for C, C++, Obj-C, Java, JavaScript, and so on.
http://clang.llvm.org/docs/ClangFormat.html
1.08k stars 123 forks source link

.clang_format style file not used #52

Open CodingJonas opened 8 years ago

CodingJonas commented 8 years ago

I have a costume .clang-format file in my home directory. When I run vim-clang-format in gVim, it formats the code without my costume settings, although I set let g:clang_format#detect_style_file = 1

in my vimrc. Does the plugin conflict with other plugins? What could be the problem?

lopippo commented 7 years ago

Are you sure you should not put that .clang-format file in the source directory?

rhysd commented 7 years ago

Please give me the information which enables me to reproduce the problem. At least in my environment it looks working.

andmer commented 7 years ago

i have a .clang_format in ~/.clang_format does it pick up that global config if no local one is present in CWD?

k-o-ta commented 7 years ago

I'd had the same problem when using vim-clang and vim-clang-format together.

Vim-clang and vim-calng-format use same command(ClangFormat). In my environment, ClangFormat command invokes vim-clang's ClangFormat and vim-clang's 'ClangFormta' uses LLVM style by default

let g:clang_enable_format_command = 0 inhibits vim-clang's ClangFormat and have solved my problem. https://github.com/justmao945/vim-clang/blob/master/plugin/clang.vim#L69-L71

1pakch commented 6 years ago

I also observe that vim-clang-format does not pick up ~/.clang_format which is picked up if I run clang-format tool by myself.

ghost commented 6 years ago

if I set this in my ~/.vimrc file

then, vim-clang-format finds .clang-format from current working directory toward it's ancestors? or it only checks the current working directory?


from README

When this variable's value is 1, vim-clang-format automatically detects(<-how does this work?) the style file like .clang-format or _clang-format and applies the style to formatting.

r7vme commented 5 years ago

I also came across similar issue. My root cause was that default style used by plugin is google (g:clang_format#code_style) instead of LLVM system-wide.

So to switch to file:

  1. clang-format -style=Google -dump-config > ~/.clang-format
  2. update ~/.clang-format with values from g:clang_format#style_options