fisadev / vim-isort

Vim plugin to sort python imports using https://github.com/timothycrosley/isort
MIT License
219 stars 32 forks source link

Do not rewrite buffer if nothing is changed. #28

Closed daliusd closed 5 years ago

daliusd commented 5 years ago

I want to use isort on each save/write to file therefore I use following configuration:

:autocmd BufWritePre *.py :Isort

This has one problem however. Even if nothing is changed my cursor jumps back to the beginning of file. This is not ideal fix but it is better than nothing. I think ideal fix would save and restore cursor position.

qbedard commented 5 years ago

Assuming this comparison is pretty quick, it's probably good to have regardless.

However, if the concern is the cursor position, we could add some additional logic to try and return to the last cursor position if possible:

Option 1:

Option 2:

Neither of these account for pushing imports from deeper in the code up to the top though.

daliusd commented 5 years ago

Honestly, I have found out that ale (https://github.com/w0rp/ale) has isort fixer and does everything what I need. Meanwhile this project actually looks dead.

fisadev commented 5 years ago

Thanks for the work on this! and really sorry for the time this has been dead, personal things getting in the way of me contributing too much to OSS. Getting back to it :)