Reduce the preview of :BCommits to the relevant part, when used with visual selection.
Only show the part of the diff that belongs to the selection.
That makes it very easy to quickly follow the evolution of a code block.
This pre-filtering is critical when working with large tag files.
'readtags' can perform a binary search for the given prefix string
but fzf has to load the entire file into memory just to start searching.
Close#1529Close#1524
Introducing a global configuration variable may seem easier but this
method is more flexible in that it allows you to define multiple
variations of the command without having to repeatedly setting and
unsetting the variable.
function! MyBuffers()
return filter(range(1, bufnr('$')), 'buflisted(v:val) && getbufvar(v:val, "&filetype") != "qf"')
endfunction
command! -bar -bang Buffers call fzf#vim#buffers(MyBuffers(), fzf#vim#with_preview({'placeholder': '{1}'}), <bang>0)
Close#831Close#393
When working in large repositories, 9 characters can be ambiguous.
Bumping it to 40, which is the length of SHA-1. (The algorithm is not
that relevant though. Even when SHA-256 takes over, 40 characters should
still be enough for most repositories.)
- When computing the center line, 'exit' on failure instead of 'return'.
- Open vim in read-only mode to avoid a non-zero exit code if the file is
already opened.
Signed-off-by: Nicolas VINCENT <nico.vince@gmail.com>
* Remove dependency of fzf#vim#helptags on grep.
The grep command was used here only to dump file contents prefixed
with the filename and a colon. Since the function generates a temporary
Perl script anyway, it is simpler to do this directly in the Perl
script. This removes the dependency on grep and makes it easier to get
:Helptags to work on Windows.
A subsequent commit will also move the sorting of the helptags into the
Perl script. I did not do it in this commit, since the OS's "sort"
command can give a different sort order than Perl's sort function,
so I'm not sure what is preferred here.
Note: 'use autodie' is recommended over 'use Fatal' but the autodie
module has only been in Perl core since v5.10.1 (2009-08-22) while
Fatal is in core since 1996. The three-argument open requires v5.6
(2000).
* Remove dependency of fzf#vim#helptags on external sort command.
This moves the sorting of helptags into the generated Perl script and
thereby removes the dependency on an external "sort" command.
Note that Perl's sort function used here may give a different sort
order than the OS's sort command. (It does so for me on Windows but
I actually like Perl's ASCII sort order better, anyway.)
---------
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
The boolean value tells the function if the output of the command
contains column numbers, but we can just see the selected lines if they
contain column numbers.
The argument is now removed from the documentation, and will be silently
ignored for backward compatibility.
Close#1480
* [[B]Commits] Support arguments for git-log
Add support for command arguments that are passed to git-log (e.g.
:Commits -S foo -3).
The place of insertion is relevant. Generally the arguments should come
at the end to overwrite existing flags if necessary, but need to come
before the pathspec (i.e. `fzf#shellescape(current)`) in BCommits.
* [[B]Commits] Make sure all positional arguments are optional
Test cases:
" With default options
%call fzf#vim#commits()
" Full screen
%call fzf#vim#commits(1)
" Not full screen
%call fzf#vim#commits(0)
" With extra fzf options
%call fzf#vim#commits({ 'up': '50%', 'options': '--no-color' })
" With extra fzf options (with preview) and in full screen
%call fzf#vim#commits(fzf#vim#with_preview({ 'options': '--no-color', 'placeholder': '' }), 1)
" With extra git log options
%call fzf#vim#commits('-S foo')
" With extra git log options in full screen
%call fzf#vim#commits('-S foo', 1)
" With extra git log options and fzf options
%call fzf#vim#commits('-S foo', { 'options': '--no-color' })
" In full-screen
%call fzf#vim#commits('-S foo', { 'options': '--no-color' }, 1)
" Command form
Commits
Commits!
Commits -S foo
Commits! -S foo
* [Commits] Enable file completion for arguments
This gets handy when BCommits is too narrow (e.g. multiple files or a
folder is specified).
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>