diff --git a/README.md b/README.md index 7ed0c91..64a8bd4 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,19 @@ Here is a list of formatprograms that are supported by default, and thus will be Here is the link to the repository: https://github.com/hhatto/autopep8. And here the link to its page on the python website: http://pypi.python.org/pypi/autopep8/0.5.2. +* `yapf` for __Python__ (supports formatting ranges). + It is readily available through PIP. Most users can install with the terminal command `sudo pip install yapf` or `pip --user install yapf`. + YAPF has one optional configuration variable to control the formatter style. + For example: + + ```vim + let g:formatter_yapf_style = 'pep8' + ``` + + `pep8` is the default value, or you can choose: `google`, `facebook`, `chromium`. + + Here is the link to the repository: https://github.com/google/yapf + * `js-beautify` for __Javascript__ and __JSON__. It can be installed by running `npm install -g js-beautify`. Note that `nodejs` is needed for this to work. @@ -274,6 +287,9 @@ contact me by creating an issue in this repository. ## Change log +### April 2016 +* Add `yapf` as a secondary Python formatter. + ### March 2016 * Add more fallback options. * Don't use the option formatprg at all, to always have the possible of using the default `gq` diff --git a/plugin/defaults.vim b/plugin/defaults.vim index ff5bfcd..b8ccee2 100644 --- a/plugin/defaults.vim +++ b/plugin/defaults.vim @@ -37,8 +37,16 @@ function! g:DoesRangeEqualBuffer(first, last) return line('$') != a:last - a:first + 1 endfunction +" Yapf supports multiple formatter styles: pep8, google, chromium, or facebook +if !exists('g:formatter_yapf_style') + let g:formatter_yapf_style = 'pep8' +endif +if !exists('g:formatdef_yapf') + let g:formatdef_yapf = "'yapf --style={based_on_style:'.g:formatter_yapf_style.',indent_width:'.&shiftwidth.'} -l '.a:firstline.'-'.a:lastline" +endif + if !exists('g:formatters_python') - let g:formatters_python = ['autopep8'] + let g:formatters_python = ['autopep8','yapf'] endif