#659 - Add options for Python fixers, and cut down on duplicated documentation

This commit is contained in:
w0rp
2017-06-18 11:03:31 +01:00
parent fb682be199
commit 629ff513ec
18 changed files with 287 additions and 217 deletions

View File

@@ -9,27 +9,6 @@ let g:ale_virtualenv_dir_names = get(g:, 'ale_virtualenv_dir_names', [
\ 'virtualenv',
\])
" Given a buffer number and a command name, find the path to the executable.
" First search on a virtualenv for Python, if nothing is found, try the global
" command. Returns an empty string if cannot find the executable
function! ale#python#GetExecutable(buffer, cmd_name) abort
let l:virtualenv = ale#python#FindVirtualenv(a:buffer)
if !empty(l:virtualenv)
let l:ve_executable = l:virtualenv . '/bin/' . a:cmd_name
if executable(l:ve_executable)
return l:ve_executable
endif
endif
if executable(a:cmd_name)
return a:cmd_name
endif
return ''
endfunction
" Given a buffer number, find the project root directory for Python.
" The root directory is defined as the first directory found while searching
" upwards through paths, including the current directory, until a path
@@ -58,3 +37,32 @@ function! ale#python#FindVirtualenv(buffer) abort
return ''
endfunction
" Given a buffer number and a command name, find the path to the executable.
" First search on a virtualenv for Python, if nothing is found, try the global
" command. Returns an empty string if cannot find the executable
function! ale#python#FindExecutable(buffer, base_var_name, path_list) abort
if ale#Var(a:buffer, a:base_var_name . '_use_global')
return ale#Var(a:buffer, a:base_var_name . '_executable')
endif
let l:virtualenv = ale#python#FindVirtualenv(a:buffer)
if !empty(l:virtualenv)
for l:path in a:path_list
let l:ve_executable = l:virtualenv . l:path
if executable(l:ve_executable)
return l:ve_executable
endif
endfor
endif
let l:global_executable = ale#Var(a:buffer, a:base_var_name . '_executable')
if executable(l:global_executable)
return l:global_executable
endif
return ''
endfunction