Fix :Connect with no arguments

Closes #120.
This commit is contained in:
Tim Pope 2014-01-06 11:38:37 -05:00
parent 9aa2071b17
commit 7277fc4e6d
1 changed files with 6 additions and 6 deletions

View File

@ -174,7 +174,7 @@ endfunction
" }}}1 " }}}1
" :Connect {{{1 " :Connect {{{1
command! -bar -complete=customlist,s:connect_complete -nargs=+ FireplaceConnect :exe s:Connect(<f-args>) command! -bar -complete=customlist,s:connect_complete -nargs=* FireplaceConnect :exe s:Connect(<f-args>)
function! fireplace#input_host_port() function! fireplace#input_host_port()
let arg = input('Host> ', 'localhost') let arg = input('Host> ', 'localhost')
@ -213,10 +213,10 @@ function! s:connect_complete(A, L, P)
return options return options
endfunction endfunction
function! s:Connect(arg, ...) function! s:Connect(...)
if a:arg =~# '^\w\+://' if (a:0 ? a:1 : '') =~# '^\w\+://'
let [proto, arg] = split(a:arg, '://') let [proto, arg] = split(a:arg, '://')
elseif a:arg !=# '' elseif a:0
return 'echoerr '.string('Usage: :Connect proto://...') return 'echoerr '.string('Usage: :Connect proto://...')
else else
let protos = s:protos() let protos = s:protos()
@ -243,7 +243,7 @@ function! s:Connect(arg, ...)
let client = s:register_connection(connection) let client = s:register_connection(connection)
echo 'Connected to '.proto.'://'.arg echo 'Connected to '.proto.'://'.arg
let path = fnamemodify(exists('b:java_root') ? b:java_root : fnamemodify(expand('%'), ':p:s?.*\zs[\/]src[\/].*??'), ':~') let path = fnamemodify(exists('b:java_root') ? b:java_root : fnamemodify(expand('%'), ':p:s?.*\zs[\/]src[\/].*??'), ':~')
let root = a:0 ? expand(a:1) : input('Scope connection to: ', path, 'dir') let root = a:0 > 1 ? expand(a:2) : input('Scope connection to: ', path, 'dir')
if root !=# '' && root !=# '-' if root !=# '' && root !=# '-'
let s:repl_paths[fnamemodify(root, ':p:s?.\zs[\/]$??')] = client let s:repl_paths[fnamemodify(root, ':p:s?.\zs[\/]$??')] = client
endif endif
@ -252,7 +252,7 @@ endfunction
augroup fireplace_connect augroup fireplace_connect
autocmd! autocmd!
autocmd FileType clojure command! -bar -complete=customlist,s:connect_complete -nargs=+ Connect :FireplaceConnect <args> autocmd FileType clojure command! -bar -complete=customlist,s:connect_complete -nargs=* Connect :FireplaceConnect <args>
augroup END augroup END
" }}}1 " }}}1