mirror of https://github.com/dense-analysis/ale
#563 Use a configurable list of directories for detecting virtualenv paths instead.
This commit is contained in:
parent
d012fd1f09
commit
65fbf1cdff
|
@ -1,6 +1,15 @@
|
|||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: Functions for integrating with Python linters.
|
||||
|
||||
let g:ale_virtualenv_dir_names = get(g:, 'ale_virtualenv_dir_names', [
|
||||
\ '.env',
|
||||
\ 'env',
|
||||
\ 've',
|
||||
\ 've-py3',
|
||||
\ 'virtualenv',
|
||||
\])
|
||||
|
||||
|
||||
" 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
|
||||
|
@ -18,12 +27,14 @@ endfunction
|
|||
" Given a buffer number, find a virtualenv path for Python.
|
||||
function! ale#python#FindVirtualenv(buffer) abort
|
||||
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
|
||||
let l:matches = globpath(l:path, '*/bin/activate', 0, 1)
|
||||
for l:dirname in ale#Var(a:buffer, 'virtualenv_dir_names')
|
||||
let l:venv_dir = l:path . '/' . l:dirname
|
||||
|
||||
if !empty(l:matches)
|
||||
return fnamemodify(l:matches[-1], ':h:h')
|
||||
if filereadable(l:venv_dir . '/bin/activate')
|
||||
return l:venv_dir
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
|
|
@ -2,6 +2,21 @@
|
|||
ALE Python Integration *ale-python-options*
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Global Options
|
||||
|
||||
g:ale_virtualenv_dir_names *g:ale_virtualenv_dir_names*
|
||||
*b:ale_virtualenv_dir_names*
|
||||
|
||||
Type: |List|
|
||||
Default: `['.env', 'env', 've', 've-py3', 'virtualenv']`
|
||||
|
||||
A list of directory names to be used when searching upwards from Python
|
||||
files to discover virtulenv directories with. For directory named `'foo'`,
|
||||
ALE will search for `'foo/bin/activate'` in all directories on and above
|
||||
the directory containing the Python file to find virtualenv paths.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
flake8 *ale-python-flake8*
|
||||
|
||||
|
|
Loading…
Reference in New Issue