defaults/yapf: handle yapf config file
YAPF has clang-format like config file for customisation of the applied style. vim-autoformat was previously ignoring any user customisation.
This commit is contained in:
parent
8d2809242c
commit
3e7f7a6874
@ -42,9 +42,15 @@ if !exists('g:formatter_yapf_style')
|
|||||||
let g:formatter_yapf_style = 'pep8'
|
let g:formatter_yapf_style = 'pep8'
|
||||||
endif
|
endif
|
||||||
if !exists('g:formatdef_yapf')
|
if !exists('g:formatdef_yapf')
|
||||||
let g:formatdef_yapf = "'yapf --style=\"{based_on_style:'.g:formatter_yapf_style.',indent_width:'.&shiftwidth.(&textwidth ? ',column_limit:'.&textwidth : '').'}\" -l '.a:firstline.'-'.a:lastline"
|
let s:configfile_def = "'yapf -l '.a:firstline.'-'.a:lastline"
|
||||||
|
let s:noconfigfile_def = "'yapf --style=\"{based_on_style:'.g:formatter_yapf_style.',indent_width:'.&shiftwidth.'}\" -l '.a:firstline.'-'.a:lastline"
|
||||||
|
let g:formatdef_yapf = "g:YAPFFormatConfigFileExists() ? (" . s:configfile_def . ") : (" . s:noconfigfile_def . ")"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
function! g:YAPFFormatConfigFileExists()
|
||||||
|
return len(findfile(".style.yapf", expand("%:p:h").";")) || len(findfile("setup.cfg", expand("%:p:h").";"))
|
||||||
|
endfunction
|
||||||
|
|
||||||
if !exists('g:formatters_python')
|
if !exists('g:formatters_python')
|
||||||
let g:formatters_python = ['autopep8','yapf']
|
let g:formatters_python = ['autopep8','yapf']
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user