summaryrefslogtreecommitdiff
path: root/autoload/ale/fixers/reorder_python_imports.vim
blob: 42a0a6e286eff3ba215798fc01fa89f78718f7b0 (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: jake <me@jake.computer>
" Description: Fixing Python imports with reorder-python-imports.

call ale#Set('python_reorder_python_imports_executable', 'reorder-python-imports')
call ale#Set('python_reorder_python_imports_options', '')
call ale#Set('python_reorder_python_imports_use_global', get(g:, 'ale_use_global_executables', 0))

function! ale#fixers#reorder_python_imports#Fix(buffer) abort
    let l:executable = ale#python#FindExecutable(
    \   a:buffer,
    \   'python_reorder_python_imports',
    \   ['reorder-python-imports'],
    \)

    if !executable(l:executable)
        return 0
    endif

    let l:options = ale#Var(a:buffer, 'python_reorder_python_imports_options')

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