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:
3
ftplugin/c.vim
Normal file
3
ftplugin/c.vim
Normal file
@@ -0,0 +1,3 @@
|
||||
if has('pythonx')
|
||||
set formatexpr=format#clang_format()
|
||||
endif
|
||||
3
ftplugin/cpp.vim
Normal file
3
ftplugin/cpp.vim
Normal file
@@ -0,0 +1,3 @@
|
||||
if has('pythonx')
|
||||
set formatexpr=format#clang_format()
|
||||
endif
|
||||
3
ftplugin/java.vim
Normal file
3
ftplugin/java.vim
Normal file
@@ -0,0 +1,3 @@
|
||||
if has('pythonx')
|
||||
set formatexpr=format#clang_format()
|
||||
endif
|
||||
3
ftplugin/javascript.vim
Normal file
3
ftplugin/javascript.vim
Normal file
@@ -0,0 +1,3 @@
|
||||
if has('pythonx')
|
||||
set formatexpr=format#clang_format()
|
||||
endif
|
||||
3
ftplugin/objc.vim
Normal file
3
ftplugin/objc.vim
Normal file
@@ -0,0 +1,3 @@
|
||||
if has('pythonx')
|
||||
set formatexpr=format#clang_format()
|
||||
endif
|
||||
3
ftplugin/objcpp.vim
Normal file
3
ftplugin/objcpp.vim
Normal file
@@ -0,0 +1,3 @@
|
||||
if has('pythonx')
|
||||
set formatexpr=format#clang_format()
|
||||
endif
|
||||
3
ftplugin/proto.vim
Normal file
3
ftplugin/proto.vim
Normal file
@@ -0,0 +1,3 @@
|
||||
if has('pythonx')
|
||||
set formatexpr=format#clang_format()
|
||||
endif
|
||||
3
ftplugin/python.vim
Normal file
3
ftplugin/python.vim
Normal file
@@ -0,0 +1,3 @@
|
||||
if has('pythonx')
|
||||
set formatexpr=format#yapf()
|
||||
endif
|
||||
Reference in New Issue
Block a user