mirror of
https://github.com/dense-analysis/ale.git
synced 2026-03-06 23:24:41 +08:00
Run DUB in a separate process as well, so it will not cause import lag.
This commit is contained in:
@@ -7,7 +7,8 @@ let g:loaded_ale_linters_d_dmd = 1
|
||||
" A function for finding the dmd-wrapper script in the Vim runtime paths
|
||||
function! s:FindWrapperScript()
|
||||
for parent in split(&runtimepath, ',')
|
||||
let path = parent . '/' . 'dmd-wrapper'
|
||||
" Expand the path to deal with ~ issues.
|
||||
let path = expand(parent . '/' . 'dmd-wrapper')
|
||||
|
||||
if filereadable(path)
|
||||
return path
|
||||
@@ -15,48 +16,11 @@ function! s:FindWrapperScript()
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ale_linters#d#dmd#GetDubImports(buffer)
|
||||
if !executable('dub')
|
||||
" If we don't have dub, then stop here.
|
||||
return []
|
||||
endif
|
||||
|
||||
" Try to find dub.json
|
||||
let dub_path = findfile("dub.json", ",;")
|
||||
|
||||
if dub_path == ''
|
||||
" Try to find package.json if that fails
|
||||
let dub_path = findfile("package.json", ",;")
|
||||
endif
|
||||
|
||||
if dub_path == ''
|
||||
" We couldn't find the project root directory, so give up.
|
||||
return
|
||||
endif
|
||||
|
||||
let dub_dir = fnamemodify(dub_path, ':h')
|
||||
let old_path = getcwd()
|
||||
|
||||
try
|
||||
" Temporarily change to the project directory.
|
||||
execute 'cd' . fnameescape(dub_dir)
|
||||
|
||||
return split(system('dub describe --import-paths'), '\n')
|
||||
finally
|
||||
" Change back to the old path.
|
||||
execute 'cd' . fnameescape(old_path)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! ale_linters#d#dmd#GetCommand(buffer)
|
||||
let wrapper_script = s:FindWrapperScript()
|
||||
|
||||
let command = wrapper_script . ' -o- -vcolumns -c'
|
||||
|
||||
for path in ale_linters#d#dmd#GetDubImports(a:buffer)
|
||||
let command .= ' -I' . shellescape(path)
|
||||
endfor
|
||||
|
||||
return command
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user