Skip to content
Myr

Update Vim plugin to take path argument

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 724724b · Browse files · 2 files+23 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+23 added−5 removed

  • other:+23 added−5 removed

2 files+23 added−5 removed

modified:plugin/fzf.vim+16 added-4 removed
21 unmodified lines
22" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.2324let s:exec = expand('<sfile>:h:h').'/fzf'2526function! s:escape(path)27 return substitute(a:path, ' ', '\\ ', 'g')28endfunction2926function! fzf#run(command, args)30function! fzf#run(command, ...)31 let cwd = getcwd()32 try33 let args = copy(a:000)34 if len(args) > 035 let dir = remove(args, -1)36 execute 'chdir '.s:escape(dir)37 endif38 let argstr = join(args)39 let tf = tempname()40 let prefix = exists('g:fzf_source') ? g:fzf_source.'|' : ''41 let fzf = executable(s:exec) ? s:exec : 'fzf'31 let options = empty(a:args) ? get(g:, 'fzf_options', '') : a:args42 let options = empty(argstr) ? get(g:, 'fzf_options', '') : argstr43 execute "silent !".prefix.fzf.' '.options." > ".tf44 if !v:shell_error45 for line in readfile(tf)46 if !empty(line)36 execute a:command.' '.line47 execute a:command.' '.s:escape(line)48 endif49 endfor50 endif51 finally52 execute 'chdir '.s:escape(cwd)53 redraw!54 silent! call delete(tf)55 endtry56endfunction5746command! -nargs=* FZF call fzf#run('silent e', <q-args>)58command! -nargs=* -complete=dir FZF call fzf#run('silent e', <f-args>)59
modified:README.md+7 added-1 removed
138 unmodified lines
139140If you install fzf as a Vim plugin, `:FZF` command will be added.141142```vim143" Look for files under current directory144:FZF145146" Look for files under your home directory147:FZF ~148149" With options144:FZF --no-sort -m150:FZF --no-sort -m /tmp151```152153You can override the source command which produces input to fzf.154
193 unmodified lines