Move formatexpr config in-tree, out of plugin

Introduces the `format` Python module which provides `clang_format()`
and `yapf()` functions which efficiently (compared to vimscript) invoke
`clang-format` or `yapf` respectively then apply the minimal number of
changes using `difflib.SequenceMatcher`.

Additionally, in order to invoke these Python functions add |autoload|
functions `format#clang_format()` and `format#yapf()` which can be
directly used by the 'formatexpr' setting.

Finally, add |ftplugin| files which set 'formatexpr' when the |autoload|
functions are available.
This commit is contained in:
2021-03-24 23:37:19 +00:00
parent 4e00e225d4
commit 46d27c17fd
12 changed files with 163 additions and 3 deletions

8
plugin/format.vim Normal file
View File

@@ -0,0 +1,8 @@
if !has('pythonx')
finish
endif
let g:clang_format_path = get(g:, 'clang_format_path', 'clang-format')
let g:clang_format_style = get(g:, 'clang_format_style', 'google')
let g:yapf_path = get(g:, 'yapf_path', 'yapf')
let g:yapf_style = get(g:, 'yapf_style', 'pep8')