diff options
author | Horacio Sanson <hsanson@gmail.com> | 2021-09-10 15:18:41 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-10 15:18:41 +0900 |
commit | bf29f6ea92ff993d5d96bc4e760f315e95e332a5 (patch) | |
tree | ec1b80c3128da0dbc18fcdcb1174390d447f4b52 /autoload | |
parent | b504eeb094b26a635f260a92e0b9762ad2eb1862 (diff) | |
download | ale-bf29f6ea92ff993d5d96bc4e760f315e95e332a5.zip |
Fix 3897 - add poetry to isort (#3898)
Co-authored-by: Horacio Sanson <horacio@allm.inc>
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fixers/isort.vim | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/autoload/ale/fixers/isort.vim b/autoload/ale/fixers/isort.vim index a640d233..082e77ec 100644 --- a/autoload/ale/fixers/isort.vim +++ b/autoload/ale/fixers/isort.vim @@ -5,6 +5,7 @@ call ale#Set('python_isort_executable', 'isort') call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_isort_options', '') call ale#Set('python_isort_auto_pipenv', 0) +call ale#Set('python_isort_auto_poetry', 0) function! ale#fixers#isort#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_isort_auto_pipenv')) @@ -12,24 +13,34 @@ function! ale#fixers#isort#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_isort_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_isort', ['isort']) endfunction function! ale#fixers#isort#Fix(buffer) abort - let l:options = ale#Var(a:buffer, 'python_isort_options') let l:executable = ale#fixers#isort#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv$' - \ ? ' run isort' - \ : '' + let l:cmd = [ale#Escape(l:executable)] - if !executable(l:executable) && l:executable isnot# 'pipenv' - return 0 + if l:executable =~? 'pipenv\|poetry$' + call extend(l:cmd, ['run', 'isort']) endif + call add(l:cmd, '--filename %s') + + let l:options = ale#Var(a:buffer, 'python_isort_options') + + if !empty(l:options) + call add(l:cmd, l:options) + endif + + call add(l:cmd, '-') + return { \ 'cwd': '%s:h', - \ 'command': ale#Escape(l:executable) . l:exec_args - \ . ale#Pad('--filename %s') - \ . (!empty(l:options) ? ' ' . l:options : '') . ' -', + \ 'command': join(l:cmd, ' ') \} endfunction |