diff options
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fixers/black.vim | 8 | ||||
-rw-r--r-- | autoload/ale/python.vim | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/autoload/ale/fixers/black.vim b/autoload/ale/fixers/black.vim index 142cd983..4a88c5cd 100644 --- a/autoload/ale/fixers/black.vim +++ b/autoload/ale/fixers/black.vim @@ -5,6 +5,7 @@ call ale#Set('python_black_executable', 'black') call ale#Set('python_black_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_black_options', '') call ale#Set('python_black_auto_pipenv', 0) +call ale#Set('python_black_auto_poetry', 0) call ale#Set('python_black_change_directory', 1) function! ale#fixers#black#GetExecutable(buffer) abort @@ -13,6 +14,11 @@ function! ale#fixers#black#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_black_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_black', ['black']) endfunction @@ -20,7 +26,7 @@ function! ale#fixers#black#Fix(buffer) abort let l:executable = ale#fixers#black#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv$' + if l:executable =~? 'pipenv\|poetry$' call extend(l:cmd, ['run', 'black']) endif diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim index 40433d17..ee856a27 100644 --- a/autoload/ale/python.vim +++ b/autoload/ale/python.vim @@ -2,6 +2,7 @@ " Description: Functions for integrating with Python linters. call ale#Set('python_auto_pipenv', '0') +call ale#Set('python_auto_poetry', '0') let s:sep = has('win32') ? '\' : '/' " bin is used for Unix virtualenv directories, and Scripts is for Windows. @@ -158,3 +159,8 @@ endfunction function! ale#python#PipenvPresent(buffer) abort return findfile('Pipfile.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# '' endfunction + +" Detects whether a poetry environment is present. +function! ale#python#PoetryPresent(buffer) abort + return findfile('poetry.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# '' +endfunction |