summaryrefslogtreecommitdiff
path: root/autoload/ale/fixers/isort.vim
blob: 9070fb274ee6ce5dc9a0f75caf57e29401d6a174 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
" Author: w0rp <devw0rp@gmail.com>
" Description: Fixing Python imports with isort.

call ale#Set('python_isort_executable', 'isort')
call ale#Set('python_isort_options', '')
call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0))

function! ale#fixers#isort#Fix(buffer) abort
    let l:options = ale#Var(a:buffer, 'python_isort_options')

    let l:executable = ale#python#FindExecutable(
    \   a:buffer,
    \   'python_isort',
    \   ['isort'],
    \)

    if !executable(l:executable)
        return 0
    endif

    return {
    \   'command': ale#path#BufferCdString(a:buffer)
    \   .   ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -',
    \}
endfunction