Make clang config finder relative to buffer file.
This commit is contained in:
parent
d704fd1647
commit
ac1aa285a3
@ -27,11 +27,11 @@ endif
|
|||||||
if !exists('g:formatdef_clangformat')
|
if !exists('g:formatdef_clangformat')
|
||||||
let s:configfile_def = "'clang-format -lines='.a:firstline.':'.a:lastline.' --assume-filename='.bufname('%').' -style=file'"
|
let s:configfile_def = "'clang-format -lines='.a:firstline.':'.a:lastline.' --assume-filename='.bufname('%').' -style=file'"
|
||||||
let s:noconfigfile_def = "'clang-format -lines='.a:firstline.':'.a:lastline.' --assume-filename='.bufname('%').' -style=\"{BasedOnStyle: WebKit, AlignTrailingComments: true, '.(&textwidth ? 'ColumnLimit: '.&textwidth.', ' : '').(&expandtab ? 'UseTab: Never, IndentWidth: '.shiftwidth() : 'UseTab: Always').'}\"'"
|
let s:noconfigfile_def = "'clang-format -lines='.a:firstline.':'.a:lastline.' --assume-filename='.bufname('%').' -style=\"{BasedOnStyle: WebKit, AlignTrailingComments: true, '.(&textwidth ? 'ColumnLimit: '.&textwidth.', ' : '').(&expandtab ? 'UseTab: Never, IndentWidth: '.shiftwidth() : 'UseTab: Always').'}\"'"
|
||||||
let g:formatdef_clangformat = "g:ClangConfigFileExists() ? (" . s:configfile_def . ") : (" . s:noconfigfile_def . ")"
|
let g:formatdef_clangformat = "g:ClangFormatConfigFileExists() ? (" . s:configfile_def . ") : (" . s:noconfigfile_def . ")"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! g:ClangConfigFileExists()
|
function! g:ClangFormatConfigFileExists()
|
||||||
return len(findfile(".clang-format", ".;")) || len(findfile("_clang-format", ".;"))
|
return len(findfile(".clang-format", expand("%:p:h").";")) || len(findfile("_clang-format", expand("%:p:h").";"))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user