diff --git a/README.md b/README.md index f753bee..67c1e9d 100644 --- a/README.md +++ b/README.md @@ -137,8 +137,7 @@ Here is a list of formatprograms that are supported by default, and thus will be * `yapf` for __Python__ (supports formatting ranges). Vim-autoformat checks whether there exists a `.style.yapf` or a `setup.cfg` file up in the current directory's ancestry. Based on that it either uses that file or tries to match vim options as much as possible. - It is readily available through PIP. - Most users can install with the terminal command `sudo pip install yapf` or `pip install --user yapf`. + Most users can install with the terminal command `sudo pip install yapf` or `pip install --user yapf`. YAPF has one optional configuration variable to control the formatter style. For example: @@ -150,6 +149,10 @@ 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/google/yapf +* `black` for __Python__. + Most users can install with the terminal command `sudo pip install black` or `pip install --user black`. + Here is the link to the repository: https://github.com/ambv/black + * `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. diff --git a/plugin/defaults.vim b/plugin/defaults.vim index 0588dcf..01a3218 100644 --- a/plugin/defaults.vim +++ b/plugin/defaults.vim @@ -52,8 +52,12 @@ function! g:YAPFFormatConfigFileExists() return len(findfile(".style.yapf", expand("%:p:h").";")) || len(findfile("setup.cfg", expand("%:p:h").";")) || filereadable(exists('$XDG_CONFIG_HOME') ? expand('$XDG_CONFIG_HOME/yapf/style') : expand('~/.config/yapf/style')) endfunction +if !exists('g:formatdef_black') + let g:formatdef_black = '"black -q ".(&textwidth ? "-l".&textwidth : "")." -"' +endif + if !exists('g:formatters_python') - let g:formatters_python = ['autopep8','yapf'] + let g:formatters_python = ['autopep8','yapf', 'black'] endif