1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-14 23:49:19 +08:00

Update python format option (#3452)

close #3429
This commit is contained in:
Wang Shidong 2020-04-16 22:56:26 +08:00 committed by GitHub
parent 4baf76d542
commit c2ed7ac502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View File

@ -140,7 +140,7 @@ function! s:language_specified_mappings() abort
if s:format_on_save
augroup SpaceVim_layer_lang_python
autocmd!
autocmd BufWritePost *.py Neoformat yapf
autocmd BufWritePre *.py undojoin | Neoformat
augroup end
endif

View File

@ -73,6 +73,17 @@ pip install --user flake8
pip install --user yapf
```
如果需要使用其他命令作为格式化工具,比如`black`命令,可以在启动函数中进行配置:
```viml
let g:neoformat_python_black = {
\ 'exe': 'black',
\ 'stdin': 1,
\ 'args': ['-q', '-'],
\ }
let g:neoformat_enabled_python = ['black']
```
**格式化导包:**
若需要更便捷地删除未使用的 imports需要安装 [autoflake](https://github.com/myint/autoflake)

View File

@ -72,6 +72,18 @@ load this layer with setting `format_on_save` to `1`.
pip install --user yapf
```
To use other tool as the format command, for example `black`, change the neoformat option in bootstrap
function.
```viml
let g:neoformat_python_black = {
\ 'exe': 'black',
\ 'stdin': 1,
\ 'args': ['-q', '-'],
\ }
let g:neoformat_enabled_python = ['black']
```
**format imports:**
To be able to suppress unused imports easily, install [autoflake](https://github.com/myint/autoflake):