neoclide / coc-python

Python extension for coc.nvim, fork of vscode-python
574 stars 51 forks source link

Sort imports on save #163

Closed Rizhiy closed 4 years ago

Rizhiy commented 4 years ago

Is there an option to sort imports on save, similar to format on save? If not, would be nice to add it.

chemzqm commented 4 years ago

No, You have to create a autocmd yourself.

lsaint commented 4 years ago

autocmd BufWritePre *.py :CocCommand python.sortImports

every time i save the file, it show the message:

[coc.nvim] changed 1 buffers, use :wa to save changes to disk or :copen to open quickfix list

i need to save it another time to take effect. can i make it auto save changes to disk?

chemzqm commented 4 years ago

i need to save it another time to take effect.

Hm, it should not. My advice is never use it on save, it has side effect and could change all your buffers.

cristicbz commented 4 years ago

@chemzqm sorting imports doesn't have side effects, right? only organizing i.e removing unused imports would