diff --git a/README.md b/README.md index 28cba80..05a4bbc 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ so you can omit it if you use a plugin manager that doesn't support hooks. ### Dependencies +- [fzf][fzf-main] 0.22.0 or above - For syntax-highlighted preview, install [bat](https://github.com/sharkdp/bat) - `Ag` requires [The Silver Searcher (ag)][ag] - `Rg` requires [ripgrep (rg)][rg] diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index 9aa48da..fa1d43d 100644 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -584,7 +584,7 @@ function! fzf#vim#gitfiles(args, ...) let wrapped = fzf#wrap({ \ 'source': 'git -c color.status=always status --short --untracked-files=all', \ '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..,..', '--tiebreak=index', '--prompt', 'GitFiles?> ', '--preview', 'sh -c "(git diff --color=always -- {-1} | sed 1,4d; cat {-1}) | head -1000"'] \}) call s:remove_layout(wrapped) let wrapped.common_sink = remove(wrapped, 'sink*') @@ -648,7 +648,7 @@ function! fzf#vim#_format_buffer(b) let readonly = getbufvar(a:b, '&modifiable') ? '' : s:green(' [RO]', 'Constant') let extra = join(filter([modified, readonly], '!empty(v:val)'), '') let target = line == 0 ? name : name.':'.line - return s:strip(printf("%s\t[%s] %s\t%s\t%s", target, s:yellow(a:b, 'Number'), flag, name, extra)) + return s:strip(printf("%s\t%d\t[%s] %s\t%s\t%s", target, line, s:yellow(a:b, 'Number'), flag, name, extra)) endfunction function! s:sort_buffers(...) @@ -667,7 +667,7 @@ function! fzf#vim#buffers(...) return s:fzf('buffers', { \ 'source': map(fzf#vim#_buflisted_sorted(), 'fzf#vim#_format_buffer(v:val)'), \ 'sink*': s:function('s:bufopen'), - \ 'options': ['+m', '-x', '--tiebreak=index', '--header-lines=1', '--ansi', '-d', '\t', '--with-nth', '2..', '-n', '2,1..2', '--prompt', 'Buf> ', '--query', query] + \ 'options': ['+m', '-x', '--tiebreak=index', '--header-lines=1', '--ansi', '-d', '\t', '--with-nth', '3..', '-n', '2,1..2', '--prompt', 'Buf> ', '--query', query, '--preview-window', '+{2}-5'] \}, args) endfunction @@ -744,6 +744,7 @@ function! fzf#vim#grep(grep_command, has_column, ...) \ 'column': a:has_column, \ 'options': ['--ansi', '--prompt', capname.'> ', \ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all', + \ '--delimiter', ':', '--preview-window', '+{2}-5', \ '--color', 'hl:4,hl+:12'] \} function! opts.sink(lines) @@ -815,7 +816,7 @@ function! fzf#vim#buffer_tags(query, ...) return s:fzf('btags', { \ 'source': s:btags_source(tag_cmds), \ 'sink*': s:function('s:btags_sink'), - \ 'options': s:reverse_list(['-m', '-d', '\t', '--with-nth', '1,4..', '-n', '1', '--prompt', 'BTags> ', '--query', a:query])}, args) + \ 'options': s:reverse_list(['-m', '-d', '\t', '--with-nth', '1,4..', '-n', '1', '--prompt', 'BTags> ', '--query', a:query, '--preview-window', '+{3}-5'])}, args) catch return s:warn(v:exception) endtry @@ -1173,7 +1174,7 @@ function! s:commits(buffer_local, args) if !s:is_win && &columns > s:wide call extend(options.options, - \ ['--preview', 'echo {} | grep -o "[a-f0-9]\{7,\}" | head -1 | xargs git show --format=format: --color=always | head -200']) + \ ['--preview', 'echo {} | grep -o "[a-f0-9]\{7,\}" | head -1 | xargs git show --format=format: --color=always | head -1000']) endif return s:fzf(a:buffer_local ? 'bcommits' : 'commits', options, a:args) diff --git a/bin/preview.sh b/bin/preview.sh index ed08075..13bc142 100755 --- a/bin/preview.sh +++ b/bin/preview.sh @@ -39,23 +39,9 @@ if [ -z "$CENTER" ]; then CENTER=0 fi -if [ -n "$FZF_PREVIEW_LINES" ]; then - LINES=$FZF_PREVIEW_LINES -else - if [ -r /dev/tty ]; then - LINES=$(stty size < /dev/tty | awk '{print $1}') - else - LINES=40 - fi -fi - -FIRST=$(($CENTER-$LINES/3)) -FIRST=$(($FIRST < 1 ? 1 : $FIRST)) -LAST=$((${FIRST}+${LINES}-1)) - if [ -z "$FZF_PREVIEW_COMMAND" ] && command -v bat > /dev/null; then bat --style="${BAT_STYLE:-numbers}" --color=always --pager=never \ - --line-range=$FIRST:$LAST --highlight-line=$CENTER "$FILE" + --highlight-line=$CENTER "$FILE" exit $? fi @@ -63,7 +49,7 @@ DEFAULT_COMMAND="highlight -O ansi -l {} || coderay {} || rougify {} || cat {}" CMD=${FZF_PREVIEW_COMMAND:-$DEFAULT_COMMAND} CMD=${CMD//{\}/$(printf %q "$FILE")} -eval "$CMD" 2> /dev/null | awk "NR >= $FIRST && NR <= $LAST { \ +eval "$CMD" 2> /dev/null | awk "{ \ if (NR == $CENTER) \ { gsub(/\x1b[[0-9;]*m/, \"&$REVERSE\"); printf(\"$REVERSE%s\n$RESET\", \$0); } \ else printf(\"$RESET%s\n\", \$0); \ diff --git a/doc/fzf-vim.txt b/doc/fzf-vim.txt index c2278ad..b32ae75 100644 --- a/doc/fzf-vim.txt +++ b/doc/fzf-vim.txt @@ -1,4 +1,4 @@ -fzf-vim.txt fzf-vim Last change: July 27 2020 +fzf-vim.txt fzf-vim Last change: August 12 2020 FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc* ============================================================================== @@ -90,11 +90,13 @@ so you can omit it if you use a plugin manager that doesn't support hooks. < Dependencies >______________________________________________________________~ *fzf-vim-dependencies* + - {fzf}{1} 0.22.0 or above - For syntax-highlighted preview, install {bat}{5} - `Ag` requires {The Silver Searcher (ag)}{6} - `Rg` requires {ripgrep (rg)}{7} - `Tags` and `Helptags` require Perl + {1} https://github.com/junegunn/fzf {5} https://github.com/sharkdp/bat {6} https://github.com/ggreer/the_silver_searcher {7} https://github.com/BurntSushi/ripgrep diff --git a/plugin/fzf.vim b/plugin/fzf.vim index d039ed4..2565d40 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -51,7 +51,7 @@ call s:defs([ \'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(, s:p(0), 0)', \'command! -bang -nargs=? GitFiles call fzf#vim#gitfiles(, == "?" ? {} : s:p(0), 0)', \'command! -bang -nargs=? GFiles call fzf#vim#gitfiles(, == "?" ? {} : s:p(0), 0)', -\'command! -bar -bang -nargs=? -complete=buffer Buffers call fzf#vim#buffers(, s:p(0, { "placeholder": "{1}", "options": ["-d", "\t"] }), 0)', +\'command! -bar -bang -nargs=? -complete=buffer Buffers call fzf#vim#buffers(, s:p(0, { "placeholder": "{1}" }), 0)', \'command! -bang -nargs=* Lines call fzf#vim#lines(, 0)', \'command! -bang -nargs=* BLines call fzf#vim#buffer_lines(, 0)', \'command! -bar -bang Colors call fzf#vim#colors(0)', @@ -59,7 +59,7 @@ call s:defs([ \'command! -bang -nargs=* Ag call fzf#vim#ag(, s:p(0), 0)', \'command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case -- ".shellescape(), 1, s:p(0), 0)', \'command! -bang -nargs=* Tags call fzf#vim#tags(, 0)', -\'command! -bang -nargs=* BTags call fzf#vim#buffer_tags(, s:p(0, { "placeholder": "{2}:{3}", "options": ["-d", "\t"] }), 0)', +\'command! -bang -nargs=* BTags call fzf#vim#buffer_tags(, s:p(0, { "placeholder": "{2}:{3}" }), 0)', \'command! -bar -bang Snippets call fzf#vim#snippets(0)', \'command! -bar -bang Commands call fzf#vim#commands(0)', \'command! -bar -bang Marks call fzf#vim#marks(0)',