Merge pull request #252 from Chiel92/add-black
Add basic definition for black formatter.
This commit is contained in:
commit
eda08fa331
@ -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).
|
* `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.
|
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.
|
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.
|
YAPF has one optional configuration variable to control the formatter style.
|
||||||
For example:
|
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
|
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__.
|
* `js-beautify` for __Javascript__ and __JSON__.
|
||||||
It can be installed by running `npm install -g js-beautify`.
|
It can be installed by running `npm install -g js-beautify`.
|
||||||
Note that `nodejs` is needed for this to work.
|
Note that `nodejs` is needed for this to work.
|
||||||
|
@ -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'))
|
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
|
endfunction
|
||||||
|
|
||||||
|
if !exists('g:formatdef_black')
|
||||||
|
let g:formatdef_black = '"black -q ".(&textwidth ? "-l".&textwidth : "")." -"'
|
||||||
|
endif
|
||||||
|
|
||||||
if !exists('g:formatters_python')
|
if !exists('g:formatters_python')
|
||||||
let g:formatters_python = ['autopep8','yapf']
|
let g:formatters_python = ['autopep8','yapf', 'black']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user