mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-28 04:22:27 +08:00
#2172 Auto PATH with ale_python_auto_virtualenv
Automatically set `PATH` for some Python linters that seem to need it when g:ale_python_auto_virtualenv or b:ale_python_auto_virtualenv is `1`.
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('python', 'pylsp')
|
||||
Save b:ale_python_auto_virtualenv
|
||||
|
||||
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
|
||||
|
||||
After:
|
||||
unlet! b:bin_dir
|
||||
unlet! b:venv_bin
|
||||
unlet! b:sep
|
||||
unlet! b:executable
|
||||
|
||||
call ale#assert#TearDownLinterTest()
|
||||
@@ -40,6 +43,17 @@ Execute(The pylsp executable should be run from the virtualenv path):
|
||||
AssertEqual ale#Escape(b:executable),
|
||||
\ ale_linters#python#pylsp#GetCommand(bufnr(''))
|
||||
|
||||
Execute(virtualenv vars should be used when ale_python_auto_virtualenv = 1):
|
||||
let b:ale_python_auto_virtualenv = 1
|
||||
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
let b:venv_bin = ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir)
|
||||
let b:sep = has('win32') ? ';' : ':'
|
||||
let b:executable = ale#path#Simplify(b:venv_bin . '/pylsp')
|
||||
|
||||
AssertLinter b:executable, ale#Env('PATH', b:venv_bin . b:sep . $PATH)
|
||||
\ . ale#Escape(b:executable)
|
||||
|
||||
Execute(You should be able to override the pylsp virtualenv lookup):
|
||||
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user