Skip to content

Instantly share code, notes, and snippets.

@k-takata
Created May 23, 2014 09:48
Show Gist options
  • Save k-takata/087c390620bcd3fae4a2 to your computer and use it in GitHub Desktop.
Save k-takata/087c390620bcd3fae4a2 to your computer and use it in GitHub Desktop.
patch for vimproc get_command_name()
diff --git a/autoload/vimproc.vim b/autoload/vimproc.vim
index 4c3b836..4fd3ca4 100644
--- a/autoload/vimproc.vim
+++ b/autoload/vimproc.vim
@@ -185,7 +185,7 @@ function! vimproc#get_command_name(command, ...) "{{{
let cnt = a:0 < 2 ? 1 : a:2
let files = split(substitute(vimproc#util#substitute_path_separator(
- \ vimproc#filepath#which(a:command, path)), '//', '/', 'g'), '\n')
+ \ vimproc#filepath#which(a:command, path, cnt)), '//', '/', 'g'), '\n')
if cnt < 0
return files
diff --git a/autoload/vimproc/filepath.vim b/autoload/vimproc/filepath.vim
index defb236..ca52a93 100644
--- a/autoload/vimproc/filepath.vim
+++ b/autoload/vimproc/filepath.vim
@@ -55,6 +55,10 @@ endfunction
" Get the full path of command.
function! s:which(command, ...)
+ let maxcount = (a:0 >= 2 && type(a:2) == type(0)) ? a:2 : 1
+ if maxcount == 1 && exists('*exepath')
+ return glob(exepath(a:command))
+ endif
let pathlist = a:command =~# s:path_sep_pattern ? [''] :
\ !a:0 ? split($PATH, s:path_separator) :
\ type(a:1) == type([]) ? copy(a:1) :
@@ -67,6 +71,7 @@ function! s:which(command, ...)
endif
let dirsep = s:separator()
+ let cmdlist = []
for dir in pathlist
let head = dir ==# '' ? '' : dir . dirsep
for ext in pathext
@@ -82,13 +87,16 @@ function! s:which(command, ...)
\ toupper(full)), '\u:\@!', '[\0\L\0]', 'g'), 1)
endif
if full != ''
- return full
+ let cmdlist += [full]
+ if maxcount > 0 && len(cmdlist) >= maxcount
+ return join(cmdlist, "\n")
+ endif
endif
endif
endfor
endfor
- return ''
+ return join(cmdlist, "\n")
endfunction
" Split the path with directory separator.
@@ -155,8 +163,8 @@ function! s:is_case_tolerant()
return s:is_case_tolerant
endfunction
-function! vimproc#filepath#which(command, path)
- return s:which(a:command, a:path)
+function! vimproc#filepath#which(command, path, maxcount)
+ return s:which(a:command, a:path, a:maxcount)
endfunction
let &cpo = s:save_cpo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment