1 Commits

Author SHA1 Message Date
Junegunn Choi
db71151970 Add g:fzf_grep_preview_window for enabling Ag/grep preview
Close #225
2016-11-14 02:44:14 +09:00
9 changed files with 238 additions and 571 deletions

View File

@@ -5,7 +5,7 @@
- [ ] Suggestion - [ ] Suggestion
- OS - OS
- [ ] Linux - [ ] Linux
- [ ] macOS - [ ] Mac OS X
- [ ] Windows - [ ] Windows
- [ ] Etc. - [ ] Etc.
- Vim - Vim
@@ -23,7 +23,7 @@ Before submitting
Start Vim with a minimal configuration Start Vim with a minimal configuration
====================================== ======================================
vim -Nu <(curl https://gist.githubusercontent.com/junegunn/6936bf79fedd3a079aeb1dd2f3c81ef5/raw) vim -Nu <(curl https://gist.githubusercontent.com/junegunn/6936bf79fedd3a079aeb1dd2f3c81ef5/raw/vimrc)
--> -->

View File

@@ -29,23 +29,12 @@ selector with fzf.
fzf is an independent command-line program and thus requires an external fzf is an independent command-line program and thus requires an external
terminal emulator when on GVim. You may or may not like the experience. Also terminal emulator when on GVim. You may or may not like the experience. Also
note that Windows support is experimental at the moment. note that fzf currently does not compile on Windows.
Installation Installation
------------ ------------
Use [vim-plug](https://github.com/junegunn/vim-plug) or any Vim plugin Using [vim-plug](https://github.com/junegunn/vim-plug):
manager of your choice.
If you already installed fzf using [Homebrew](https://brew.sh/), the following
should suffice:
```vim
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
```
But if you want to install fzf as well using vim-plug:
```vim ```vim
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
@@ -54,6 +43,8 @@ Plug 'junegunn/fzf.vim'
- `dir` and `do` options are not mandatory - `dir` and `do` options are not mandatory
- Use `./install --bin` instead if you don't need fzf outside of Vim - Use `./install --bin` instead if you don't need fzf outside of Vim
- If you installed fzf using Homebrew, the following should suffice:
- `Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'`
- Make sure to use Vim 7.4 or above - Make sure to use Vim 7.4 or above
Commands Commands
@@ -102,10 +93,6 @@ pathogen#helptags()`. [↩](#a1))
#### Global options #### Global options
See [README-VIM.md][readme-vim] of the main fzf repository for details.
[readme-vim]: https://github.com/junegunn/fzf/blob/master/README-VIM.md#configuration
```vim ```vim
" This is the default extra key bindings " This is the default extra key bindings
let g:fzf_action = { let g:fzf_action = {
@@ -120,7 +107,6 @@ let g:fzf_layout = { 'down': '~40%' }
" In Neovim, you can set up fzf window using a Vim command " In Neovim, you can set up fzf window using a Vim command
let g:fzf_layout = { 'window': 'enew' } let g:fzf_layout = { 'window': 'enew' }
let g:fzf_layout = { 'window': '-tabnew' } let g:fzf_layout = { 'window': '-tabnew' }
let g:fzf_layout = { 'window': '10split enew' }
" Customize fzf colors to match your color scheme " Customize fzf colors to match your color scheme
let g:fzf_colors = let g:fzf_colors =
@@ -131,7 +117,6 @@ let g:fzf_colors =
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'], \ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'], \ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'], \ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'], \ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'], \ 'marker': ['fg', 'Keyword'],
@@ -148,6 +133,12 @@ let g:fzf_history_dir = '~/.local/share/fzf-history'
#### Command-local options #### Command-local options
```vim ```vim
" [Files] Extra options for fzf
" e.g. File preview using Highlight
" (http://www.andre-simon.de/doku/highlight/en/highlight.html)
let g:fzf_files_options =
\ '--preview "(highlight -O ansi {} || cat {}) 2> /dev/null | head -'.&lines.'"'
" [Buffers] Jump to the existing window if possible " [Buffers] Jump to the existing window if possible
let g:fzf_buffers_jump = 1 let g:fzf_buffers_jump = 1
@@ -159,49 +150,25 @@ let g:fzf_tags_command = 'ctags -R'
" [Commands] --expect expression for directly executing the command " [Commands] --expect expression for directly executing the command
let g:fzf_commands_expect = 'alt-enter,ctrl-x' let g:fzf_commands_expect = 'alt-enter,ctrl-x'
" [Ag / fzf#vim#grep] Command to preview the content
" - Requires Ruby
" - Install Highlight or CodeRay for syntax highlighting
let g:fzf_grep_preview_window = 'right:50%'
``` ```
#### Advanced customization #### Advanced customization using autoload functions
You can use autoload functions to define your own commands. You can use autoload functions to define your own commands.
```vim ```vim
" Command for git grep " git grep
" - fzf#vim#grep(command, with_column, [options], [fullscreen])
command! -bang -nargs=* GGrep command! -bang -nargs=* GGrep
\ call fzf#vim#grep('git grep --line-number '.shellescape(<q-args>), 0, <bang>0) \ call fzf#vim#grep('git grep --line-number '.shellescape(<q-args>), 0, <bang>0)
" Override Colors command. You can safely do this in your .vimrc as fzf.vim " We use VimEnter event so that the code is run after fzf.vim is loaded
" will not override existing commands. autocmd VimEnter * command! Colors
command! -bang Colors \ call fzf#vim#colors({'left': '15%', 'options': '--reverse --margin 30%,0'})
\ call fzf#vim#colors({'left': '15%', 'options': '--reverse --margin 30%,0'}, <bang>0)
" Augmenting Ag command using fzf#vim#with_preview function
" * fzf#vim#with_preview([[options], preview window, [toggle keys...]])
" * For syntax-highlighting, Ruby and any of the following tools are required:
" - Highlight: http://www.andre-simon.de/doku/highlight/en/highlight.php
" - CodeRay: http://coderay.rubychan.de/
" - Rouge: https://github.com/jneen/rouge
"
" :Ag - Start fzf with hidden preview window that can be enabled with "?" key
" :Ag! - Start fzf in fullscreen and display the preview window above
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
" Similarly, we can apply it to fzf#vim#grep. To use ripgrep instead of ag:
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
" Likewise, Files command with preview window
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
``` ```
Mappings Mappings
@@ -260,7 +227,7 @@ following exceptions:
- Or a function to extract completion prefix - Or a function to extract completion prefix
- Both `source` and `options` can be given as funcrefs that take the - Both `source` and `options` can be given as funcrefs that take the
completion prefix as the argument and return the final value completion prefix as the argument and return the final value
- `sink` or `sink*` are ignored - `sink` or `sink*` are not allowed
#### Reducer example #### Reducer example

View File

@@ -1,4 +1,4 @@
" Copyright (c) 2017 Junegunn Choi " Copyright (c) 2016 Junegunn Choi
" "
" MIT License " MIT License
" "
@@ -28,83 +28,11 @@ set cpo&vim
" Common " Common
" ------------------------------------------------------------------ " ------------------------------------------------------------------
let s:is_win = has('win32') || has('win64')
let s:layout_keys = ['window', 'up', 'down', 'left', 'right'] let s:layout_keys = ['window', 'up', 'down', 'left', 'right']
let s:bin_dir = expand('<sfile>:h:h:h').'/bin/' let s:bin = { 'preview': expand('<sfile>:h:h:h').'/bin/preview.rb' }
let s:bin = { let s:TYPE = {'dict': type({}), 'funcref': type(function('call')), 'string': type('')}
\ 'preview': s:bin_dir.(executable('ruby') ? 'preview.rb' : 'preview.sh'),
\ 'tags': s:bin_dir.'tags.pl' }
let s:TYPE = {'dict': type({}), 'funcref': type(function('call')), 'string': type(''), 'list': type([])}
if s:is_win
if has('nvim')
let s:bin.preview = split(system('for %A in ("'.s:bin.preview.'") do echo %~sA'), "\n")[1]
else
let s:bin.preview = fnamemodify(s:bin.preview, ':8')
endif
let s:bin.preview = (executable('ruby') ? 'ruby' : 'bash').' '.escape(s:bin.preview, '\')
endif
function! s:extend_opts(dict, eopts, prepend) function s:remove_layout(opts)
if empty(a:eopts)
return
endif
if has_key(a:dict, 'options')
if type(a:dict.options) == s:TYPE.list && type(a:eopts) == s:TYPE.list
if a:prepend
let a:dict.options = extend(copy(a:eopts), a:dict.options)
else
call extend(a:dict.options, a:eopts)
endif
else
let all_opts = a:prepend ? [a:eopts, a:dict.options] : [a:dict.options, a:eopts]
let a:dict.options = join(map(all_opts, 'type(v:val) == s:TYPE.list ? join(map(copy(v:val), "fzf#shellescape(v:val)")) : v:val'))
endif
else
let a:dict.options = a:eopts
endif
endfunction
function! s:merge_opts(dict, eopts)
return s:extend_opts(a:dict, a:eopts, 0)
endfunction
function! s:prepend_opts(dict, eopts)
return s:extend_opts(a:dict, a:eopts, 1)
endfunction
" [[options to wrap], preview window expression, [toggle-preview keys...]]
function! fzf#vim#with_preview(...)
" Default options
let options = {}
let window = 'right'
let args = copy(a:000)
" Options to wrap
if len(args) && type(args[0]) == s:TYPE.dict
let options = copy(args[0])
call remove(args, 0)
endif
" Preview window
if len(args) && type(args[0]) == s:TYPE.string
if args[0] !~# '^\(up\|down\|left\|right\)'
throw 'invalid preview window: '.args[0]
endif
let window = args[0]
call remove(args, 0)
endif
let preview = ['--preview-window', window, '--preview', s:bin.preview.' '.(window =~ 'up\|down' ? '-v' : '').' {}']
if len(args)
call extend(preview, ['--bind', join(map(args, 'v:val.":toggle-preview"'), ',')])
endif
call s:merge_opts(options, preview)
return options
endfunction
function! s:remove_layout(opts)
for key in s:layout_keys for key in s:layout_keys
if has_key(a:opts, key) if has_key(a:opts, key)
call remove(a:opts, key) call remove(a:opts, key)
@@ -118,14 +46,15 @@ function! fzf#vim#wrap(opts)
return fzf#wrap(a:opts) return fzf#wrap(a:opts)
endfunction endfunction
" Deprecated
function! fzf#vim#layout(...)
return (a:0 && a:1) ? {} : copy(get(g:, 'fzf_layout', g:fzf#vim#default_layout))
endfunction
function! s:wrap(name, opts, bang) function! s:wrap(name, opts, bang)
" fzf#wrap does not append --expect if sink or sink* is found " fzf#wrap does not append --expect if sink or sink* is found
let opts = copy(a:opts) let opts = copy(a:opts)
let options = '' if get(opts, 'options', '') !~ '--expect' && has_key(opts, 'sink*')
if has_key(opts, 'options')
let options = type(opts.options) == s:TYPE.list ? join(opts.options) : opts.options
endif
if options !~ '--expect' && has_key(opts, 'sink*')
let Sink = remove(opts, 'sink*') let Sink = remove(opts, 'sink*')
let wrapped = fzf#wrap(a:name, opts, a:bang) let wrapped = fzf#wrap(a:name, opts, a:bang)
let wrapped['sink*'] = Sink let wrapped['sink*'] = Sink
@@ -147,6 +76,10 @@ function! s:escape(path)
return escape(a:path, ' $%#''"\') return escape(a:path, ' $%#''"\')
endfunction endfunction
function! s:q1(str)
return "'".substitute(a:str, "'", "'\\\\''", 'g')."'"
endfunction
if v:version >= 704 if v:version >= 704
function! s:function(name) function! s:function(name)
return function(a:name) return function(a:name)
@@ -159,12 +92,9 @@ else
endif endif
function! s:get_color(attr, ...) function! s:get_color(attr, ...)
let gui = has('termguicolors') && &termguicolors
let fam = gui ? 'gui' : 'cterm'
let pat = gui ? '^#[a-f0-9]\+' : '^[0-9]\+$'
for group in a:000 for group in a:000
let code = synIDattr(synIDtrans(hlID(group)), a:attr, fam) let code = synIDattr(synIDtrans(hlID(group)), a:attr, 'cterm')
if code =~? pat if code =~ '^[0-9]\+$'
return code return code
endif endif
endfor endfor
@@ -173,19 +103,11 @@ endfunction
let s:ansi = {'black': 30, 'red': 31, 'green': 32, 'yellow': 33, 'blue': 34, 'magenta': 35, 'cyan': 36} let s:ansi = {'black': 30, 'red': 31, 'green': 32, 'yellow': 33, 'blue': 34, 'magenta': 35, 'cyan': 36}
function! s:csi(color, fg)
let prefix = a:fg ? '38;' : '48;'
if a:color[0] == '#'
return prefix.'2;'.join(map([a:color[1:2], a:color[3:4], a:color[5:6]], 'str2nr(v:val, 16)'), ';')
endif
return prefix.'5;'.a:color
endfunction
function! s:ansi(str, group, default, ...) function! s:ansi(str, group, default, ...)
let fg = s:get_color('fg', a:group) let fg = s:get_color('fg', a:group)
let bg = s:get_color('bg', a:group) let bg = s:get_color('bg', a:group)
let color = s:csi(empty(fg) ? s:ansi[a:default] : fg, 1) . let color = (empty(fg) ? s:ansi[a:default] : ('38;5;'.fg)) .
\ (empty(bg) ? '' : s:csi(bg, 0)) \ (empty(bg) ? '' : (';48;5;'.bg))
return printf("\x1b[%s%sm%s\x1b[m", color, a:0 ? ';1' : '', a:str) return printf("\x1b[%s%sm%s\x1b[m", color, a:0 ? ';1' : '', a:str)
endfunction endfunction
@@ -196,7 +118,13 @@ for s:color_name in keys(s:ansi)
endfor endfor
function! s:buflisted() function! s:buflisted()
return filter(range(1, bufnr('$')), 'buflisted(v:val) && getbufvar(v:val, "&filetype") != "qf"') return filter(range(1, bufnr('$')), 'buflisted(v:val)')
endfunction
function! s:defaults()
let rules = copy(get(g:, 'fzf_colors', {}))
let colors = join(map(items(filter(map(rules, 'call("s:get_color", v:val)'), '!empty(v:val)')), 'join(v:val, ":")'), ',')
return empty(colors) ? '' : ('--color='.colors)
endfunction endfunction
function! s:fzf(name, opts, extra) function! s:fzf(name, opts, extra)
@@ -216,7 +144,7 @@ function! s:fzf(name, opts, extra)
let eopts = has_key(extra, 'options') ? remove(extra, 'options') : '' let eopts = has_key(extra, 'options') ? remove(extra, 'options') : ''
let merged = extend(copy(a:opts), extra) let merged = extend(copy(a:opts), extra)
call s:merge_opts(merged, eopts) let merged.options = join(filter([s:defaults(), get(merged, 'options', ''), eopts], '!empty(v:val)'))
return fzf#run(s:wrap(a:name, merged, bang)) return fzf#run(s:wrap(a:name, merged, bang))
endfunction endfunction
@@ -225,12 +153,6 @@ let s:default_action = {
\ 'ctrl-x': 'split', \ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' } \ 'ctrl-v': 'vsplit' }
function! s:action_for(key, ...)
let default = a:0 ? a:1 : ''
let Cmd = get(get(g:, 'fzf_action', s:default_action), a:key, default)
return type(Cmd) == s:TYPE.string ? Cmd : default
endfunction
function! s:open(cmd, target) function! s:open(cmd, target)
if stridx('edit', a:cmd) == 0 && fnamemodify(a:target, ':p') ==# expand('%:p') if stridx('edit', a:cmd) == 0 && fnamemodify(a:target, ':p') ==# expand('%:p')
return return
@@ -260,7 +182,7 @@ function! s:warn(message)
return 0 return 0
endfunction endfunction
function! fzf#vim#_uniq(list) function! s:uniq(list)
let visited = {} let visited = {}
let ret = [] let ret = []
for l in a:list for l in a:list
@@ -275,30 +197,19 @@ endfunction
" ------------------------------------------------------------------ " ------------------------------------------------------------------
" Files " Files
" ------------------------------------------------------------------ " ------------------------------------------------------------------
function! s:shortpath()
let short = fnamemodify(getcwd(), ':~:.')
if !has('win32unix')
let short = pathshorten(short)
endif
let slash = (s:is_win && !&shellslash) ? '\' : '/'
return empty(short) ? '~'.slash : short . (short =~ escape(slash, '\').'$' ? '' : slash)
endfunction
function! fzf#vim#files(dir, ...) function! fzf#vim#files(dir, ...)
let args = {} let args = {'options': '-m '.get(g:, 'fzf_files_options', '')}
if !empty(a:dir) if !empty(a:dir)
if !isdirectory(expand(a:dir)) if !isdirectory(expand(a:dir))
return s:warn('Invalid directory') return s:warn('Invalid directory')
endif endif
let slash = (s:is_win && !&shellslash) ? '\\' : '/' let dir = substitute(a:dir, '/*$', '/', '')
let dir = substitute(a:dir, '[/\\]*$', slash, '')
let args.dir = dir let args.dir = dir
let args.options .= ' --prompt '.shellescape(dir)
else else
let dir = s:shortpath() let args.options .= ' --prompt '.shellescape(pathshorten(getcwd())).'/'
endif endif
let args.options = ['-m', '--prompt', strwidth(dir) < &columns / 2 - 20 ? dir : '> ']
call s:merge_opts(args, get(g:, 'fzf_files_options', []))
return s:fzf('files', args, a:000) return s:fzf('files', args, a:000)
endfunction endfunction
@@ -310,7 +221,7 @@ function! s:line_handler(lines)
return return
endif endif
normal! m' normal! m'
let cmd = s:action_for(a:lines[0]) let cmd = get(get(g:, 'fzf_action', s:default_action), a:lines[0], '')
if !empty(cmd) && stridx('edit', cmd) < 0 if !empty(cmd) && stridx('edit', cmd) < 0
execute 'silent' cmd execute 'silent' cmd
endif endif
@@ -379,7 +290,7 @@ function! s:buffer_line_handler(lines)
return return
endif endif
normal! m' normal! m'
let cmd = s:action_for(a:lines[0]) let cmd = get(get(g:, 'fzf_action', s:default_action), a:lines[0], '')
if !empty(cmd) if !empty(cmd)
execute 'silent' cmd execute 'silent' cmd
endif endif
@@ -407,12 +318,9 @@ endfunction
" Colors " Colors
" ------------------------------------------------------------------ " ------------------------------------------------------------------
function! fzf#vim#colors(...) function! fzf#vim#colors(...)
let colors = split(globpath(&rtp, "colors/*.vim"), "\n")
if has('packages')
let colors += split(globpath(&packpath, "pack/*/opt/*/colors/*.vim"), "\n")
endif
return s:fzf('colors', { return s:fzf('colors', {
\ 'source': fzf#vim#_uniq(map(colors, "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')")), \ 'source': map(split(globpath(&rtp, "colors/*.vim"), "\n"),
\ "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')"),
\ 'sink': 'colo', \ 'sink': 'colo',
\ 'options': '+m --prompt="Colors> "' \ 'options': '+m --prompt="Colors> "'
\}, a:000) \}, a:000)
@@ -432,11 +340,9 @@ endfunction
" History[:/] " History[:/]
" ------------------------------------------------------------------ " ------------------------------------------------------------------
function! s:all_files() function! s:all_files()
return fzf#vim#_uniq(map( return extend(
\ filter([expand('%')], 'len(v:val)') \ filter(reverse(copy(v:oldfiles)), "filereadable(expand(v:val))"),
\ + filter(map(s:buflisted_sorted(), 'bufname(v:val)'), 'len(v:val)') \ filter(map(s:buflisted(), 'bufname(v:val)'), '!empty(v:val)'))
\ + filter(copy(v:oldfiles), "filereadable(expand(v:val))"),
\ 'fnamemodify(v:val, ":~:.")'))
endfunction endfunction
function! s:history_source(type) function! s:history_source(type)
@@ -490,8 +396,8 @@ endfunction
function! fzf#vim#history(...) function! fzf#vim#history(...)
return s:fzf('history-files', { return s:fzf('history-files', {
\ 'source': s:all_files(), \ 'source': reverse(s:all_files()),
\ 'options': ['-m', '--header-lines', !empty(expand('%')), '--prompt', 'Hist> '] \ 'options': '-m --prompt "Hist> "'
\}, a:000) \}, a:000)
endfunction endfunction
@@ -499,7 +405,14 @@ endfunction
" GFiles[?] " GFiles[?]
" ------------------------------------------------------------------ " ------------------------------------------------------------------
" helper function to get the git root. Uses vim-fugitive if available for EXTRA SPEED!
function! s:get_git_root() function! s:get_git_root()
if exists('*fugitive#repo')
try
return fugitive#repo().tree()
catch
endtry
endif
let root = split(system('git rev-parse --show-toplevel'), '\n')[0] let root = split(system('git rev-parse --show-toplevel'), '\n')[0]
return v:shell_error ? '' : root return v:shell_error ? '' : root
endfunction endfunction
@@ -511,7 +424,7 @@ function! fzf#vim#gitfiles(args, ...)
endif endif
if a:args != '?' if a:args != '?'
return s:fzf('gfiles', { return s:fzf('gfiles', {
\ 'source': 'git ls-files '.a:args.(s:is_win ? '' : ' | uniq'), \ 'source': 'git ls-files '.a:args,
\ 'dir': root, \ 'dir': root,
\ 'options': '-m --prompt "GitFiles> "' \ 'options': '-m --prompt "GitFiles> "'
\}, a:000) \}, a:000)
@@ -523,7 +436,7 @@ function! fzf#vim#gitfiles(args, ...)
let wrapped = fzf#wrap({ let wrapped = fzf#wrap({
\ 'source': 'git -c color.status=always status --short --untracked-files=all', \ 'source': 'git -c color.status=always status --short --untracked-files=all',
\ 'dir': root, \ 'dir': root,
\ 'options': ['--ansi', '--multi', '--nth', '2..,..', '--tiebreak=index', '--prompt', 'GitFiles?> ', '--preview', 'sh -c "(git diff --color=always -- {-1} | sed 1,4d; cat {-1}) | head -500"'] \ 'options': '--ansi --multi --nth 2..,.. --prompt "GitFiles?> " --preview ''sh -c "(git diff --color=always -- {-1} | sed 1,4d; cat {-1}) | head -500"'''
\}) \})
call s:remove_layout(wrapped) call s:remove_layout(wrapped)
let wrapped.common_sink = remove(wrapped, 'sink*') let wrapped.common_sink = remove(wrapped, 'sink*')
@@ -570,7 +483,7 @@ function! s:bufopen(lines)
return return
endif endif
endif endif
let cmd = s:action_for(a:lines[0]) let cmd = get(get(g:, 'fzf_action', s:default_action), a:lines[0], '')
if !empty(cmd) if !empty(cmd)
execute 'silent' cmd execute 'silent' cmd
endif endif
@@ -591,21 +504,16 @@ endfunction
function! s:sort_buffers(...) function! s:sort_buffers(...)
let [b1, b2] = map(copy(a:000), 'get(g:fzf#vim#buffers, v:val, v:val)') let [b1, b2] = map(copy(a:000), 'get(g:fzf#vim#buffers, v:val, v:val)')
" Using minus between a float and a number in a sort function causes an error " Using minus between a float and a number in a sort function causes an error
return b1 < b2 ? 1 : -1 return b1 > b2 ? 1 : -1
endfunction
function! s:buflisted_sorted()
return sort(s:buflisted(), 's:sort_buffers')
endfunction endfunction
function! fzf#vim#buffers(...) function! fzf#vim#buffers(...)
let [query, args] = (a:0 && type(a:1) == type('')) ? let bufs = map(sort(s:buflisted(), 's:sort_buffers'), 's:format_buffer(v:val)')
\ [a:1, a:000[1:]] : ['', a:000]
return s:fzf('buffers', { return s:fzf('buffers', {
\ 'source': map(s:buflisted_sorted(), 's:format_buffer(v:val)'), \ 'source': reverse(bufs),
\ 'sink*': s:function('s:bufopen'), \ 'sink*': s:function('s:bufopen'),
\ 'options': '+m -x --tiebreak=index --header-lines=1 --ansi -d "\t" -n 2,1..2 --prompt="Buf> "'.s:q(query) \ 'options': '+m -x --tiebreak=index --header-lines=1 --ansi -d "\t" -n 2,1..2 --prompt="Buf> "',
\}, args) \}, a:000)
endfunction endfunction
" ------------------------------------------------------------------ " ------------------------------------------------------------------
@@ -626,7 +534,7 @@ function! s:ag_handler(lines, with_column)
return return
endif endif
let cmd = s:action_for(a:lines[0], 'e') let cmd = get(get(g:, 'fzf_action', s:default_action), a:lines[0], 'e')
let list = map(filter(a:lines[1:], 'len(v:val)'), 's:ag_to_qf(v:val, a:with_column)') let list = map(filter(a:lines[1:], 'len(v:val)'), 's:ag_to_qf(v:val, a:with_column)')
if empty(list) if empty(list)
return return
@@ -658,15 +566,12 @@ function! fzf#vim#ag(query, ...)
let query = empty(a:query) ? '^(?=.)' : a:query let query = empty(a:query) ? '^(?=.)' : a:query
let args = copy(a:000) let args = copy(a:000)
let ag_opts = len(args) > 1 && type(args[0]) == s:TYPE.string ? remove(args, 0) : '' let ag_opts = len(args) > 1 && type(args[0]) == s:TYPE.string ? remove(args, 0) : ''
let command = ag_opts . ' ' . fzf#shellescape(query) let command = ag_opts . ' ' . s:q1(query)
return call('fzf#vim#ag_raw', insert(args, command, 0)) return call('fzf#vim#ag_raw', insert(args, command, 0))
endfunction endfunction
" ag command suffix, [options] " ag command suffix, [options]
function! fzf#vim#ag_raw(command_suffix, ...) function! fzf#vim#ag_raw(command_suffix, ...)
if !executable('ag')
return s:warn('ag is not found')
endif
return call('fzf#vim#grep', extend(['ag --nogroup --column --color '.a:command_suffix, 1], a:000)) return call('fzf#vim#grep', extend(['ag --nogroup --column --color '.a:command_suffix, 1], a:000))
endfunction endfunction
@@ -682,12 +587,19 @@ function! fzf#vim#grep(grep_command, with_column, ...)
let words = empty(words) ? ['grep'] : words let words = empty(words) ? ['grep'] : words
let name = join(words, '-') let name = join(words, '-')
let capname = join(map(words, 'toupper(v:val[0]).v:val[1:]'), '') let capname = join(map(words, 'toupper(v:val[0]).v:val[1:]'), '')
let textcol = a:with_column ? '4..' : '3..'
let preview = ''
if executable('ruby') && exists('g:fzf_grep_preview_window')
let preview = printf(' --preview-window %s --preview "%s"\ {1}\ {2}\ %d',
\ g:fzf_grep_preview_window,
\ shellescape(s:bin.preview), g:fzf_grep_preview_window =~ 'up\|down')
endif
let opts = { let opts = {
\ 'source': a:grep_command, \ 'source': a:grep_command,
\ 'column': a:with_column, \ 'column': a:with_column,
\ 'options': ['--ansi', '--prompt', capname.'> ', \ 'options': '--ansi --delimiter : --nth '.textcol.',.. --prompt "'.capname.'> " '.
\ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all', \ '--multi --bind alt-a:select-all,alt-d:deselect-all '.
\ '--color', 'hl:68,hl+:110'] \ '--color hl:68,hl+:110'.preview
\} \}
function! opts.sink(lines) function! opts.sink(lines)
return s:ag_handler(a:lines, self.column) return s:ag_handler(a:lines, self.column)
@@ -706,7 +618,7 @@ function! s:btags_source(tag_cmds)
for cmd in a:tag_cmds for cmd in a:tag_cmds
let lines = split(system(cmd), "\n") let lines = split(system(cmd), "\n")
if !v:shell_error && len(lines) if !v:shell_error
break break
endif endif
endfor endfor
@@ -723,7 +635,7 @@ function! s:btags_sink(lines)
return return
endif endif
normal! m' normal! m'
let cmd = s:action_for(a:lines[0]) let cmd = get(get(g:, 'fzf_action', s:default_action), a:lines[0], '')
if !empty(cmd) if !empty(cmd)
execute 'silent' cmd '%' execute 'silent' cmd '%'
endif endif
@@ -742,20 +654,15 @@ function! s:btags_sink(lines)
endfunction endfunction
function! s:q(query) function! s:q(query)
return ' --query '.fzf#shellescape(a:query) return ' --query '.s:q1(a:query)
endfunction endfunction
" query, [[tag commands], options] " query, [[tag commands], options]
function! fzf#vim#buffer_tags(query, ...) function! fzf#vim#buffer_tags(query, ...)
let args = copy(a:000) let args = copy(a:000)
let escaped = fzf#shellescape(expand('%')) let tag_cmds = len(args) > 1 ? remove(args, 0) : [
let null = s:is_win ? 'nul' : '/dev/null' \ printf('ctags -f - --sort=no --excmd=number --language-force=%s %s', &filetype, expand('%:S')),
let tag_cmds = (len(args) > 1 && type(args[0]) != type({})) ? remove(args, 0) : [ \ printf('ctags -f - --sort=no --excmd=number %s', expand('%:S'))]
\ printf('ctags -f - --sort=no --excmd=number --language-force=%s %s 2> %s', &filetype, escaped, null),
\ printf('ctags -f - --sort=no --excmd=number %s 2> %s', escaped, null)]
if type(tag_cmds) != type([])
let tag_cmds = [tag_cmds]
endif
try try
return s:fzf('btags', { return s:fzf('btags', {
\ 'source': s:btags_source(tag_cmds), \ 'source': s:btags_source(tag_cmds),
@@ -775,17 +682,14 @@ function! s:tags_sink(lines)
endif endif
normal! m' normal! m'
let qfl = [] let qfl = []
let cmd = s:action_for(a:lines[0], 'e') let cmd = get(get(g:, 'fzf_action', s:default_action), a:lines[0], 'e')
try try
let [magic, &magic, wrapscan, &wrapscan, acd, &acd] = [&magic, 0, &wrapscan, 1, &acd, 0] let [magic, &magic, wrapscan, &wrapscan] = [&magic, 0, &wrapscan, 1]
for line in a:lines[1:] for line in a:lines[1:]
try try
let parts = split(line, '\t\zs') let parts = split(line, '\t\zs')
let excmd = matchstr(join(parts[2:-2], '')[:-2], '^.*\ze;"\t') let excmd = matchstr(join(parts[2:], ''), '^.*\ze;"\t')
let base = fnamemodify(parts[-1], ':h') call s:open(cmd, parts[1][:-2])
let relpath = parts[1][:-2]
let abspath = relpath =~ (s:is_win ? '^[A-Z]:\' : '^/') ? relpath : join([base, relpath], '/')
call s:open(cmd, expand(abspath, 1))
execute excmd execute excmd
call add(qfl, {'filename': expand('%'), 'lnum': line('.'), 'text': getline('.')}) call add(qfl, {'filename': expand('%'), 'lnum': line('.'), 'text': getline('.')})
catch /^Vim:Interrupt$/ catch /^Vim:Interrupt$/
@@ -795,7 +699,7 @@ function! s:tags_sink(lines)
endtry endtry
endfor endfor
finally finally
let [&magic, &wrapscan, &acd] = [magic, wrapscan, acd] let [&magic, &wrapscan] = [magic, wrapscan]
endtry endtry
if len(qfl) > 1 if len(qfl) > 1
call setqflist(qfl) call setqflist(qfl)
@@ -807,9 +711,6 @@ function! s:tags_sink(lines)
endfunction endfunction
function! fzf#vim#tags(query, ...) function! fzf#vim#tags(query, ...)
if !executable('perl')
return s:warn('Tags command requires perl')
endif
if empty(tagfiles()) if empty(tagfiles())
call inputsave() call inputsave()
echohl WarningMsg echohl WarningMsg
@@ -817,9 +718,9 @@ function! fzf#vim#tags(query, ...)
echohl None echohl None
call inputrestore() call inputrestore()
redraw redraw
if gen =~? '^y' if gen =~ '^y'
call s:warn('Preparing tags') call s:warn('Preparing tags')
call system(get(g:, 'fzf_tags_command', 'ctags -R'.(s:is_win ? ' --output-format=e-ctags' : ''))) call system(get(g:, 'fzf_tags_command', 'ctags -R'))
if empty(tagfiles()) if empty(tagfiles())
return s:warn('Failed to create tags') return s:warn('Failed to create tags')
endif endif
@@ -828,20 +729,21 @@ function! fzf#vim#tags(query, ...)
endif endif
endif endif
let tagfiles = tagfiles() let tagfile = tagfiles()[0]
let v2_limit = 1024 * 1024 * 200 " We don't want to apply --ansi option when tags file is large as it makes
for tagfile in tagfiles " processing much slower.
let v2_limit -= getfsize(tagfile) if getfsize(tagfile) > 1024 * 1024 * 20
if v2_limit < 0 let proc = 'grep -v ''^\!'' '
break let copt = ''
endif else
endfor let proc = 'perl -ne ''unless (/^\!/) { s/^(.*?)\t(.*?)\t/'.s:yellow('\1', 'Function').'\t'.s:blue('\2', 'String').'\t/; print }'' '
let opts = v2_limit < 0 ? '--algo=v1 ' : '' let copt = '--ansi '
endif
return s:fzf('tags', { return s:fzf('tags', {
\ 'source': fzf#shellescape(s:bin.tags).' '.join(map(tagfiles, 'fzf#shellescape(fnamemodify(v:val, ":p"))')), \ 'source': proc.shellescape(fnamemodify(tagfile, ':t')),
\ 'sink*': s:function('s:tags_sink'), \ 'sink*': s:function('s:tags_sink'),
\ 'options': opts.'--nth 1..2 -m --tiebreak=begin --prompt "Tags> "'.s:q(a:query)}, a:000) \ 'dir': fnamemodify(tagfile, ':h'),
\ 'options': copt.'-m --tiebreak=begin --prompt "Tags> "'.s:q(a:query)}, a:000)
endfunction endfunction
" ------------------------------------------------------------------ " ------------------------------------------------------------------
@@ -944,7 +846,7 @@ function! s:mark_sink(lines)
if len(a:lines) < 2 if len(a:lines) < 2
return return
endif endif
let cmd = s:action_for(a:lines[0]) let cmd = get(get(g:, 'fzf_action', s:default_action), a:lines[0], '')
if !empty(cmd) if !empty(cmd)
execute 'silent' cmd execute 'silent' cmd
endif endif
@@ -975,22 +877,14 @@ function! s:helptag_sink(line)
endfunction endfunction
function! fzf#vim#helptags(...) function! fzf#vim#helptags(...)
if !executable('grep') || !executable('perl') let sorted = sort(split(globpath(&runtimepath, '**/doc/tags'), '\n'))
return s:warn('Helptags command requires grep and perl') let tags = exists('*uniq') ? uniq(sorted) : s:uniq(sorted)
endif
let sorted = sort(split(globpath(&runtimepath, 'doc/tags'), '\n'))
let tags = exists('*uniq') ? uniq(sorted) : fzf#vim#_uniq(sorted)
if exists('s:helptags_script')
silent! call delete(s:helptags_script)
endif
let s:helptags_script = tempname()
call writefile(['/('.(s:is_win ? '^[A-Z]:\/.*?[^:]' : '.*?').'):(.*?)\t(.*?)\t/; printf(qq('.s:green('%-40s', 'Label').'\t%s\t%s\n), $2, $3, $1)'], s:helptags_script)
return s:fzf('helptags', { return s:fzf('helptags', {
\ 'source': 'grep -H ".*" '.join(map(tags, 'fzf#shellescape(v:val)')). \ 'source': "grep -H '.*' ".join(map(tags, 'shellescape(v:val)')).
\ ' | perl -n '.fzf#shellescape(s:helptags_script).' | sort', \ "| perl -ne '/(.*?):(.*?)\t(.*?)\t/; printf(qq(".s:green('%-40s', 'Label')."\t%s\t%s\n), $2, $3, $1)' | sort",
\ 'sink': s:function('s:helptag_sink'), \ 'sink': s:function('s:helptag_sink'),
\ 'options': ['--ansi', '+m', '--tiebreak=begin', '--with-nth', '..-2']}, a:000) \ 'options': '--ansi +m --tiebreak=begin --with-nth ..-2'}, a:000)
endfunction endfunction
" ------------------------------------------------------------------ " ------------------------------------------------------------------
@@ -1047,13 +941,12 @@ function! s:commits_sink(lines)
return return
endif endif
let diff = a:lines[0] == 'ctrl-d' let cmd = get(extend({'ctrl-d': ''}, get(g:, 'fzf_action', s:default_action)), a:lines[0], 'e')
let cmd = s:action_for(a:lines[0], 'e')
let buf = bufnr('') let buf = bufnr('')
for idx in range(1, len(a:lines) - 1) for idx in range(1, len(a:lines) - 1)
let sha = matchstr(a:lines[idx], '[0-9a-f]\{7,9}') let sha = matchstr(a:lines[idx], '[0-9a-f]\{7}')
if !empty(sha) if !empty(sha)
if diff if empty(cmd)
if idx > 1 if idx > 1
execute 'tab sb' buf execute 'tab sb' buf
endif endif
@@ -1073,11 +966,11 @@ function! s:commits(buffer_local, args)
return s:warn('Not in git repository') return s:warn('Not in git repository')
endif endif
let source = 'git log '.get(g:, 'fzf_commits_log_options', '--color=always '.fzf#shellescape('--format=%C(auto)%h%d %s %C(green)%cr')) let source = 'git log '.get(g:, 'fzf_commits_log_options', '--graph --color=always --format="%C(auto)%h%d %s %C(green)%cr"')
let current = expand('%') let current = expand('%:S')
let managed = 0 let managed = 0
if !empty(current) if !empty(current)
call system('git show '.fzf#shellescape(current).' 2> '.(s:is_win ? 'nul' : '/dev/null')) call system('git show '.current.' 2> /dev/null')
let managed = !v:shell_error let managed = !v:shell_error
endif endif
@@ -1085,9 +978,7 @@ function! s:commits(buffer_local, args)
if !managed if !managed
return s:warn('The current buffer is not in the working tree') return s:warn('The current buffer is not in the working tree')
endif endif
let source .= ' --follow '.fzf#shellescape(current) let source .= ' --follow '.current
else
let source .= ' --graph'
endif endif
let command = a:buffer_local ? 'BCommits' : 'Commits' let command = a:buffer_local ? 'BCommits' : 'Commits'
@@ -1095,20 +986,15 @@ function! s:commits(buffer_local, args)
let options = { let options = {
\ 'source': source, \ 'source': source,
\ 'sink*': s:function('s:commits_sink'), \ 'sink*': s:function('s:commits_sink'),
\ 'options': ['--ansi', '--multi', '--tiebreak=index', '--reverse', \ 'options': '--ansi --multi --no-sort --tiebreak=index --reverse '.
\ '--inline-info', '--prompt', command.'> ', '--bind=ctrl-s:toggle-sort', \ '--inline-info --prompt "'.command.'> " --bind=ctrl-s:toggle-sort '.
\ '--header', ':: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort', \ '--expect='.expect_keys
\ '--expect='.expect_keys]
\ } \ }
if a:buffer_local if a:buffer_local
let options.options[-2] .= ', '.s:magenta('CTRL-D', 'Special').' to diff' let options.options .= ',ctrl-d --header ":: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort, '.s:magenta('CTRL-D', 'Special').' to diff"'
let options.options[-1] .= ',ctrl-d' else
endif let options.options .= ' --header ":: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort"'
if !s:is_win
call extend(options.options,
\ ['--preview', 'grep -o "[a-f0-9]\{7,\}" <<< {} | xargs git show --format=format: --color=always | head -200'])
endif endif
return s:fzf(a:buffer_local ? 'bcommits' : 'commits', options, a:args) return s:fzf(a:buffer_local ? 'bcommits' : 'commits', options, a:args)
@@ -1164,12 +1050,13 @@ function! fzf#vim#maps(mode, ...)
let list = [] let list = []
let curr = '' let curr = ''
for line in split(cout, "\n") for line in split(cout, "\n")
if line =~ "^\t" let src = matchstr(line, 'Last set from \zs.*')
let src = ' '.join(reverse(reverse(split(split(line)[-1], '/'))[0:2]), '/') if empty(src)
let curr = line[3:]
else
let src = ' '.join(reverse(reverse(split(src, '/'))[0:2]), '/')
call add(list, printf('%s %s', curr, s:green(src, 'Comment'))) call add(list, printf('%s %s', curr, s:green(src, 'Comment')))
let curr = '' let curr = ''
else
let curr = line[3:]
endif endif
endfor endfor
if !empty(curr) if !empty(curr)
@@ -1196,7 +1083,7 @@ endfunction
function! s:complete_trigger() function! s:complete_trigger()
let opts = copy(s:opts) let opts = copy(s:opts)
call s:prepend_opts(opts, ['+m', '-q', s:query]) let opts.options = printf('+m -q %s %s', shellescape(s:query), get(opts, 'options', ''))
let opts['sink*'] = s:function('s:complete_insert') let opts['sink*'] = s:function('s:complete_insert')
let s:reducer = s:pluck(opts, 'reducer', s:function('s:first_line')) let s:reducer = s:pluck(opts, 'reducer', s:function('s:first_line'))
call fzf#run(opts) call fzf#run(opts)
@@ -1241,20 +1128,16 @@ endfunction
function! fzf#vim#complete(...) function! fzf#vim#complete(...)
if a:0 == 0 if a:0 == 0
let s:opts = fzf#wrap() let s:opts = g:fzf#vim#default_layout
elseif type(a:1) == s:TYPE.dict elseif type(a:1) == s:TYPE.dict
let s:opts = copy(a:1) if has_key(a:1, 'sink') || has_key(a:1, 'sink*')
elseif type(a:1) == s:TYPE.string echoerr 'sink not allowed'
let s:opts = extend({'source': a:1}, get(a:000, 1, fzf#wrap())) return ''
else
echoerr 'Invalid argument: '.string(a:000)
return ''
endif
for s in ['sink', 'sink*']
if has_key(s:opts, s)
call remove(s:opts, s)
endif endif
endfor let s:opts = copy(a:1)
else
let s:opts = extend({'source': a:1}, g:fzf#vim#default_layout)
endif
let eol = col('$') let eol = col('$')
let ve = &ve let ve = &ve
@@ -1277,14 +1160,8 @@ 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')
call s:merge_opts(s:opts, remove(s:opts, 'extra_options')) let s:opts.options =
endif \ join(filter([get(s:opts, 'options', ''), remove(s:opts, 'extra_options')], '!empty(v:val)'))
if has_key(s:opts, 'options')
if type(s:opts.options) == s:TYPE.list
call add(s:opts.options, '--no-expect')
else
let s:opts.options .= ' --no-expect'
endif
endif endif
call feedkeys("\<Plug>(-fzf-complete-trigger)") call feedkeys("\<Plug>(-fzf-complete-trigger)")

View File

@@ -23,7 +23,6 @@
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)
@@ -49,7 +48,7 @@ endif
function! fzf#vim#complete#word(...) function! fzf#vim#complete#word(...)
return fzf#vim#complete(s:extend({ return fzf#vim#complete(s:extend({
\ 'source': 'cat /usr/share/dict/words'}, \ 'source': 'cat /usr/share/dict/words'},
\ get(a:000, 0, fzf#wrap()))) \ get(a:000, 0, g:fzf#vim#default_layout)))
endfunction endfunction
" ---------------------------------------------------------------------------- " ----------------------------------------------------------------------------
@@ -59,26 +58,25 @@ 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, '[/\\]*$', slash, ''), \ substitute(a:prefix, '/*$', '/', ''),
\ ''] : \ ''] :
\ [fnamemodify(expanded, ':h'), \ [fnamemodify(expanded, ':h'),
\ substitute(fnamemodify(a:prefix, ':h'), '[/\\]*$', slash, ''), \ substitute(fnamemodify(a:prefix, ':h'), '/*$', '/', ''),
\ 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", \ "cd %s && ".s:file_cmd." | sed 's:^:%s:'",
\ fzf#shellescape(dir), fzf#shellescape('s:^:'.(empty(a:prefix) || a:prefix == tail ? '' : head).':')) \ shellescape(dir), 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 ['--prompt', head, '--query', tail] return printf('--prompt %s --query %s', shellescape(head), shellescape(tail))
endfunction endfunction
function! s:fname_prefix(str) function! s:fname_prefix(str)
@@ -130,7 +128,7 @@ function! fzf#vim#complete#path(command, ...)
return fzf#vim#complete(s:extend({ return fzf#vim#complete(s:extend({
\ 'prefix': s:function('s:fname_prefix'), \ 'prefix': s:function('s:fname_prefix'),
\ 'source': s:function('s:file_source'), \ 'source': s:function('s:file_source'),
\ 'options': s:function('s:file_options')}, get(a:000, 0, fzf#wrap()))) \ 'options': s:function('s:file_options')}, get(a:000, 0, g:fzf#vim#default_layout)))
endfunction endfunction
" ---------------------------------------------------------------------------- " ----------------------------------------------------------------------------
@@ -149,13 +147,13 @@ function! fzf#vim#complete#line(...)
\ 'prefix': '^.*$', \ 'prefix': '^.*$',
\ 'source': lines, \ 'source': lines,
\ 'options': '--tiebreak=index --ansi --nth '.nth.'.. --tabstop=1', \ 'options': '--tiebreak=index --ansi --nth '.nth.'.. --tabstop=1',
\ 'reducer': s:function('s:reduce_line')}, get(a:000, 0, fzf#wrap()))) \ 'reducer': s:function('s:reduce_line')}, get(a:000, 0, g:fzf#vim#default_layout)))
endfunction endfunction
function! fzf#vim#complete#buffer_line(...) function! fzf#vim#complete#buffer_line(...)
return fzf#vim#complete(s:extend({ call fzf#vim#complete(s:extend({
\ 'prefix': '^.*$', \ 'prefix': '^.*$',
\ 'source': fzf#vim#_uniq(getline(1, '$'))}, get(a:000, 0, fzf#wrap()))) \ 'source': s:uniq(getline(1, '$'))}, get(a:000, 0, g:fzf#vim#default_layout)))
endfunction endfunction
let &cpo = s:cpo_save let &cpo = s:cpo_save

View File

@@ -1,52 +1,21 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# #
# usage: ./preview.rb [-v] FILENAME[:LINE][:IGNORED] # usage: ./preview.rb FILENAME LINENO VSPLIT(0|1)
require 'shellwords' require 'shellwords'
COMMAND = %[(highlight -O ansi -l {} || coderay {} || rougify {} || cat {}) 2> /dev/null] COMMAND = %[(highlight -O ansi -l {} || coderay {} || cat {}) 2> /dev/null]
ANSI = /\x1b\[[0-9;]*m/ ANSI = /\x1b\[[0-9;]*m/
REVERSE = "\x1b[7m" REVERSE = "\x1b[7m"
RESET = "\x1b[m" RESET = "\x1b[m"
split = ARGV.delete('-v') file, center, split = ARGV.fetch(0), ARGV.fetch(1).to_i, ARGV.fetch(2) == '1'
height = File.readable?('/dev/tty') ? `stty size < /dev/tty`.split.first.to_i : 40
def usage height /= 2 if split
puts "usage: #$0 [-v] FILENAME[:LINENO][:IGNORED]" height -= 2 # preview border
exit 1
end
usage if ARGV.empty?
file, center, extra = ARGV.first.split(':')
if ARGV.first =~ /^[A-Z]:\\/
file << ':' + center
center = extra
end
usage unless file
path = File.expand_path(file)
unless File.readable? path
puts "File not found: #{file}"
exit 1
end
if `file --mime "#{file}"` =~ /binary/
puts "#{file} is a binary file"
exit 0
end
center = (center || 0).to_i
if ENV['FZF_PREVIEW_HEIGHT']
height = ENV['FZF_PREVIEW_HEIGHT'].to_i
else
height = File.readable?('/dev/tty') ? `stty size < /dev/tty`.split.first.to_i : 40
height /= 2 if split
height -= 2 # preview border
end
offset = [1, center - height / 3].max offset = [1, center - height / 3].max
IO.popen(['sh', '-c', COMMAND.gsub('{}', Shellwords.shellescape(path))]) do |io| IO.popen(['sh', '-c', COMMAND.gsub('{}', Shellwords.shellescape(file))]) do |io|
io.each_line.drop(offset - 1).take(height).each_with_index do |line, lno| io.each_line.drop(offset - 1).take(height).each_with_index do |line, lno|
if lno + offset == center if lno + offset == center
puts REVERSE + line.chomp.gsub(ANSI) { |m| m + REVERSE } + RESET puts REVERSE + line.chomp.gsub(ANSI) { |m| m + REVERSE } + RESET

View File

@@ -1,57 +0,0 @@
#!/bin/bash
REVERSE="\x1b[7m"
RESET="\x1b[m"
if [ "$1" == "-v" ]; then
SPLIT=1
shift
fi
if [ -z "$1" ]; then
echo "usage: $0 [-v] FILENAME[:LINENO][:IGNORED]"
exit 1
fi
IFS=':' read -r -a INPUT <<< "$1"
FILE=${INPUT[0]}
CENTER=${INPUT[1]}
if [[ $1 =~ ^[A-Z]:\\ ]]; then
FILE=$FILE:${INPUT[1]}
CENTER=${INPUT[2]}
fi
if [ ! -r "$FILE" ]; then
echo "File not found ${FILE}"
exit 1
fi
if [[ "$(file --mime "$FILE")" =~ binary ]]; then
echo "$1 is a binary file"
exit 0
fi
if [ -z "$CENTER" ]; then
CENTER=1
fi
if [ -n "$FZF_PREVIEW_HEIGHT" ]; then
LINES=$FZF_PREVIEW_HEIGHT
else
if [ -r /dev/tty ]; then
LINES=$(stty size < /dev/tty | awk '{print $1}')
else
LINES=40
fi
if [ -n "$SPLIT" ]; then
LINES=$(($LINES/2)) # using horizontal split
fi
LINES=$(($LINES-2)) # remove preview border
fi
FIRST=$(($CENTER-$LINES/3))
FIRST=$(($FIRST < 1 ? 1 : $FIRST))
LAST=$((${FIRST}+${LINES}-1))
awk "NR >= $FIRST && NR <= $LAST {if (NR == $CENTER) printf(\"$REVERSE%5d %s\n$RESET\", NR, \$0); else printf(\"%5d %s\n\", NR, \$0)}" $FILE

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env perl
use strict;
foreach my $file (@ARGV) {
open my $lines, $file;
while (<$lines>) {
unless (/^\!/) {
s/^[^\t]*/sprintf("%-24s", $&)/e;
s/$/\t$file/;
print;
}
}
close $lines;
}

View File

@@ -1,4 +1,4 @@
fzf-vim.txt fzf-vim Last change: October 21 2017 fzf-vim.txt fzf-vim Last change: September 20 2015
FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc* FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc*
============================================================================== ==============================================================================
@@ -8,14 +8,10 @@ FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-to
Installation Installation
Commands Commands
Customization Customization
Global options
Command-local options
Advanced customization
Mappings Mappings
Usage Usage
Completion helper Completion helper
Reducer example Reducer example
Status line (neovim)
License License
FZF :HEART: VIM *fzf-vim-fzf-heart-vim* FZF :HEART: VIM *fzf-vim-fzf-heart-vim*
@@ -57,48 +53,35 @@ selector with fzf.
fzf is an independent command-line program and thus requires an external fzf is an independent command-line program and thus requires an external
terminal emulator when on GVim. You may or may not like the experience. Also terminal emulator when on GVim. You may or may not like the experience. Also
note that Windows support is experimental at the moment. note that fzf currently does not compile on Windows.
INSTALLATION *fzf-vim-installation* INSTALLATION *fzf-vim-installation*
============================================================================== ==============================================================================
Use {vim-plug}{4} or any Vim plugin manager of your choice. Using {vim-plug}{4}:
If you already installed fzf using {Homebrew}{5}, the following should
suffice:
> >
Plug '/usr/local/opt/fzf' Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
Plug 'junegunn/fzf.vim' Plug 'junegunn/fzf.vim'
< <
But if you want to install fzf as well using vim-plug:
>
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
<
- `dir` and `do` options are not mandatory
- Use `./install--bin` instead if you don't need fzf outside of Vim
- Make sure to use Vim 7.4 or above
{4} https://github.com/junegunn/vim-plug {4} https://github.com/junegunn/vim-plug
{5} https://brew.sh/
COMMANDS *fzf-vim-commands* COMMANDS *fzf-vim-commands*
============================================================================== ==============================================================================
-----------------+----------------------------------------------------------------------- -----------------+-------------------------------------------------------------------
Command | List ~ Command | List ~
-----------------+----------------------------------------------------------------------- -----------------+-------------------------------------------------------------------
`Files[PATH]` | Files (similar to `:FZF` ) `Files[PATH]` | Files (similar to `:FZF` )
`GFiles[OPTS]` | Git files ( `gitls-files` ) `GFiles [OPTS]` | Git files (git ls-files)
`GFiles?` | Git files ( `gitstatus` ) `GFiles?` | Git files (git status)
`Buffers` | Open buffers `Buffers` | Open buffers
`Colors` | Color schemes `Colors` | Color schemes
`Ag[PATTERN]` | {ag}{6} search result ( `ALT-A` to select all, `ALT-D` to deselect all) `Ag[PATTERN]` | {ag}{5} search result (ALT-A to select all, ALT-D to deselect all)
`Lines[QUERY]` | Lines in loaded buffers `Lines [QUERY]` | Lines in loaded buffers
`BLines[QUERY]` | Lines in the current buffer `BLines [QUERY]` | Lines in the current buffer
`Tags[QUERY]` | Tags in the project ( `ctags-R` ) `Tags[QUERY]` | Tags in the project ( `ctags-R` )
`BTags[QUERY]` | Tags in the current buffer `BTags[QUERY]` | Tags in the current buffer
`Marks` | Marks `Marks` | Marks
@@ -107,40 +90,36 @@ COMMANDS *fzf-vim-commands*
`History` | `v:oldfiles` and open buffers `History` | `v:oldfiles` and open buffers
`History:` | Command history `History:` | Command history
`History/` | Search history `History/` | Search history
`Snippets` | Snippets ({UltiSnips}{7}) `Snippets` | Snippets ({UltiSnips}{6})
`Commits` | Git commits (requires {fugitive.vim}{8}) `Commits` | Git commits (requires {fugitive.vim}{7})
`BCommits` | Git commits for the current buffer `BCommits` | Git commits for the current buffer
`Commands` | Commands `Commands` | Commands
`Maps` | Normal mode mappings `Maps` | Normal mode mappings
`Helptags` | Help tags [1] `Helptags` | Help tags [1]
`Filetypes` | File types `Filetypes` | File types
-----------------+----------------------------------------------------------------------- -----------------+-------------------------------------------------------------------
*g:fzf_command_prefix*
- Most commands support CTRL-T / CTRL-X / CTRL-V key bindings to open in a new - Most commands support CTRL-T / CTRL-X / CTRL-V key bindings to open in a new
tab, a new split, or in a new vertical split tab, a new split, or in a new vertical split
- Bang-versions of the commands (e.g. `Ag!`) will open fzf in fullscreen - Bang-versions of the commands (e.g. `Ag!`) will open fzf in fullscreen
- You can set `g:fzf_command_prefix` to give the same prefix to the commands - You can set `g:fzf_command_prefix` to give the same prefix to the commands
- e.g. `letg:fzf_command_prefix='Fzf'` and you have `FzfFiles`, etc. - e.g. `let g:fzf_command_prefix = 'Fzf'` and you have `FzfFiles`, etc.
(1: `Helptags` will shadow the command of the same name from {pathogen}{9}. (1: `Helptags` will shadow the command of the same name from {pathogen}{8}.
But its functionality is still available via `call pathogen#helptags()`.) But its functionality is still available via `call pathogen#helptags()`.)
{6} https://github.com/ggreer/the_silver_searcher {5} https://github.com/ggreer/the_silver_searcher
{7} https://github.com/SirVer/ultisnips {6} https://github.com/SirVer/ultisnips
{8} https://github.com/tpope/vim-fugitive {7} https://github.com/tpope/vim-fugitive
{9} https://github.com/tpope/vim-pathogen {8} https://github.com/tpope/vim-pathogen
< Customization >_____________________________________________________________~ < Customization >_____________________________________________________________~
*fzf-vim-customization* *fzf-vim-customization*
*g:fzf_action* *g:fzf_layout* *g:fzf_colors* *g:fzf_commits_log_options*
Global options~ Global options~
*fzf-vim-global-options*
See {README-VIM.md}{10} of the main fzf repository for details.
> >
" This is the default extra key bindings " This is the default extra key bindings
let g:fzf_action = { let g:fzf_action = {
@@ -155,7 +134,6 @@ See {README-VIM.md}{10} of the main fzf repository for details.
" In Neovim, you can set up fzf window using a Vim command " In Neovim, you can set up fzf window using a Vim command
let g:fzf_layout = { 'window': 'enew' } let g:fzf_layout = { 'window': 'enew' }
let g:fzf_layout = { 'window': '-tabnew' } let g:fzf_layout = { 'window': '-tabnew' }
let g:fzf_layout = { 'window': '10split enew' }
" Customize fzf colors to match your color scheme " Customize fzf colors to match your color scheme
let g:fzf_colors = let g:fzf_colors =
@@ -166,7 +144,6 @@ See {README-VIM.md}{10} of the main fzf repository for details.
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'], \ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'], \ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'], \ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'], \ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'], \ 'marker': ['fg', 'Keyword'],
@@ -179,20 +156,21 @@ See {README-VIM.md}{10} of the main fzf repository for details.
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS. " explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history' let g:fzf_history_dir = '~/.local/share/fzf-history'
< <
{10} https://github.com/junegunn/fzf/blob/master/README-VIM.md#configuration
Command-local options~ Command-local options~
*fzf-vim-command-local-options*
*g:fzf_buffers_jump* *g:fzf_commits_log_options* *g:fzf_tags_command*
*g:fzf_commands_expect*
> >
" [Files] Extra options for fzf
" e.g. File preview using coderay (http://coderay.rubychan.de/)
let g:fzf_files_options =
\ '--preview "(coderay {} || cat {}) 2> /dev/null | head -'.&lines.'"'
" [Buffers] Jump to the existing window if possible " [Buffers] Jump to the existing window if possible
let g:fzf_buffers_jump = 1 let g:fzf_buffers_jump = 1
" [[B]Commits] Customize the options used by 'git log': " [[B]Commits] Customize the options used by 'git log':
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"' let g:fzf_commits_log_options = \
'--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
" [Tags] Command to generate tags file " [Tags] Command to generate tags file
let g:fzf_tags_command = 'ctags -R' let g:fzf_tags_command = 'ctags -R'
@@ -201,49 +179,20 @@ Command-local options~
let g:fzf_commands_expect = 'alt-enter,ctrl-x' let g:fzf_commands_expect = 'alt-enter,ctrl-x'
< <
Advanced customization~ Advanced customization using autoload functions~
*fzf-vim-advanced-customization*
You can use autoload functions to define your own commands. You can use autoload functions to define your own commands.
> >
" Command for git grep " git grep
" - fzf#vim#grep(command, with_column, [options], [fullscreen])
command! -bang -nargs=* GGrep command! -bang -nargs=* GGrep
\ call fzf#vim#grep('git grep --line-number '.shellescape(<q-args>), 0, <bang>0) \ call fzf#vim#grep('git grep --line-number '.shellescape(<q-args>), 0, <bang>0)
" Override Colors command. You can safely do this in your .vimrc as fzf.vim " We use VimEnter event so that the code is run after fzf.vim is loaded
" will not override existing commands. autocmd VimEnter * command! Colors
command! -bang Colors \ call fzf#vim#colors({'left': '15%', 'options': '--reverse --margin 30%,0'})
\ call fzf#vim#colors({'left': '15%', 'options': '--reverse --margin 30%,0'}, <bang>0)
" Augmenting Ag command using fzf#vim#with_preview function
" * fzf#vim#with_preview([[options], preview window, [toggle keys...]])
" * For syntax-highlighting, Ruby and any of the following tools are required:
" - Highlight: http://www.andre-simon.de/doku/highlight/en/highlight.php
" - CodeRay: http://coderay.rubychan.de/
" - Rouge: https://github.com/jneen/rouge
"
" :Ag - Start fzf with hidden preview window that can be enabled with "?" key
" :Ag! - Start fzf in fullscreen and display the preview window above
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
" Similarly, we can apply it to fzf#vim#grep. To use ripgrep instead of ag:
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
" Likewise, Files command with preview window
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
< <
MAPPINGS *fzf-vim-mappings* MAPPINGS *fzf-vim-mappings*
============================================================================== ==============================================================================
@@ -302,7 +251,7 @@ following exceptions:
- Or a function to extract completion prefix - Or a function to extract completion prefix
- Both `source` and `options` can be given as funcrefs that take the completion - Both `source` and `options` can be given as funcrefs that take the completion
prefix as the argument and return the final value prefix as the argument and return the final value
- `sink` or `sink*` are ignored - `sink` or `sink*` are not allowed
Reducer example~ Reducer example~
@@ -319,20 +268,6 @@ Reducer example~
\ 'left': 20}) \ 'left': 20})
< <
STATUS LINE (NEOVIM) *fzf-vim-status-lineneovim*
==============================================================================
>
function! s:fzf_statusline()
" Override statusline as you like
highlight fzf1 ctermfg=161 ctermbg=251
highlight fzf2 ctermfg=23 ctermbg=251
highlight fzf3 ctermfg=237 ctermbg=251
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
endfunction
autocmd! User FzfStatusLine call <SID>fzf_statusline()
<
LICENSE *fzf-vim-license* LICENSE *fzf-vim-license*
============================================================================== ==============================================================================

View File

@@ -23,7 +23,8 @@
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim set cpo&vim
let s:is_win = has('win32') || has('win64')
let g:fzf#vim#default_layout = {'down': '~40%'}
function! s:defs(commands) function! s:defs(commands)
let prefix = get(g:, 'fzf_command_prefix', '') let prefix = get(g:, 'fzf_command_prefix', '')
@@ -32,35 +33,32 @@ function! s:defs(commands)
return return
endif endif
for command in a:commands for command in a:commands
let name = ':'.prefix.matchstr(command, '\C[A-Z]\S\+') execute substitute(command, '\ze\C[A-Z]', prefix, '')
if 2 != exists(name)
execute substitute(command, '\ze\C[A-Z]', prefix, '')
endif
endfor endfor
endfunction endfunction
call s:defs([ call s:defs([
\'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, <bang>0)', \'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, <bang>0)',
\'command! -bang -nargs=? GitFiles call fzf#vim#gitfiles(<q-args>, <bang>0)', \'command! -bang -nargs=? GitFiles call fzf#vim#gitfiles(<q-args>, <bang>0)',
\'command! -bang -nargs=? GFiles call fzf#vim#gitfiles(<q-args>, <bang>0)', \'command! -bang -nargs=? GFiles call fzf#vim#gitfiles(<q-args>, <bang>0)',
\'command! -bar -bang -nargs=? -complete=buffer Buffers call fzf#vim#buffers(<q-args>, <bang>0)', \'command! -bang Buffers call fzf#vim#buffers(<bang>0)',
\'command! -bang -nargs=* Lines call fzf#vim#lines(<q-args>, <bang>0)', \'command! -bang -nargs=* Lines call fzf#vim#lines(<q-args>, <bang>0)',
\'command! -bang -nargs=* BLines call fzf#vim#buffer_lines(<q-args>, <bang>0)', \'command! -bang -nargs=* BLines call fzf#vim#buffer_lines(<q-args>, <bang>0)',
\'command! -bar -bang Colors call fzf#vim#colors(<bang>0)', \'command! -bang Colors call fzf#vim#colors(<bang>0)',
\'command! -bang -nargs=+ -complete=dir Locate call fzf#vim#locate(<q-args>, <bang>0)', \'command! -bang -nargs=+ -complete=dir Locate call fzf#vim#locate(<q-args>, <bang>0)',
\'command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, <bang>0)', \'command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, <bang>0)',
\'command! -bang -nargs=* Tags call fzf#vim#tags(<q-args>, <bang>0)', \'command! -bang -nargs=* Tags call fzf#vim#tags(<q-args>, <bang>0)',
\'command! -bang -nargs=* BTags call fzf#vim#buffer_tags(<q-args>, <bang>0)', \'command! -bang -nargs=* BTags call fzf#vim#buffer_tags(<q-args>, <bang>0)',
\'command! -bar -bang Snippets call fzf#vim#snippets(<bang>0)', \'command! -bang Snippets call fzf#vim#snippets(<bang>0)',
\'command! -bar -bang Commands call fzf#vim#commands(<bang>0)', \'command! -bang Commands call fzf#vim#commands(<bang>0)',
\'command! -bar -bang Marks call fzf#vim#marks(<bang>0)', \'command! -bang Marks call fzf#vim#marks(<bang>0)',
\'command! -bar -bang Helptags call fzf#vim#helptags(<bang>0)', \'command! -bang Helptags call fzf#vim#helptags(<bang>0)',
\'command! -bar -bang Windows call fzf#vim#windows(<bang>0)', \'command! -bang Windows call fzf#vim#windows(<bang>0)',
\'command! -bar -bang Commits call fzf#vim#commits(<bang>0)', \'command! -bang Commits call fzf#vim#commits(<bang>0)',
\'command! -bar -bang BCommits call fzf#vim#buffer_commits(<bang>0)', \'command! -bang BCommits call fzf#vim#buffer_commits(<bang>0)',
\'command! -bar -bang Maps call fzf#vim#maps("n", <bang>0)', \'command! -bang Maps call fzf#vim#maps("n", <bang>0)',
\'command! -bar -bang Filetypes call fzf#vim#filetypes(<bang>0)', \'command! -bang Filetypes call fzf#vim#filetypes(<bang>0)',
\'command! -bang -nargs=* History call s:history(<q-args>, <bang>0)']) \'command! -bang -nargs=* History call s:history(<q-args>, <bang>0)'])
function! s:history(arg, bang) function! s:history(arg, bang)
let bang = a:bang || a:arg[len(a:arg)-1] == '!' let bang = a:bang || a:arg[len(a:arg)-1] == '!'
@@ -83,13 +81,13 @@ if has('nvim') && get(g:, 'fzf_nvim_statusline', 1)
doautocmd User FzfStatusLine doautocmd User FzfStatusLine
else else
if $TERM !~ "256color" if $TERM !~ "256color"
highlight default fzf1 ctermfg=1 ctermbg=8 guifg=#E12672 guibg=#565656 highlight fzf1 ctermfg=1 ctermbg=8 guifg=#E12672 guibg=#565656
highlight default fzf2 ctermfg=2 ctermbg=8 guifg=#BCDDBD guibg=#565656 highlight fzf2 ctermfg=2 ctermbg=8 guifg=#BCDDBD guibg=#565656
highlight default fzf3 ctermfg=7 ctermbg=8 guifg=#D9D9D9 guibg=#565656 highlight fzf3 ctermfg=7 ctermbg=8 guifg=#D9D9D9 guibg=#565656
else else
highlight default fzf1 ctermfg=161 ctermbg=238 guifg=#E12672 guibg=#565656 highlight fzf1 ctermfg=161 ctermbg=238 guifg=#E12672 guibg=#565656
highlight default fzf2 ctermfg=151 ctermbg=238 guifg=#BCDDBD guibg=#565656 highlight fzf2 ctermfg=151 ctermbg=238 guifg=#BCDDBD guibg=#565656
highlight default fzf3 ctermfg=252 ctermbg=238 guifg=#D9D9D9 guibg=#565656 highlight fzf3 ctermfg=252 ctermbg=238 guifg=#D9D9D9 guibg=#565656
endif endif
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
endif endif
@@ -124,14 +122,9 @@ 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()
if s:is_win inoremap <expr> <plug>(fzf-complete-path) fzf#vim#complete#path("find . -path '*/\.*' -prune -o -print \| sed '1d;s:^..::'")
inoremap <expr> <plug>(fzf-complete-path) fzf#vim#complete#path('dir /s/b') 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) fzf#vim#complete#path('dir /s/b/a:-d') inoremap <expr> <plug>(fzf-complete-file-ag) fzf#vim#complete#path("ag -l -g ''")
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()