Fix #1507 - Add an option for disabling switching directories for pylint
This commit is contained in:
parent
fb720251bf
commit
f9ba3d924f
@ -1,20 +1,21 @@
|
|||||||
" Author: keith <k@keith.so>
|
" Author: keith <k@keith.so>
|
||||||
" Description: pylint for python files
|
" Description: pylint for python files
|
||||||
|
|
||||||
let g:ale_python_pylint_executable =
|
call ale#Set('python_pylint_executable', 'pylint')
|
||||||
\ get(g:, 'ale_python_pylint_executable', 'pylint')
|
call ale#Set('python_pylint_options', '')
|
||||||
|
call ale#Set('python_pylint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||||
let g:ale_python_pylint_options =
|
call ale#Set('python_pylint_change_directory', 1)
|
||||||
\ get(g:, 'ale_python_pylint_options', '')
|
|
||||||
|
|
||||||
let g:ale_python_pylint_use_global = get(g:, 'ale_python_pylint_use_global', get(g:, 'ale_use_global_executables', 0))
|
|
||||||
|
|
||||||
function! ale_linters#python#pylint#GetExecutable(buffer) abort
|
function! ale_linters#python#pylint#GetExecutable(buffer) abort
|
||||||
return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint'])
|
return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint'])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#python#pylint#GetCommand(buffer) abort
|
function! ale_linters#python#pylint#GetCommand(buffer) abort
|
||||||
return ale#path#BufferCdString(a:buffer)
|
let l:cd_string = ale#Var(a:buffer, 'python_pylint_change_directory')
|
||||||
|
\ ? ale#path#BufferCdString(a:buffer)
|
||||||
|
\ : ''
|
||||||
|
|
||||||
|
return l:cd_string
|
||||||
\ . ale#Escape(ale_linters#python#pylint#GetExecutable(a:buffer))
|
\ . ale#Escape(ale_linters#python#pylint#GetExecutable(a:buffer))
|
||||||
\ . ' ' . ale#Var(a:buffer, 'python_pylint_options')
|
\ . ' ' . ale#Var(a:buffer, 'python_pylint_options')
|
||||||
\ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n'
|
\ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n'
|
||||||
|
@ -231,6 +231,17 @@ g:ale_python_pycodestyle_use_global *g:ale_python_pycodestyle_use_global*
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
pylint *ale-python-pylint*
|
pylint *ale-python-pylint*
|
||||||
|
|
||||||
|
g:ale_python_pylint_change_directory *g:ale_python_pylint_change_directory*
|
||||||
|
*b:ale_python_pylint_change_directory*
|
||||||
|
Type: |Number|
|
||||||
|
Default: `1`
|
||||||
|
|
||||||
|
If set to `1`, ALE will switch to the directory the Python file being
|
||||||
|
checked with `pylint` is in before checking it. This helps `pylint` find
|
||||||
|
configuration files more easily. This option can be turned off if you want
|
||||||
|
to control the directory Python is executed from yourself.
|
||||||
|
|
||||||
|
|
||||||
g:ale_python_pylint_executable *g:ale_python_pylint_executable*
|
g:ale_python_pylint_executable *g:ale_python_pylint_executable*
|
||||||
*b:ale_python_pylint_executable*
|
*b:ale_python_pylint_executable*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
|
@ -2,10 +2,12 @@ Before:
|
|||||||
Save g:ale_python_pylint_executable
|
Save g:ale_python_pylint_executable
|
||||||
Save g:ale_python_pylint_options
|
Save g:ale_python_pylint_options
|
||||||
Save g:ale_python_pylint_use_global
|
Save g:ale_python_pylint_use_global
|
||||||
|
Save g:ale_python_pylint_change_directory
|
||||||
|
|
||||||
unlet! g:ale_python_pylint_executable
|
unlet! g:ale_python_pylint_executable
|
||||||
unlet! g:ale_python_pylint_options
|
unlet! g:ale_python_pylint_options
|
||||||
unlet! g:ale_python_pylint_use_global
|
unlet! g:ale_python_pylint_use_global
|
||||||
|
unlet! g:ale_python_pylint_change_directory
|
||||||
|
|
||||||
runtime ale_linters/python/pylint.vim
|
runtime ale_linters/python/pylint.vim
|
||||||
call ale#test#SetDirectory('/testplugin/test/command_callback')
|
call ale#test#SetDirectory('/testplugin/test/command_callback')
|
||||||
@ -32,6 +34,17 @@ Execute(The pylint callbacks should return the correct default values):
|
|||||||
\ . ale#Escape('pylint') . ' ' . b:command_tail,
|
\ . ale#Escape('pylint') . ' ' . b:command_tail,
|
||||||
\ ale_linters#python#pylint#GetCommand(bufnr(''))
|
\ ale_linters#python#pylint#GetCommand(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The option for disabling changing directories should work):
|
||||||
|
let g:ale_python_pylint_change_directory = 0
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ 'pylint',
|
||||||
|
\ ale_linters#python#pylint#GetExecutable(bufnr(''))
|
||||||
|
\
|
||||||
|
AssertEqual
|
||||||
|
\ ale#Escape('pylint') . ' ' . b:command_tail,
|
||||||
|
\ ale_linters#python#pylint#GetCommand(bufnr(''))
|
||||||
|
|
||||||
Execute(The pylint executable should be configurable, and escaped properly):
|
Execute(The pylint executable should be configurable, and escaped properly):
|
||||||
let g:ale_python_pylint_executable = 'executable with spaces'
|
let g:ale_python_pylint_executable = 'executable with spaces'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user