All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: infokiller <joweill@icloud.com>
2 " Description: Tidy imports using pyflyby's tidy-import script
3 " https://github.com/deshaw/pyflyby
5 call ale#Set('python_pyflyby_executable', 'tidy-imports')
6 call ale#Set('python_pyflyby_use_global', get(g:, 'ale_use_global_executables', 0))
7 call ale#Set('python_pyflyby_options', '')
8 call ale#Set('python_pyflyby_auto_pipenv', 0)
9 call ale#Set('python_pyflyby_auto_poetry', 0)
10 call ale#Set('python_pyflyby_auto_uv', 0)
12 function! ale#fixers#pyflyby#GetExecutable(buffer) abort
13 if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflyby_auto_pipenv'))
14 \ && ale#python#PipenvPresent(a:buffer)
18 if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyflyby_auto_poetry'))
19 \ && ale#python#PoetryPresent(a:buffer)
23 if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pyflyby_auto_uv'))
24 \ && ale#python#UvPresent(a:buffer)
28 return ale#python#FindExecutable(a:buffer, 'python_pyflyby', ['tidy-imports'])
31 function! ale#fixers#pyflyby#Fix(buffer) abort
32 " let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer)
33 let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer)
34 let l:cmd = [ale#Escape(l:executable)]
36 if l:executable =~? '\(pipenv\|poetry\|uv\)$'
37 call extend(l:cmd, ['run', 'tidy-imports'])
40 let l:options = ale#Var(a:buffer, 'python_pyflyby_options')
43 call add(l:cmd, l:options)
46 return {'command': join(l:cmd, ' ')}