summaryrefslogtreecommitdiff
path: root/ale_linters/d/dmd.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/d/dmd.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/d/dmd.vim')
-rw-r--r--ale_linters/d/dmd.vim30
1 files changed, 16 insertions, 14 deletions
diff --git a/ale_linters/d/dmd.vim b/ale_linters/d/dmd.vim
index 14461ae6..cc5d8bc6 100644
--- a/ale_linters/d/dmd.vim
+++ b/ale_linters/d/dmd.vim
@@ -1,35 +1,37 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: "dmd for D files"
-function! ale_linters#d#dmd#GetDUBCommand(buffer) abort
+function! s:GetDUBCommand(buffer) abort
" If we can't run dub, then skip this command.
if !executable('dub')
" Returning an empty string skips to the DMD command.
- return ''
- endif
-
- let l:dub_file = ale#d#FindDUBConfig(a:buffer)
+ let l:config = ale#d#FindDUBConfig(a:buffer)
- if empty(l:dub_file)
- return ''
+ " To support older dub versions, we just change the directory to the
+ " directory where we found the dub config, and then run `dub describe`
+ " from that directory.
+ if !empty(l:config)
+ return [fnamemodify(l:config, ':h'), 'dub describe --import-paths']
+ endif
endif
- " To support older dub versions, we just change the directory to
- " the directory where we found the dub config, and then run `dub describe`
- " from that directory.
- return 'cd ' . ale#Escape(fnamemodify(l:dub_file, ':h'))
- \ . ' && dub describe --import-paths'
+ return ['', '']
endfunction
function! ale_linters#d#dmd#RunDUBCommand(buffer) abort
- let l:command = ale_linters#d#dmd#GetDUBCommand(a:buffer)
+ let [l:cwd, l:command] = s:GetDUBCommand(a:buffer)
if empty(l:command)
" If we can't run DUB, just run DMD.
return ale_linters#d#dmd#DMDCommand(a:buffer, [], {})
endif
- return ale#command#Run(a:buffer, l:command, function('ale_linters#d#dmd#DMDCommand'))
+ return ale#command#Run(
+ \ a:buffer,
+ \ l:command,
+ \ function('ale_linters#d#dmd#DMDCommand'),
+ \ {'cwd': l:cwd},
+ \)
endfunction
function! ale_linters#d#dmd#DMDCommand(buffer, dub_output, meta) abort