Skip to content

Commit c289243

Browse files
committed
search style file in parent directories (Issue #6)
1 parent e9117b3 commit c289243

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

autoload/clang_format.vim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,18 @@ endif
117117
" format codes {{{
118118
function! s:detect_style_file()
119119
let dirname = expand('%:p:h')
120-
let dotfiles = map(split(globpath(dirname, '.*', 1), "\n"), 'filereadable(v:val)')
121120
let style_file_name = has('win32') || has('win64') ? '_clang-format' : '.clang-format'
122-
return filter(dotfiles, 'fnamemodify(v:val, ":t") ==# style_file_name') != []
121+
return findfile(style_file_name, dirname.';') != ''
123122
endfunction
124123

125124
function! clang_format#format(line1, line2)
126125
let args = printf(" -lines=%d:%d", a:line1, a:line2)
127126
if ! (g:clang_format#detect_style_file && s:detect_style_file())
128-
let args .= printf(" -style=%s", s:make_style_options())
127+
let args .= printf(" -style=%s ", s:make_style_options())
128+
else
129+
let args .= " -style=file "
129130
endif
130-
let args .= ' ' . g:clang_format#extra_args
131+
let args .= g:clang_format#extra_args
131132
let clang_format = printf("%s %s --", g:clang_format#command, args)
132133
return s:system(clang_format, join(getline(1, '$'), "\n"))
133134
endfunction

0 commit comments

Comments
 (0)