Merge pull request #1698 from dsifford/dsifford-isort-options
add options variable to isort
This commit is contained in:
commit
d49daeb816
@ -2,9 +2,12 @@
|
||||
" Description: Fixing Python imports with isort.
|
||||
|
||||
call ale#Set('python_isort_executable', 'isort')
|
||||
call ale#Set('python_isort_options', '')
|
||||
call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale#fixers#isort#Fix(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'python_isort_options')
|
||||
|
||||
let l:executable = ale#python#FindExecutable(
|
||||
\ a:buffer,
|
||||
\ 'python_isort',
|
||||
@ -17,6 +20,6 @@ function! ale#fixers#isort#Fix(buffer) abort
|
||||
|
||||
return {
|
||||
\ 'command': ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(l:executable) . ' -',
|
||||
\ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -',
|
||||
\}
|
||||
endfunction
|
||||
|
@ -145,6 +145,14 @@ g:ale_python_isort_executable *g:ale_python_isort_executable*
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
g:ale_python_isort_options *g:ale_python_isort_options*
|
||||
*b:ale_python_isort_options*
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
This variable can be set to pass extra options to isort.
|
||||
|
||||
|
||||
g:ale_python_isort_use_global *g:ale_python_isort_use_global*
|
||||
*b:ale_python_isort_use_global*
|
||||
Type: |Number|
|
||||
|
@ -1,5 +1,6 @@
|
||||
Before:
|
||||
Save g:ale_python_isort_executable
|
||||
Save g:ale_python_isort_options
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_python_isort_executable = 'xxxinvalid'
|
||||
@ -30,3 +31,19 @@ Execute(The isort callback should return the correct default values):
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/isort')) . ' -',
|
||||
\ },
|
||||
\ ale#fixers#isort#Fix(bufnr(''))
|
||||
|
||||
Execute(The isort callback should respect custom options):
|
||||
let g:ale_python_isort_options = '--multi-line=3 --trailing-comma'
|
||||
|
||||
AssertEqual
|
||||
\ 0,
|
||||
\ ale#fixers#isort#Fix(bufnr(''))
|
||||
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir/foo')) . ' && '
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/isort'))
|
||||
\ . ' --multi-line=3 --trailing-comma -',
|
||||
\ },
|
||||
\ ale#fixers#isort#Fix(bufnr(''))
|
||||
|
Loading…
Reference in New Issue
Block a user