summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fixers/black.vim22
1 files changed, 16 insertions, 6 deletions
diff --git a/autoload/ale/fixers/black.vim b/autoload/ale/fixers/black.vim
index 4169322a..7523bcae 100644
--- a/autoload/ale/fixers/black.vim
+++ b/autoload/ale/fixers/black.vim
@@ -4,22 +4,32 @@
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)
+
+function! ale#fixers#black#GetExecutable(buffer) abort
+ if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_black_auto_pipenv'))
+ \ && ale#python#PipenvPresent(a:buffer)
+ return 'pipenv'
+ endif
+
+ return ale#python#FindExecutable(a:buffer, 'python_black', ['black'])
+endfunction
function! ale#fixers#black#Fix(buffer) abort
- let l:executable = ale#python#FindExecutable(
- \ a:buffer,
- \ 'python_black',
- \ ['black'],
- \)
+ let l:executable = ale#fixers#black#GetExecutable(a:buffer)
if !executable(l:executable)
return 0
endif
+ let l:exec_args = l:executable =~? 'pipenv$'
+ \ ? ' run black'
+ \ : ''
+
let l:options = ale#Var(a:buffer, 'python_black_options')
return {
- \ 'command': ale#Escape(l:executable)
+ \ 'command': ale#Escape(l:executable) . l:exec_args
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' -',
\}