From 066c1d60589ea116be697657435d5596c09471e8 Mon Sep 17 00:00:00 2001 From: IdanArye Date: Fri, 30 Aug 2013 03:46:55 +0300 Subject: [PATCH] Added a Vim plugin option to add import paths as arguments to DCDstartServer --- editors/vim/README.md | 8 +++++--- editors/vim/autoload/dcomplete.vim | 5 +++-- editors/vim/ftplugin/d.vim | 6 ++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/editors/vim/README.md b/editors/vim/README.md index 49b9be1..2788f24 100644 --- a/editors/vim/README.md +++ b/editors/vim/README.md @@ -24,13 +24,15 @@ Import paths are globbed with Vim's globbing function. Usage =================== When the filetype is D, use the `DCDstartServer` command to start the server -and the `DCDstopServer` command to stop the server. +and the `DCDstopServer` command to stop the server. `DCDstartServer` can +receive import path(s) as arguments. -Use the `DCDaddPath` command to add an import path to the server. Make sure you +Use the `DCDaddPath` command to add a import path(s) to the server. Make sure you escape spaces! Import paths are globbed with Vim's globbing function. Use the `DCD` command to send arbitary commands to the server via the client. The syntax is the same as with `dcd-client`, so you can use it without arguments to print the help message. -When the server is running, use `CTRL`+`x` `CTRL`+`o` to use DCD completion. +When the server is running, use `CTRL`+`x` `CTRL`+`o` in a D buffer to use DCD +completion. diff --git a/editors/vim/autoload/dcomplete.vim b/editors/vim/autoload/dcomplete.vim index 1cabb34..6e13d6f 100644 --- a/editors/vim/autoload/dcomplete.vim +++ b/editors/vim/autoload/dcomplete.vim @@ -73,9 +73,10 @@ endfunction "DCD's syntax. function! dcomplete#initImportPath() if exists('g:dcd_importPath') - return dcomplete#globImportPath(g:dcd_importPath) + return dcomplete#globImportPath(copy(g:dcd_importPath)) + else + return '' endif - return '' endfunction "Run DCD to get autocompletion results diff --git a/editors/vim/ftplugin/d.vim b/editors/vim/ftplugin/d.vim index 176c9c6..d87b45e 100644 --- a/editors/vim/ftplugin/d.vim +++ b/editors/vim/ftplugin/d.vim @@ -1,9 +1,11 @@ setlocal omnifunc=dcomplete#Complete if has('win32') - command! -buffer DCDstartServer execute '!start '.dcomplete#DCDserver().' '.dcomplete#initImportPath() + command! -buffer -nargs=* -complete=dir DCDstartServer execute '!start '.dcomplete#DCDserver().' '.dcomplete#initImportPath(). + \ ' '.dcomplete#globImportPath([]) else - command! -buffer DCDstartServer execute '!'.dcomplete#DCDserver().' '.dcomplete#initImportPath().' > /dev/null &' + command! -buffer -nargs=* -complete=dir DCDstartServer execute '!'.dcomplete#DCDserver().' '.dcomplete#initImportPath(). + \ ' '.dcomplete#globImportPath([]).' > /dev/null &' endif command! -buffer -nargs=? DCD execute '!'.dcomplete#DCDclient().' '. command! -buffer DCDstopServer DCD --shutdown