Merge pull request #436 from janlazo/Windows_complete
[fzf#vim#complete#path] works in Windows
This commit is contained in:
commit
39f0c2d0a4
3 changed files with 23 additions and 13 deletions
|
@ -1171,7 +1171,7 @@ endfunction
|
|||
|
||||
function! s:complete_trigger()
|
||||
let opts = copy(s:opts)
|
||||
let opts.options = printf('+m -q %s %s', shellescape(s:query), get(opts, 'options', ''))
|
||||
call s:merge_opts(opts, ['+m', '-q', s:query])
|
||||
let opts['sink*'] = s:function('s:complete_insert')
|
||||
let s:reducer = s:pluck(opts, 'reducer', s:function('s:first_line'))
|
||||
call fzf#run(opts)
|
||||
|
@ -1252,12 +1252,14 @@ function! fzf#vim#complete(...)
|
|||
let s:opts = s:eval(s:opts, 'options', s:query)
|
||||
let s:opts = s:eval(s:opts, 'extra_options', s:query)
|
||||
if has_key(s:opts, 'extra_options')
|
||||
let s:opts.options =
|
||||
\ join(filter([get(s:opts, 'options', ''), remove(s:opts, 'extra_options')], '!empty(v:val)'))
|
||||
call s:merge_opts(s:opts, remove(s:opts, 'extra_options'))
|
||||
endif
|
||||
if has_key(s:opts, 'options')
|
||||
" FIXME: fzf currently doesn't have --no-expect option
|
||||
let s:opts.options = substitute(s:opts.options, '--expect=[^ ]*', '', 'g')
|
||||
if type(s:opts.options) == s:TYPE.list
|
||||
call add(s:opts.options, '--no-expect')
|
||||
else
|
||||
let s:opts.options .= ' --no-expect'
|
||||
endif
|
||||
endif
|
||||
|
||||
call feedkeys("\<Plug>(-fzf-complete-trigger)")
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
let s:is_win = has('win32') || has('win64')
|
||||
|
||||
function! s:extend(base, extra)
|
||||
let base = copy(a:base)
|
||||
|
@ -58,25 +59,26 @@ endfunction
|
|||
" ----------------------------------------------------------------------------
|
||||
function! s:file_split_prefix(prefix)
|
||||
let expanded = expand(a:prefix)
|
||||
let slash = (s:is_win && !&shellslash) ? '\\' : '/'
|
||||
return isdirectory(expanded) ?
|
||||
\ [expanded,
|
||||
\ substitute(a:prefix, '/*$', '/', ''),
|
||||
\ substitute(a:prefix, '[/\\]*$', slash, ''),
|
||||
\ ''] :
|
||||
\ [fnamemodify(expanded, ':h'),
|
||||
\ substitute(fnamemodify(a:prefix, ':h'), '/*$', '/', ''),
|
||||
\ substitute(fnamemodify(a:prefix, ':h'), '[/\\]*$', slash, ''),
|
||||
\ fnamemodify(expanded, ':t')]
|
||||
endfunction
|
||||
|
||||
function! s:file_source(prefix)
|
||||
let [dir, head, tail] = s:file_split_prefix(a:prefix)
|
||||
return printf(
|
||||
\ "cd %s && ".s:file_cmd." | sed 's:^:%s:'",
|
||||
\ shellescape(dir), empty(a:prefix) || a:prefix == tail ? '' : head)
|
||||
\ "cd %s && ".s:file_cmd." | sed %s",
|
||||
\ fzf#shellescape(dir), fzf#shellescape('s:^:'.(empty(a:prefix) || a:prefix == tail ? '' : head).':'))
|
||||
endfunction
|
||||
|
||||
function! s:file_options(prefix)
|
||||
let [_, head, tail] = s:file_split_prefix(a:prefix)
|
||||
return printf('--prompt %s --query %s', shellescape(head), shellescape(tail))
|
||||
return ['--prompt', head, '--query', tail]
|
||||
endfunction
|
||||
|
||||
function! s:fname_prefix(str)
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
let s:is_win = has('win32') || has('win64')
|
||||
|
||||
function! s:defs(commands)
|
||||
let prefix = get(g:, 'fzf_command_prefix', '')
|
||||
|
@ -123,9 +124,14 @@ augroup fzf_buffers
|
|||
augroup END
|
||||
|
||||
inoremap <expr> <plug>(fzf-complete-word) fzf#vim#complete#word()
|
||||
inoremap <expr> <plug>(fzf-complete-path) fzf#vim#complete#path("find . -path '*/\.*' -prune -o -print \| sed '1d;s:^..::'")
|
||||
inoremap <expr> <plug>(fzf-complete-file) fzf#vim#complete#path("find . -path '*/\.*' -prune -o -type f -print -o -type l -print \| sed 's:^..::'")
|
||||
inoremap <expr> <plug>(fzf-complete-file-ag) fzf#vim#complete#path("ag -l -g ''")
|
||||
if s:is_win
|
||||
inoremap <expr> <plug>(fzf-complete-path) fzf#vim#complete#path('dir /s/b')
|
||||
inoremap <expr> <plug>(fzf-complete-file) fzf#vim#complete#path('dir /s/b/a:-d')
|
||||
else
|
||||
inoremap <expr> <plug>(fzf-complete-path) fzf#vim#complete#path("find . -path '*/\.*' -prune -o -print \| sed '1d;s:^..::'")
|
||||
inoremap <expr> <plug>(fzf-complete-file) fzf#vim#complete#path("find . -path '*/\.*' -prune -o -type f -print -o -type l -print \| sed 's:^..::'")
|
||||
endif
|
||||
inoremap <expr> <plug>(fzf-complete-file-ag) fzf#vim#complete#path('ag -l -g ""')
|
||||
inoremap <expr> <plug>(fzf-complete-line) fzf#vim#complete#line()
|
||||
inoremap <expr> <plug>(fzf-complete-buffer-line) fzf#vim#complete#buffer_line()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue