mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-23 12:31:30 +08:00
Respect python black fixer configuration file
Similar to other linters/fixers, by default change to the directory of the file being fixed before invoking `black`, which allows the tool to read project-specific configuration (pyproject.toml) Fixes #2218
This commit is contained in:
@@ -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_change_directory', 1)
|
||||
|
||||
function! ale#fixers#black#GetExecutable(buffer) abort
|
||||
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_black_auto_pipenv'))
|
||||
@@ -16,6 +17,10 @@ function! ale#fixers#black#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#black#Fix(buffer) abort
|
||||
let l:cd_string = ale#Var(a:buffer, 'python_black_change_directory')
|
||||
\ ? ale#path#BufferCdString(a:buffer)
|
||||
\ : ''
|
||||
|
||||
let l:executable = ale#fixers#black#GetExecutable(a:buffer)
|
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv$'
|
||||
@@ -25,7 +30,7 @@ function! ale#fixers#black#Fix(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'python_black_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . l:exec_args
|
||||
\ 'command': l:cd_string . ale#Escape(l:executable) . l:exec_args
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -',
|
||||
\}
|
||||
|
||||
Reference in New Issue
Block a user