vim-clang-format icon indicating copy to clipboard operation
vim-clang-format copied to clipboard

.clang_format style file not used

Open CodingJonas opened this issue 9 years ago • 7 comments

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?

CodingJonas avatar Oct 12 '16 11:10 CodingJonas

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

lopippo avatar Dec 19 '16 12:12 lopippo

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

rhysd avatar Dec 21 '16 10:12 rhysd

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

andmer avatar Feb 06 '17 20:02 andmer

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

k-o-ta avatar Feb 19 '17 04:02 k-o-ta

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.

1pakch avatar May 02 '18 09:05 1pakch

if I set this in my ~/.vimrc file

  • let g:clang_format#detect_style_file = 1

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

  • g:clang_format#detect_style_file

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.

ghost avatar Aug 30 '18 14:08 ghost

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

r7vme avatar Oct 05 '19 10:10 r7vme