mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-08 13:34:47 +08:00
[fzf#vim#complete#path] works in Windows
This commit is contained in:
@@ -1252,12 +1252,13 @@ function! fzf#vim#complete(...)
|
|||||||
let s:opts = s:eval(s:opts, 'options', s:query)
|
let s:opts = s:eval(s:opts, 'options', s:query)
|
||||||
let s:opts = s:eval(s:opts, 'extra_options', s:query)
|
let s:opts = s:eval(s:opts, 'extra_options', s:query)
|
||||||
if has_key(s:opts, 'extra_options')
|
if has_key(s:opts, 'extra_options')
|
||||||
let s:opts.options =
|
call s:merge_opts(s:opts, remove(s:opts, 'extra_options'))
|
||||||
\ join(filter([get(s:opts, 'options', ''), remove(s:opts, 'extra_options')], '!empty(v:val)'))
|
|
||||||
endif
|
endif
|
||||||
if has_key(s:opts, 'options')
|
if has_key(s:opts, 'options')
|
||||||
" FIXME: fzf currently doesn't have --no-expect option
|
" 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.string
|
||||||
|
let s:opts.options = substitute(s:opts.options, '--expect=[^ ]*', '', 'g')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call feedkeys("\<Plug>(-fzf-complete-trigger)")
|
call feedkeys("\<Plug>(-fzf-complete-trigger)")
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
let s:is_win = has('win32') || has('win64')
|
||||||
|
|
||||||
function! s:extend(base, extra)
|
function! s:extend(base, extra)
|
||||||
let base = copy(a:base)
|
let base = copy(a:base)
|
||||||
@@ -58,25 +59,26 @@ endfunction
|
|||||||
" ----------------------------------------------------------------------------
|
" ----------------------------------------------------------------------------
|
||||||
function! s:file_split_prefix(prefix)
|
function! s:file_split_prefix(prefix)
|
||||||
let expanded = expand(a:prefix)
|
let expanded = expand(a:prefix)
|
||||||
|
let slash = (s:is_win && !&shellslash) ? '\\' : '/'
|
||||||
return isdirectory(expanded) ?
|
return isdirectory(expanded) ?
|
||||||
\ [expanded,
|
\ [expanded,
|
||||||
\ substitute(a:prefix, '/*$', '/', ''),
|
\ substitute(a:prefix, '[/\\]*$', slash, ''),
|
||||||
\ ''] :
|
\ ''] :
|
||||||
\ [fnamemodify(expanded, ':h'),
|
\ [fnamemodify(expanded, ':h'),
|
||||||
\ substitute(fnamemodify(a:prefix, ':h'), '/*$', '/', ''),
|
\ substitute(fnamemodify(a:prefix, ':h'), '[/\\]*$', slash, ''),
|
||||||
\ fnamemodify(expanded, ':t')]
|
\ fnamemodify(expanded, ':t')]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:file_source(prefix)
|
function! s:file_source(prefix)
|
||||||
let [dir, head, tail] = s:file_split_prefix(a:prefix)
|
let [dir, head, tail] = s:file_split_prefix(a:prefix)
|
||||||
return printf(
|
return printf(
|
||||||
\ "cd %s && ".s:file_cmd." | sed 's:^:%s:'",
|
\ "cd %s && ".s:file_cmd." | sed %s",
|
||||||
\ shellescape(dir), empty(a:prefix) || a:prefix == tail ? '' : head)
|
\ fzf#shellescape(dir), fzf#shellescape('s:^:'.(empty(a:prefix) || a:prefix == tail ? '' : head).':'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:file_options(prefix)
|
function! s:file_options(prefix)
|
||||||
let [_, head, tail] = s:file_split_prefix(a: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
|
endfunction
|
||||||
|
|
||||||
function! s:fname_prefix(str)
|
function! s:fname_prefix(str)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
let s:is_win = has('win32') || has('win64')
|
||||||
|
|
||||||
function! s:defs(commands)
|
function! s:defs(commands)
|
||||||
let prefix = get(g:, 'fzf_command_prefix', '')
|
let prefix = get(g:, 'fzf_command_prefix', '')
|
||||||
@@ -123,9 +124,14 @@ augroup fzf_buffers
|
|||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
inoremap <expr> <plug>(fzf-complete-word) fzf#vim#complete#word()
|
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:^..::'")
|
if s:is_win
|
||||||
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-path) fzf#vim#complete#path('dir /s/b')
|
||||||
inoremap <expr> <plug>(fzf-complete-file-ag) fzf#vim#complete#path("ag -l -g ''")
|
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-line) fzf#vim#complete#line()
|
||||||
inoremap <expr> <plug>(fzf-complete-buffer-line) fzf#vim#complete#buffer_line()
|
inoremap <expr> <plug>(fzf-complete-buffer-line) fzf#vim#complete#buffer_line()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user