From 9fe7b1fe6a23fb55e6d782293585d58193123f59 Mon Sep 17 00:00:00 2001 From: w0rp Date: Mon, 1 Mar 2021 20:11:10 +0000 Subject: 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. --- ale_linters/d/dmd.vim | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'ale_linters/d') 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 " 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 -- cgit debian/1.2.3+git2.25.1-1-2-gaceb0