summaryrefslogtreecommitdiff
path: root/ale_linters/python/flake8.vim
diff options
context:
space:
mode:
authorBartek thindil Jasicki <thindil@laeran.pl>2020-09-04 13:46:11 +0200
committerBartek thindil Jasicki <thindil@laeran.pl>2020-09-04 13:46:11 +0200
commitc78be861035765d268a5533cf583803e22d56d1c (patch)
tree63b2294216911121d594b885ae93fb82edc00273 /ale_linters/python/flake8.vim
parent0de847a8e1793b597ba0a73ae8e20797a5fce920 (diff)
parent844febb9fbfb66bb13dd652d958495e47f0bd408 (diff)
downloadale-c78be861035765d268a5533cf583803e22d56d1c.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'ale_linters/python/flake8.vim')
-rw-r--r--ale_linters/python/flake8.vim28
1 files changed, 24 insertions, 4 deletions
diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim
index e2e7b743..fc4ab692 100644
--- a/ale_linters/python/flake8.vim
+++ b/ale_linters/python/flake8.vim
@@ -4,7 +4,7 @@
call ale#Set('python_flake8_executable', 'flake8')
call ale#Set('python_flake8_options', '')
call ale#Set('python_flake8_use_global', get(g:, 'ale_use_global_executables', 0))
-call ale#Set('python_flake8_change_directory', 1)
+call ale#Set('python_flake8_change_directory', 'project')
call ale#Set('python_flake8_auto_pipenv', 0)
function! s:UsingModule(buffer) abort
@@ -38,10 +38,30 @@ function! ale_linters#python#flake8#RunWithVersionCheck(buffer) abort
\)
endfunction
+function! ale_linters#python#flake8#GetCdString(buffer) abort
+ let l:change_directory = ale#Var(a:buffer, 'python_flake8_change_directory')
+ let l:cd_string = ''
+
+ if l:change_directory is# 'project'
+ let l:project_root = ale#python#FindProjectRootIni(a:buffer)
+
+ if !empty(l:project_root)
+ let l:cd_string = ale#path#CdString(l:project_root)
+ endif
+ endif
+
+ if (l:change_directory is# 'project' && empty(l:cd_string))
+ \|| l:change_directory is# 1
+ \|| l:change_directory is# 'file'
+ let l:cd_string = ale#path#BufferCdString(a:buffer)
+ endif
+
+ return l:cd_string
+endfunction
+
function! ale_linters#python#flake8#GetCommand(buffer, version) abort
- let l:cd_string = ale#Var(a:buffer, 'python_flake8_change_directory')
- \ ? ale#path#BufferCdString(a:buffer)
- \ : ''
+ let l:cd_string = ale_linters#python#flake8#GetCdString(a:buffer)
+
let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv$'