Add `python_auto_pipenv` config var for all python linters.

This allows a user to set one variable instead of eight.
This commit is contained in:
Eddie Lebow 2018-09-15 21:38:26 -04:00
parent 56e67c5811
commit dbe9352935
10 changed files with 26 additions and 8 deletions

View File

@ -12,7 +12,8 @@ function! s:UsingModule(buffer) abort
endfunction
function! ale_linters#python#flake8#GetExecutable(buffer) abort
if ale#Var(a:buffer, 'python_flake8_auto_pipenv') && ale#python#PipenvPresent(a:buffer)
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_flake8_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif

View File

@ -8,7 +8,8 @@ call ale#Set('python_mypy_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_mypy_auto_pipenv', 0)
function! ale_linters#python#mypy#GetExecutable(buffer) abort
if ale#Var(a:buffer, 'python_mypy_auto_pipenv') && ale#python#PipenvPresent(a:buffer)
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_mypy_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif

View File

@ -12,7 +12,8 @@ let g:ale_python_prospector_options =
let g:ale_python_prospector_use_global = get(g:, 'ale_python_prospector_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#python#prospector#GetExecutable(buffer) abort
if ale#Var(a:buffer, 'python_prospector_auto_pipenv') && ale#python#PipenvPresent(a:buffer)
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_prospector_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif

View File

@ -7,7 +7,8 @@ call ale#Set('python_pycodestyle_use_global', get(g:, 'ale_use_global_executable
call ale#Set('python_pycodestyle_auto_pipenv', 0)
function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort
if ale#Var(a:buffer, 'python_pycodestyle_auto_pipenv') && ale#python#PipenvPresent(a:buffer)
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pycodestyle_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif

View File

@ -6,7 +6,8 @@ call ale#Set('python_pyflakes_use_global', get(g:, 'ale_use_global_executables',
call ale#Set('python_pyflakes_auto_pipenv', 0)
function! ale_linters#python#pyflakes#GetExecutable(buffer) abort
if ale#Var(a:buffer, 'python_pyflakes_auto_pipenv') && ale#python#PipenvPresent(a:buffer)
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflakes_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif

View File

@ -8,7 +8,8 @@ call ale#Set('python_pylint_change_directory', 1)
call ale#Set('python_pylint_auto_pipenv', 0)
function! ale_linters#python#pylint#GetExecutable(buffer) abort
if ale#Var(a:buffer, 'python_pylint_auto_pipenv') && ale#python#PipenvPresent(a:buffer)
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylint_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif

View File

@ -6,7 +6,8 @@ call ale#Set('python_pyls_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_pyls_auto_pipenv', 0)
function! ale_linters#python#pyls#GetExecutable(buffer) abort
if ale#Var(a:buffer, 'python_pyls_auto_pipenv') && ale#python#PipenvPresent(a:buffer)
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyls_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif

View File

@ -6,7 +6,8 @@ call ale#Set('python_pyre_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_pyre_auto_pipenv', 0)
function! ale_linters#python#pyre#GetExecutable(buffer) abort
if ale#Var(a:buffer, 'python_pyre_auto_pipenv') && ale#python#PipenvPresent(a:buffer)
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyre_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif

View File

@ -1,6 +1,8 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Functions for integrating with Python linters.
call ale#Set('python_auto_pipenv', '0')
let s:sep = has('win32') ? '\' : '/'
" bin is used for Unix virtualenv directories, and Scripts is for Windows.
let s:bin_dir = has('unix') ? 'bin' : 'Scripts'

View File

@ -2,6 +2,14 @@
ALE Python Integration *ale-python-options*
g:ale_python_auto_pipenv *g:ale_python_auto_pipenv*
*b:ale_python_auto_pipenv*
Type: |Number|
Default: `0`
Detect whether the file is inside a pipenv, and set the executable to `pipenv`
if true. This is overridden by a manually-set executable.
===============================================================================
ALE Python Project Root Behavior *ale-python-root*