mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 23:49:19 +08:00
parent
4baf76d542
commit
c2ed7ac502
@ -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
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user