summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorAiden Scandella <git@sca.ndella.com>2019-01-30 07:57:58 -0800
committerAiden Scandella <git@sca.ndella.com>2019-01-30 14:44:38 -0800
commitde29ff26ff536dbb99c57fc5f20ec6ee0b17a6c6 (patch)
treed26f9a667b2f091f9f7f7e4b0e172cdc2e3e4022 /autoload
parent067601e9db7e0c2ab6c8394c9be74769463c6da9 (diff)
downloadale-de29ff26ff536dbb99c57fc5f20ec6ee0b17a6c6.zip
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
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fixers/black.vim7
1 files changed, 6 insertions, 1 deletions
diff --git a/autoload/ale/fixers/black.vim b/autoload/ale/fixers/black.vim
index 27249c55..367b8d52 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_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 : '')
\ . ' -',
\}