Escape the pyls executable in the command, and support running virtualenv pyls executables
This commit is contained in:
parent
e6fb32b792
commit
52f3ad7c75
@ -2,9 +2,16 @@
|
||||
" Description: A language server for Python
|
||||
|
||||
call ale#Set('python_pyls_executable', 'pyls')
|
||||
call ale#Set('python_pyls_use_global', 0)
|
||||
|
||||
function! ale_linters#python#pyls#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'python_pyls_executable')
|
||||
return ale#python#FindExecutable(a:buffer, 'python_pyls', ['pyls'])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#pyls#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#python#pyls#GetExecutable(a:buffer)
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#pyls#GetLanguage(buffer) abort
|
||||
@ -15,7 +22,7 @@ call ale#linter#Define('python', {
|
||||
\ 'name': 'pyls',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable_callback': 'ale_linters#python#pyls#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#python#pyls#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#python#pyls#GetCommand',
|
||||
\ 'language_callback': 'ale_linters#python#pyls#GetLanguage',
|
||||
\ 'project_root_callback': 'ale#python#FindProjectRoot',
|
||||
\})
|
||||
|
@ -189,16 +189,26 @@ g:ale_python_pylint_use_global *g:ale_python_pylint_use_global*
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
===============================================================================
|
||||
pyls *ale-python-pyls*
|
||||
|
||||
g:ale_python_pyls_executable *g:ale_python_pyls_executable*
|
||||
*b:ale_python_pyls_executable*
|
||||
Type: |String|
|
||||
Default: `pyls`
|
||||
Default: `'pyls'`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
g:ale_python_pyls_use_global *g:ale_python_pyls_use_global*
|
||||
*b:ale_python_pyls_use_global*
|
||||
Type: |Number|
|
||||
Default: `0`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
===============================================================================
|
||||
yapf *ale-python-yapf*
|
||||
|
||||
|
0
test/command_callback/python_paths/with_virtualenv/env/Scripts/pyls
vendored
Executable file
0
test/command_callback/python_paths/with_virtualenv/env/Scripts/pyls
vendored
Executable file
0
test/command_callback/python_paths/with_virtualenv/env/bin/pyls
vendored
Executable file
0
test/command_callback/python_paths/with_virtualenv/env/bin/pyls
vendored
Executable file
49
test/command_callback/test_pyls_command_callback.vader
Normal file
49
test/command_callback/test_pyls_command_callback.vader
Normal file
@ -0,0 +1,49 @@
|
||||
Before:
|
||||
Save g:ale_python_pyls_executable
|
||||
Save g:ale_python_pyls_use_global
|
||||
|
||||
unlet! g:ale_python_pyls_executable
|
||||
unlet! g:ale_python_pyls_use_global
|
||||
|
||||
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/command_callback')
|
||||
|
||||
runtime ale_linters/python/pyls.vim
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! b:bin_dir
|
||||
unlet! b:executable
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The pyls command callback should return default string):
|
||||
AssertEqual ale#Escape('pyls'),
|
||||
\ ale_linters#python#pyls#GetCommand(bufnr(''))
|
||||
|
||||
Execute(The pyls executable should be configurable):
|
||||
let g:ale_python_pyls_executable = '~/.local/bin/pyls'
|
||||
|
||||
AssertEqual ale#Escape('~/.local/bin/pyls'),
|
||||
\ ale_linters#python#pyls#GetCommand(bufnr(''))
|
||||
|
||||
Execute(The pyls executable should be run from the virtualenv path):
|
||||
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
let b:executable = ale#path#Winify(
|
||||
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/pyls'
|
||||
\)
|
||||
|
||||
AssertEqual ale#Escape(b:executable),
|
||||
\ ale_linters#python#pyls#GetCommand(bufnr(''))
|
||||
|
||||
Execute(You should be able to override the pyls virtualenv lookup):
|
||||
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
let g:ale_python_pyls_use_global = 1
|
||||
|
||||
AssertEqual ale#Escape('pyls'),
|
||||
\ ale_linters#python#pyls#GetCommand(bufnr(''))
|
Loading…
Reference in New Issue
Block a user