summaryrefslogtreecommitdiff
path: root/ale_linters/python/pylama.vim
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2021-03-01 20:11:10 +0000
committerw0rp <devw0rp@gmail.com>2021-03-01 20:11:10 +0000
commit9fe7b1fe6a23fb55e6d782293585d58193123f59 (patch)
tree0403deb70011aee7be08e586b10b5828cf69499e /ale_linters/python/pylama.vim
parent48fab99a0ab793e1b9607795c21659f12bd6947f (diff)
downloadale-9fe7b1fe6a23fb55e6d782293585d58193123f59.zip
Close #2281 - Separate cwd commands from commands
Working directories are now set seperately from the commands so they can later be swapped out when running linters over projects is supported, and also better support filename mapping for running linters on other machines in future.
Diffstat (limited to 'ale_linters/python/pylama.vim')
-rw-r--r--ale_linters/python/pylama.vim17
1 files changed, 9 insertions, 8 deletions
diff --git a/ale_linters/python/pylama.vim b/ale_linters/python/pylama.vim
index 38dd2836..bad69667 100644
--- a/ale_linters/python/pylama.vim
+++ b/ale_linters/python/pylama.vim
@@ -16,19 +16,20 @@ function! ale_linters#python#pylama#GetExecutable(buffer) abort
return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama'])
endfunction
-function! ale_linters#python#pylama#GetCommand(buffer) abort
- let l:cd_string = ''
-
+function! ale_linters#python#pylama#GetCwd(buffer) abort
if ale#Var(a:buffer, 'python_pylama_change_directory')
" Pylama loads its configuration from the current directory only, and
" applies file masks using paths relative to the current directory.
" Run from project root, if found, otherwise buffer dir.
let l:project_root = ale#python#FindProjectRoot(a:buffer)
- let l:cd_string = l:project_root isnot# ''
- \ ? ale#path#CdString(l:project_root)
- \ : ale#path#BufferCdString(a:buffer)
+
+ return !empty(l:project_root) ? l:project_root : '%s:h'
endif
+ return ''
+endfunction
+
+function! ale_linters#python#pylama#GetCommand(buffer) abort
let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv$'
\ ? ' run pylama'
@@ -37,8 +38,7 @@ function! ale_linters#python#pylama#GetCommand(buffer) abort
" Note: Using %t to lint changes would be preferable, but many pylama
" checks use surrounding paths (e.g. C0103 module name, E0402 relative
" import beyond top, etc.). Neither is ideal.
- return l:cd_string
- \ . ale#Escape(l:executable) . l:exec_args
+ return ale#Escape(l:executable) . l:exec_args
\ . ale#Pad(ale#Var(a:buffer, 'python_pylama_options'))
\ . ' %s'
endfunction
@@ -86,6 +86,7 @@ endfunction
call ale#linter#Define('python', {
\ 'name': 'pylama',
\ 'executable': function('ale_linters#python#pylama#GetExecutable'),
+\ 'cwd': function('ale_linters#python#pylama#GetCwd'),
\ 'command': function('ale_linters#python#pylama#GetCommand'),
\ 'callback': 'ale_linters#python#pylama#Handle',
\ 'lint_file': 1,