2017-06-07 13:02:29 +00:00
|
|
|
" Author: w0rp <devw0rp@gmail.com>
|
|
|
|
" Description: Fixing Python imports with isort.
|
|
|
|
|
2017-06-18 10:03:31 +00:00
|
|
|
call ale#Set('python_isort_executable', 'isort')
|
2018-04-09 18:11:20 +00:00
|
|
|
call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0))
|
2017-06-18 10:03:31 +00:00
|
|
|
|
2017-06-07 13:02:29 +00:00
|
|
|
function! ale#fixers#isort#Fix(buffer) abort
|
2017-06-18 10:03:31 +00:00
|
|
|
let l:executable = ale#python#FindExecutable(
|
|
|
|
\ a:buffer,
|
|
|
|
\ 'python_isort',
|
2017-07-05 12:07:55 +00:00
|
|
|
\ ['isort'],
|
2017-06-18 10:03:31 +00:00
|
|
|
\)
|
|
|
|
|
2017-11-04 10:46:19 +00:00
|
|
|
if !executable(l:executable)
|
2017-06-07 19:42:30 +00:00
|
|
|
return 0
|
|
|
|
endif
|
|
|
|
|
2017-06-07 13:02:29 +00:00
|
|
|
return {
|
2018-02-04 13:16:44 +00:00
|
|
|
\ 'command': ale#path#BufferCdString(a:buffer)
|
|
|
|
\ . ale#Escape(l:executable) . ' -',
|
2017-06-07 13:02:29 +00:00
|
|
|
\}
|
|
|
|
endfunction
|