diff options
author | w0rp <devw0rp@gmail.com> | 2017-05-07 16:31:33 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-05-07 16:31:33 +0100 |
commit | 1a157b1cd5f08d652f93defbb10f5bcc1a20a739 (patch) | |
tree | 4b641e7d25957a725d1c670a20f2498350d3a011 /ale_linters | |
parent | 05bd4f591c3d9f53dff8beadb5468ed7a301fad4 (diff) | |
download | ale-1a157b1cd5f08d652f93defbb10f5bcc1a20a739.zip |
Support `python -m flake8` for users who are running flake8 that way
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/python/flake8.vim | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim index ab074567..4959583f 100644 --- a/ale_linters/python/flake8.vim +++ b/ale_linters/python/flake8.vim @@ -14,8 +14,12 @@ let g:ale_python_flake8_use_global = get(g:, 'ale_python_flake8_use_global', 0) " executables, so we don't have to look up the version number constantly. let s:version_cache = {} +function! s:UsingModule(buffer) abort + return ale#Var(a:buffer, 'python_flake8_options') =~# ' *-m flake8' +endfunction + function! ale_linters#python#flake8#GetExecutable(buffer) abort - if !ale#Var(a:buffer, 'python_flake8_use_global') + if !s:UsingModule(a:buffer) && !ale#Var(a:buffer, 'python_flake8_use_global') let l:virtualenv = ale#python#FindVirtualenv(a:buffer) if !empty(l:virtualenv) @@ -44,8 +48,10 @@ function! ale_linters#python#flake8#VersionCheck(buffer) abort return '' endif - return fnameescape(ale_linters#python#flake8#GetExecutable(a:buffer)) - \ . ' --version' + let l:executable = fnameescape(ale_linters#python#flake8#GetExecutable(a:buffer)) + let l:module_string = s:UsingModule(a:buffer) ? ' -m flake8' : '' + + return l:executable . l:module_string . ' --version' endfunction " Get the flake8 version from the output, or the cache. |