320 Commits

Author SHA1 Message Date
Junegunn Choi
98dcd77a18 Fix dictionary alignments 2025-06-08 10:51:25 +09:00
Scott Lai
a2ed9fb885 Add :BMarks command (#1593)
And allow passing arguments of :marks to :Marks command. Close #1158.

Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2025-06-08 10:48:17 +09:00
Max Coplan
3ed6ac56d0 feat(preview): teach preview.sh to print directories (#1590) 2025-05-24 19:00:23 +09:00
Mo-tmd
3cb44a8ba5 Add workaround for normal! bug in nvim terminals (#1588)
There's a known issue regarding `normal` usage in neovim. See
https://github.com/neovim/neovim/issues/4895 for more details.

As a temporary workaround, use setpos to set the
bookmark instead.
2025-04-16 07:58:52 +09:00
Junegunn Choi
1fff637559 Use FugitiveWorkTree() to find the git root
Fix #1586
2025-03-21 17:31:10 +09:00
Junegunn Choi
245eaf8e50 Allow specifying command-level fzf options
Close #1583
2025-03-03 19:35:54 +09:00
Simon Désaulniers
f06bd1e69b autoload/fzf: don't user fzf#shellescape in favor of shellescape (#1582)
fzf#shellescape should only be used when building commands that fzf will run.
2025-02-22 10:41:20 +09:00
Junegunn Choi
6cda389bde Update README 2025-02-02 23:27:53 +09:00
Junegunn Choi
b3a49d7993 Apply --scheme=path where appropriate
See https://github.com/junegunn/fzf/pull/4192
2025-01-30 00:26:53 +09:00
Junegunn Choi
80d1cc2e68 Clean up scroll offset expression 2025-01-30 00:19:58 +09:00
Junegunn Choi
556f45e79a Use --gap option for rendering g:fzf_vim.grep_multi_line = 2+
Requires fzf 0.56.0

https://github.com/junegunn/fzf/releases/tag/v0.56.0
2024-10-29 14:09:47 +09:00
Junegunn Choi
ec75ffbfd5 [Ag/Rg] Fix quickfix list when multi-line mode is enabled
Fix #1568
2024-10-01 18:40:44 +09:00
Junegunn Choi
c5ce7908ee Require fzf 0.53.0 or above with --tmux
Close https://github.com/junegunn/fzf/issues/3980
2024-08-28 13:44:08 +09:00
Junegunn Choi
04bfa81157 [Colors] Change color scheme on the fly (experimental) 2024-08-24 16:10:24 +09:00
Junegunn Choi
6f28c8c7bb [Tags] Fix preview on Vim 9.1
Fix #1555
2024-08-01 15:20:41 +09:00
Junegunn Choi
f7c7b44764 Rename issue template file 2024-07-19 21:54:33 +09:00
Junegunn Choi
0337b09394 Update issue template 2024-07-19 21:49:07 +09:00
Junegunn Choi
8f3846f968 Show how to download the latest binary in ISSUE_TEMPLATE.md 2024-07-19 21:42:56 +09:00
zzm
3e2ed513d4 [Jumps] Support preview window (#1553)
Require fzf 0.54.0 or above

Signed-off-by: zeminzhou <zhouzemin@pingcap.cn>
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2024-07-19 21:39:44 +09:00
Junegunn Choi
279e1ec068 [fzf#vim#grep / Ag / Rg / RG] Multi-line display for narrow screens (#1549) 2024-06-07 08:38:27 +09:00
ykhan21
0a80e43f90 Fix environment variable reference (#1546) 2024-05-26 09:21:13 +09:00
Junegunn Choi
47077d0b17 Fix missing quote
Thanks @arekt
2024-05-25 17:02:44 +09:00
ykhan21
42507c3bea Add scoop_git_bash to Windows bash candidates (#1545) 2024-05-25 14:38:13 +09:00
Junegunn Choi
19de6507ff Fix Ag/Rg sink for win32unix (git bash, mintty) 2024-05-23 21:38:15 +09:00
Felix Endres
08dcd814a9 Improve :BCommits Preview (#1525)
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.
2024-05-23 12:56:13 +09:00
Junegunn Choi
71b0e0fb94 [Changes] Fix 'List index out of range: 0' error
Ignore change item that points to a non-existent line
2024-05-17 21:48:08 +09:00
Junegunn Choi
3656cbb9ef [preview.sh] Rename $BATNAME to $BATCAT (#1457) 2024-05-14 17:54:37 +09:00
Junegunn Choi
61edb0ca42 [preview.sh] Use $BATNAME if defined
Close #1457
2024-05-14 17:52:23 +09:00
Junegunn Choi
a50c2640b9 Fix Commands and Windows on Windows
Use tab character with --tabstop=1 instead of non-breaking space

Fix #1542
2024-05-14 17:39:29 +09:00
Junegunn Choi
d91dd754a9 [preview.sh] Fix handling of backslashes in paths on Windows 2024-05-14 09:34:55 +09:00
Junegunn Choi
99093bd103 [RG] Use 'cd .' as the dummy command on Windows 2024-05-08 00:06:01 +09:00
Junegunn Choi
269c08641e [RG] Do not append '|| :' on Windows 2024-04-29 00:09:13 +09:00
Junegunn Choi
503bb6fe9c [Tags] Require readtags from universal-ctags
Close #1540
2024-04-25 20:03:30 +09:00
Junegunn Choi
45d96c9cb1 Do not omit argument to bufnr() for Vim 8 compatibility
bufnr() requires an argument in Vim 8.0

Close #1521
2024-03-22 11:17:34 +09:00
Junegunn Choi
e69f2dcdad [Tags] Add '-' argument to readtags to split options and the search string 2024-03-11 12:08:01 +09:00
Junegunn Choi
0b3e015ad8 [Tags] Use 'readtags' if query string is given
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 #1529
Close #1524
2024-03-11 12:00:49 +09:00
Junegunn Choi
8ea9574b3e Update README: warp.dev 2024-02-15 14:30:15 +09:00
Junegunn Choi
20a1c014b5 Update README: warp.dev 2024-02-13 08:45:27 +09:00
Junegunn Choi
f6cb5b1789 [Helptags] Do not use 'Fatal'
Fix #1506
2024-01-08 16:43:32 +09:00
Junegunn Choi
1e054c1d07 [History] Fix error when there are no entries
Fix #1512
2023-10-27 11:43:42 +09:00
Junegunn Choi
d1016dbd7c [fzf#vim#buffers] Allow users to pass a custom list of buffer numbers
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 #831
Close #393
2023-10-14 23:57:35 +09:00
Ivan Kovnatsky
f3b82091a6 Fix formatting around BLines (#1510)
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2023-10-06 09:11:13 +09:00
Balki
678ee1a549 Replace unicode figure space (U+2007) with regular space (#1507) 2023-09-17 23:52:34 +09:00
Junegunn Choi
fe362d413a Restore the behavior of custom actions on Ag/Rg/Tags/Commits
Fix #1505
2023-09-16 19:36:06 +09:00
Junegunn Choi
937f430ce3 Add :Changes command
Close #1478
Close #1479
2023-09-14 22:45:00 +09:00
jiz4oh
587f55bf50 Use fzf#shellescape instead (#1503) 2023-09-07 11:31:15 +09:00
Junegunn Choi
7ba5be32bc [Buffers] Do not preview '[No Name]' 2023-09-06 18:26:23 +09:00
Junegunn Choi
2c501dc5a2 [Windows] Add preview
Close #1487
2023-09-06 18:26:23 +09:00
Nikita Kouevda
19dec6c038 Use s:conf for preview_bash and files_options (#1502)
Follow-up to 832a090870.
2023-09-06 11:14:08 +09:00
Junegunn Choi
1be10b0e50 Update README 2023-09-06 00:48:04 +09:00
Junegunn Choi
5c218e982d [Lines] Allow multiple selections 2023-09-06 00:46:24 +09:00
Junegunn Choi
832a090870 Add option to use location list instead of quickfix list
Close #432
Close #448
Close #846
Close #1095
Close #1500
2023-09-06 00:46:24 +09:00
Nikita Kouevda
5ab282c2f4 doc: Remove broken link to .vimrc (#1499) 2023-09-03 18:20:37 +09:00
Frederick Zhang
811f34b70b [[B]Commits] Bump Git commit hash length limit to 40 (#1495)
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.)
2023-08-10 20:30:57 +09:00
Nicolas
e0d131d953 tagpreview: open vim in readonly mode, and exit on failure (#1488)
- 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>
2023-07-17 18:57:01 +09:00
Edwin Steiner
1dcdb21db6 [Helptags] Remove dependencies of grep and sort (#1482)
* 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>
2023-06-09 16:46:50 +09:00
Kevin Ushey
5d87ac1fe8 Add :Jumps (#710)
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2023-06-04 16:21:37 +09:00
Junegunn Choi
f5ba993af3 Require the latest fzf
It has a crucial fix for fzf#vim#grep2
2023-06-04 15:50:44 +09:00
Junegunn Choi
fd812b5710 [fzf#vim#grep[2]] Deprecate has_column argument
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
2023-06-04 15:49:16 +09:00
Junegunn Choi
87b60bb133 Add :RG command and fzf#vim#grep2 function 2023-06-04 15:27:45 +09:00
Junegunn Choi
dc71692255 Update documentation and comments 2023-01-27 10:42:13 +09:00
Julian Prein
ca542801a1 [[B]Commits] Support arguments for git-log (#1455)
* [[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>
2023-01-27 10:40:32 +09:00
psyngw
bdf48c282a Fix: Windows preview window logic, including git diff preview (#1452)
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2023-01-16 13:41:07 +09:00
Junegunn Choi
9c37e6801b Update RG example 2023-01-08 17:55:48 +09:00
ksmai
0f03107bc9 fix: GFiles is ignoring args (#1447)
The commit linked below removed `a:args` from the `git ls-files` command, making it
unable to take any options like `--cached`, `--others` and
`--exclude-standard`

531dd67350
2022-12-31 12:41:48 +09:00
Junegunn Choi
fd7fab77b2 [GFiles] Use ls-files --deduplicate only on git 2.31 or above
Close #1446
2022-12-24 10:34:55 +09:00
Nathan Thomas
7434543270 Add support for nushell (#1300)
Nushell doesn't allow programs surrounded in quotes to be executed.
2022-12-22 17:37:50 +09:00
Marc Mezzarobba
531dd67350 Make :GFiles work with "unusual" filenames (#1200)
git ls-files quotes file names containing "unusual" (non-ASCII?)
characters by default, breaking :GFiles

Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2022-12-22 17:31:38 +09:00
JohanChane
9ceac71802 Fix ctags language force for C++ (#1425)
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2022-09-22 17:30:41 +09:00
Junegunn Choi
333635e25e Update g:fzf_preview_window example 2022-09-22 17:30:03 +09:00
Junegunn Choi
ecbf9cd98e Revert "Add Sponsor Labels action"
This reverts commit f64c5b726d.
2022-09-13 09:43:23 +09:00
Junegunn Choi
f64c5b726d Add Sponsor Labels action 2022-09-10 11:27:56 +09:00
Junegunn Choi
c491d702b7 [GFiles] Fix opening files from subdirectory
https://github.com/junegunn/fzf.vim/pull/1290#issuecomment-1208759166
2022-08-09 13:47:50 +09:00
Junegunn Choi
c6b59d8ad7 [GFiles] fzf#vim#gitfiles should respect 'dir'
https://github.com/junegunn/fzf.vim/pull/1290#issuecomment-1207832597
2022-08-08 23:47:20 +09:00
Frederick Zhang
2f3e29fc37 Change git working directory according to the current buffer (#1290)
* Commits
* BCommits
* GFiles
2022-08-03 22:24:13 +09:00
TryWumbo
dff3ad4b62 Update README.md (#1406)
Minor update to first sentence to aid clarity
2022-08-03 14:33:15 +09:00
Junegunn Choi
a4617a7291 Use ASCII non-breaking space 2022-08-02 13:56:15 +09:00
Junegunn Choi
6a34c9060a Create FUNDING.yml 2022-07-30 19:54:16 +09:00
Emilv2
c311c0a95f [[B]Commits] Show current file first in preview (#1402)
Close #802
2022-06-28 14:33:15 +09:00
Junegunn Choi
d5f1f8641b Update .github/ISSUE_TEMPLATE.md 2022-04-07 17:47:54 +09:00
jiz4oh
b23e4bb8f8 [fzf#vim#complete#word] Respect &dictionary option (#1373) 2022-03-07 17:35:08 +09:00
Tomáš Janoušek
1f7bfa4007 [[B]Commits] Use --color=always with delta as well (#1362)
With some delta configurations (e.g. color-only = true, diff-highlight =
true), delta doesn't add its own coloring and keeps that from git diff,
and thus we need to turn that on.

Additionally, delta doesn't do its own detection of moved lines and
relies on git diff's colorMoved, which also needs enabling of colors.
2022-02-01 15:34:48 +09:00
Tomáš Janoušek
70541d2ee0 [Commands] Fix hit-enter/more-prompt with terminal buffer fzf (#1363)
Since 85ae745910,
fzf opens in a terminal buffer (in my setup) and that breaks commands
that end up showing the hit-enter or more prompt, such as :scriptnames
or :ALEInfo. No idea why those commands break (I tried to diagnose this
but gave up unfortunately), but executing them using feedkeys fixes
this.
2022-01-30 13:28:24 +09:00
Melandel
91332acb1c [GFiles?] Fix preview on windows (wsl bash + git_install_folder/usr/bash) (#1360)
* Fix preview on GFiles? on Windows+WSL
* Fix preview on GFiles? on Windows using gitInstallFolder\usr/bin\bash.exe

Co-authored-by: Minh-Tam TRAN <c_mtran@capsuletech.com>
Co-authored-by: Minh-Tam TRAN <minh-tam.tran@younited-credit.fr>
2022-01-24 18:02:50 +09:00
Philip Kannegaard Hayes
66cb8b8264 [Helptags] add preview window to :Helptags command (#1357)
+ In `fzf#vim#helptags`, we now also parse out the ex-command in the
  perl script so it's available for the preview (this is just an
  extra `\t(.*)` appended to the original regex).

+ Add the `--tag` placeholder to `:Helptags` with corresponding
  arguments.
2022-01-16 21:33:29 +09:00
Ben Denhartog
d6aa21476b Add LICENSE file (#1342) 2021-11-02 09:05:22 +09:00
peelz
0452b71830 Fix preview failing on files with special characters (#1337) 2021-10-10 21:55:15 +09:00
magras
a4ce66d725 Set jump if the target is in the current file (#1195)
Adding a record to the jump list allows to go back to the cursor
position before jump with CTRL-O.

Fix #595
2021-10-08 17:26:38 +09:00
Junegunn Choi
e393108bfa Simplify version checking
Fix #1329
2021-09-29 20:22:47 +09:00
Walter Wang
bd703a7a7d Force LF on Windows (#1326)
Fix #1270
2021-09-16 11:43:27 +09:00
Kevin Lin
980cd07439 [fzf#vim#with_preview] Set --no-unicode if ambiwidth is 'double' (#1322)
Fix #1320

Append fzf argument `--no-unicode` when ambiwidth is `double` to keep the
preview window rendering correctly.
2021-09-03 06:46:54 +09:00
Junegunn Choi
a552e44810 [preview] Let bat decide if the file is a binary
Fix #1264
2021-08-31 14:16:07 +09:00
Ben
b1afeca8cc Unfold jumped line in grep sink (#1277) 2021-08-17 16:17:51 +09:00
Frederick Zhang
e34f6c129d [[B]Commits] Preserve window view (#1289)
In 161da95, [B]Commits were changed to range commands with -range=%, now
Vim jumps to the first line when these two commands are called directly
without specifying range.

This fixes it by saving window view in a temporary variable and
restoring it later. Reference: [1].

[1] https://vi.stackexchange.com/a/6037/33583
2021-05-25 13:30:41 +09:00
Junegunn Choi
161da95640 [[B]Commits] Allow tracking changes in the line range
Thanks to @anhpt379

Close #898
Close #1288
2021-05-24 19:38:51 +09:00
Junegunn Choi
d7211d0f61 Set delta width
Fix #1219
2021-05-24 16:29:31 +09:00
Stefan Kanev
a88311b222 Don't mutate args to fzf#vim#files() (#1282)
As the code was written before, if we do this:

   let s:opts = {
   \ 'window': {'width': 0.6, 'height': 0.6, 'relative': v:false},
   \ 'options': ['--layout=reverse', '--info=inline'],
   \}

   call fzf#vim#files('', s:opts, 0)

...then s:opts will get mutated by the call to fzf#vim#files, cloberring
any persistent configuration established this way.

Making a defensive copy solves the problem.
2021-05-09 13:45:33 +09:00
Junegunn Choi
75c7e87de1 [Tags] Handle \t characters in EXCMD
Fix #1278
2021-05-01 09:55:40 +09:00
Eddie
ee91c93d4c [Snippets] Do not limit search scope (#1217) 2021-04-15 05:38:19 +09:00
Junegunn Choi
caf7754b26 [Buffers] Increase tabstop according to the string length of bufno
e.g. vim {1..1000} +'silent 1bd'

Fix #1237
2021-03-25 01:16:02 +09:00
Greg Fisher
1ef72b14cc Use nvim if vim not installed (#1262)
The `tagpreview.sh` script is hardcoded to the `vim` binary. For users that only
have  Neovim installed an error is displayed and no preview is rendered.

This change addresses this by falling back to the `nvim` binary if the `vim`
binary isn't present.
2021-03-14 12:08:29 +09:00
Junegunn Choi
711fb41e39 Respect preview-window value in FZF_DEFAULT_OPTS
when g:fzf_preview_window is not set, instead of overriding it with `right`.

Close #2378
2021-03-06 16:34:25 +09:00
Junegunn Choi
02a192ea0b [Buffers] Increase tabstop if the number of buffers >= 1000
Fix #1237
2021-02-02 11:11:20 +09:00
Grueslayer
68ab645574 Fix preview support for MS Windows (WSL and Git bash) (#1215)
* Fixes #1212

* Path translation only when containing backslash.

- lower letters also allowed for drive

Co-authored-by: Jan Stocker <Jan.Stocker@cosmoconsult.com>
2021-02-01 19:48:25 +09:00
Junegunn Choi
707f5b6269 Make fzf#vim#preview process g:fzf_preview_window
Related #1023
Related #1225
2021-01-27 10:53:14 +09:00
Ingo Meyer
36de5db9f0 [Tagpreview] Handle absolute file paths correctly (#1229)
Fix #1228
2021-01-20 20:34:56 +09:00
Ingo Meyer
1fcdee55cc [Tags] Add a tag preview with a custom tagpreview.sh script (#1223)
* Add a tag preview with a custom `tagpreview.sh` script

* [Tags] Respect g:fzf_preview_window

Co-authored-by: Ingo Meyer <IJ_M@gmx.de>
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2021-01-17 22:36:02 +09:00
Junegunn Choi
d43df0ea2f [fzf#vim#complete] Keep insert mode after completion
https://github.com/junegunn/fzf.vim/issues/303#issuecomment-755965141

Fix a bug where completion ends in normal mode instead of in insert mode
when a terminal buffer is used to render fzf in regular Vim (layout != down).
2021-01-07 18:12:10 +09:00
Junegunn Choi
811b8607c6 [Buffers] Do not apply --header-lines when the current buffer is unlisted
Fix #1211
2020-12-30 23:43:54 +09:00
Junegunn Choi
e9d62b4c87 delta: Remove invalid flag 2020-12-14 14:20:58 +09:00
Junegunn Choi
dfc318b2be delta: Only disable --side-by-side (#1205) 2020-12-14 14:09:09 +09:00
Junegunn Choi
a1f33472f9 delta --no-gitconfig
Close #1205
2020-12-14 10:33:18 +09:00
Junegunn Choi
708c26aceb Update README 2020-12-14 00:18:01 +09:00
Junegunn Choi
4c9af003e6 Fix typo 2020-12-14 00:14:45 +09:00
Junegunn Choi
54b3817db2 [[B]Commits] Use delta if available 2020-12-14 00:12:22 +09:00
Junegunn Choi
65b6cdb0f2 [GF?] Use bash instead of sh
[[ may not be available on sh
2020-12-12 10:28:26 +09:00
Junegunn Choi
97ec188e07 [GF?] Use delta to format git diff if available
Close #1202
2020-12-12 02:22:21 +09:00
Junegunn Choi
636a62f140 Add g:loaded_fzf_vim
Close #1201
2020-12-11 10:08:30 +09:00
Junegunn Choi
8fa9cf0524 [fzf#vim#grep] Remove color overrides
Related: https://github.com/junegunn/fzf.vim/issues/1197#issuecomment-739804363
2020-12-07 18:50:21 +09:00
infokiller
cabfd44a8b [Commands] Add command to history when directly executed (#910) 2020-11-29 20:46:59 +09:00
Junegunn Choi
cc13a4b728 Use system() instead of systemlist() for older versions of Vim
Fix #1184
2020-11-25 13:51:11 +09:00
Junegunn Choi
53b3aea0da [fzf#vim#grep] Go to the correct column by using cursor function instead of |
Ceci n'est pas une pipe.

Fix #1173
Fix #1174
2020-11-11 16:56:18 +09:00
DZ84
61c4b6d1ed [fzf#vim#with_preview] Incorporate batcat name (#1159)
* Added detection/selection of two bat install scenarios.
2020-11-04 01:59:18 +09:00
Junegunn Choi
bd3a021ec1 See the last line of "fzf --version" output
The output may contain some warning messages from the shell. While such
extra messages should be properly fixed by the user, we can ignore them
by checking the last line of the output.

Related: https://github.com/junegunn/fzf.vim/issues/1145#issuecomment-719465248
2020-10-30 19:34:04 +09:00
Junegunn Choi
7d45724fdd [[B]Commits] Apply g:fzf_preview_window
Related: #1149
2020-10-27 16:35:06 +09:00
Junegunn Choi
fcb1e6ebec Optimize History: and History/
@kevinhwang91 profiled the code and found a low hanging fruit for making
the commands faster
2020-10-23 22:35:40 +09:00
Junegunn Choi
ddc377c0d3 Update doc: 0.23.0 or above required 2020-10-22 17:11:09 +09:00
Junegunn Choi
8b3ab784ed Print error message when fzf --version failed
Fix #1145
2020-10-22 17:06:48 +09:00
Junegunn Choi
44057cce0e Update g:fzf_preview_window to be a list with optional toggle keys
- The default preview window option will be ['right', 'ctrl-/']
  regardless of screen width or <bang>
- This will also fix #1010
2020-10-22 17:02:48 +09:00
sicher
0eb385065b Concat string with "." (#1142)
expr-.. is not available on older versions of Vim
2020-10-21 13:36:37 +09:00
Junegunn Choi
01f7146cf6 Put focused line in the middle of the preview window
Fix #1092
Requires fzf 0.23.0 or above
2020-10-18 13:37:41 +09:00
Denis Cornehl
0fe8e198a3 [Tags] Unfold after Tags/BTags (#1133) 2020-10-04 19:42:58 +09:00
Jan Edmund Lazo
3348aef05d [fzf#vim#with_preview] Detect WSL bash on Windows only
Close https://github.com/junegunn/fzf.vim/issues/1052
2020-09-12 01:06:17 +09:00
Junegunn Choi
18205e071d Version requirement 2020-09-04 21:48:15 +09:00
Junegunn Choi
4145f53f3d Use native preview scroll of fzf 0.22.0
This allows you to scroll upwards

Fix #1053
Fix #751
Fix #749
2020-08-13 00:14:41 +09:00
Junegunn Choi
23dda8602f Fix code comments: options -> spec 2020-08-13 00:14:41 +09:00
Junegunn Choi
9cc54fb3d3 [fzf#vim#grep] Ignore whitespaces around :
Fix #1071
2020-08-12 21:51:26 +09:00
Antoine
2115caeba1 Fix :Maps when :verbose map does not have a 2nd line with comments (#1067) 2020-07-30 12:50:19 +09:00
Junegunn Choi
7bc8eccf57 Dependencies 2020-07-27 20:47:38 +09:00
RichardNee
2bf85d25e2 Fix preview.sh not running when the file path contains "binary" (#1055) 2020-06-21 17:54:35 +09:00
Doron Behar
8f1e73b598 Expose some buffer related functions (#1044) 2020-06-07 10:16:16 +09:00
Junegunn Choi
16e3efbcb1 Disable preview window if bash is not found
Fix #1039
2020-06-07 10:13:35 +09:00
Maxim Kim
5aa5977d74 Handle absolute windows paths in Grep/Ag/Ripgrep sink process (#1038)
Fix #1037

Function `ag_to_qf` is used to parse line produced by Grep, Ag or
Ripgrep. Implementation in quesition split it using regexp that doesn't
work for windows absolut paths.

A better approach is to use `matchlist` function.
2020-06-01 12:16:18 +09:00
Jan Edmund Lazo
7a655179a4 [fzf#vim#with_preview] Support WSL bash (#1026)
* [fzf#vim#with_preview] support wsl bash

Close https://github.com/junegunn/fzf.vim/issues/988
Close https://github.com/junegunn/fzf.vim/pull/1009

* [fzf#vim#with_preview] use abs path for bin/

WSL has issues with relative filepaths.
2020-05-23 21:23:26 +09:00
Maxim Kim
996ec3b4b0 [Helptags] Fix perl script for Windows (#1036)
Temporary perl script that parses output of help grep doesn't take into
account backward slash as windows path separator.

Fixes #987
2020-05-23 20:33:04 +09:00
Jesse Leite
a74605b81d Add undocumented fzf#vim#_recent_files function (#1024)
* Rename and make `s:all_files` public for user fzf extension
2020-05-13 00:33:34 +09:00
Junegunn Choi
3925db8307 Update vim help file 2020-05-06 00:54:32 +09:00
Alexandre Perrin
25bed070d8 Use -- before the search pattern for Ag, Rg, etc. (#1012)
Before this patch, a search pattern starting with a dash like
`:Rg -bang` would fail (or exhibit the wrong behaviour) because it would
be treated as a option. However, this case is very common when searching
for ->member in a project in C, C++, PHP, etc.

Co-authored-by: Alexandre Perrin <alex@atipik.ch>
2020-05-06 00:53:11 +09:00
Junegunn Choi
2c07630341 Better completion example 2020-05-03 17:36:28 +09:00
Junegunn Choi
5b6f282d97 Update documentation: fuzzy completion functions 2020-05-03 17:24:11 +09:00
Ian Homer
4cf475b753 [Maps] Display filename and line number (#998)
Fix #997

Co-authored-by: Ian Homer <ihomer@worth.systems>
2020-05-01 11:28:03 +09:00
Junegunn Choi
f86ef1bce6 [Buffers] getbufinfo() may not be available 2020-04-09 10:30:11 +09:00
Junegunn Choi
f90b3197ad [fzf#vim#with_preview] Do not override --preview-window with the default value
Fix #975
2020-04-05 17:35:54 +09:00
Junegunn Choi
d4d36b412b Update installation instruction 2020-03-17 14:29:57 +09:00
Junegunn Choi
7ccecee77d Clarification: Files command runs $FZF_DEFAULT_COMMAND
Files is equivalent to running fzf without input pipe; fzf reads the
output of $FZF_DEFAULT_COMMAND

Related: #966
2020-03-17 12:07:37 +09:00
Junegunn Choi
d16ddcf58d [History] Fix #964 2020-03-16 00:37:35 +09:00
Junegunn Choi
ef24327796 Enable preview window for BTags
Close #195
Close #799

Close #724
Close #955
2020-03-15 16:46:56 +09:00
Junegunn Choi
15ed47f561 Add option to globally enable or disable preview window 2020-03-15 16:16:04 +09:00
Kohei Murakami
ed9d66c2a6 Remove unnecessary escaping in tilde expansion (#962) 2020-03-11 23:22:06 +09:00
Junegunn Choi
e32a9c3767 Do not put --layout=reverse-list if FZF_DEFAULT_OPTS sets reverse layout
Close #916
2020-03-05 21:15:38 +09:00
uzxmx
48a2d80a24 [fzf#vim#preview] Respect $BAT_STYLE (#953) 2020-02-19 12:16:32 +09:00
Junegunn Choi
467c327788 Recommend running ./install --bin on update 2020-02-05 10:37:52 +09:00
Junegunn Choi
ee08c8f949 Clarification on 'do' option of Plug statement 2020-02-04 18:28:55 +09:00
Junegunn Choi
dc7796a6e2 Simplify the installation instruction 2020-02-04 18:23:53 +09:00
Phong
dc4c4c2271 Use FZF_PREVIEW_LINES instead of LINES (#931)
Since fzf v0.18.0 FZF_PREVIEW_LINES is preferred over LINES
2020-01-14 14:07:14 +09:00
Junegunn Choi
6eeeab64a8 Revert "[[B]Commits] Add support for files in submodules (#919)"
This reverts commit 360f7f36da.
2020-01-14 10:37:57 +09:00
matawed
360f7f36da [[B]Commits] Add support for files in submodules (#919) 2020-01-14 10:36:05 +09:00
tockn
8a6894d6a5 Fix typo (#914) 2020-01-10 11:51:02 +09:00
Nils ANDRÉ-CHANG
8b778dc642 Remove useless line in autocmd (#924) 2020-01-10 11:48:06 +09:00
atarax
fab0597a50 [fzf#vim#grep] Properly handle filenames with double-colons (#928) 2020-01-10 11:45:08 +09:00
Junegunn Choi
76669c3c1d Deprecate preview.rb 2019-12-22 18:11:18 +09:00
Junegunn Choi
f71f4808d9 Update examples 2019-12-18 10:08:03 +09:00
Junegunn Choi
206ec5efe9 Use --line-range and --highlight-line options of bat 2019-12-17 14:19:59 +09:00
Junegunn Choi
65edb6ad99 Update ISSUE_TEMPLATE 2019-11-24 22:44:30 +09:00
Junegunn Choi
6eda9fd38a Revamp README 2019-11-24 19:33:58 +09:00
David Bengoa
fcdb7a0096 Fix broken anchor in link (#908) 2019-11-24 18:25:28 +09:00
Junegunn Choi
98cf39949b Change fzf#vim#grep to rely on temporary FZF_DEFAULT_COMMAND
Related #907
Also https://github.com/junegunn/fzf/issues/1750

function! RipgrepFzf(query, fullscreen)
  let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
  let initial_command = printf(command_fmt, shellescape(a:query))
  let reload_command = printf(command_fmt, '{q}')
  let options = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
  call fzf#vim#grep(initial_command, 1, options, a:fullscreen)
endfunction

command! -nargs=* -bang RF call RipgrepFzf(<q-args>, <bang>0)
2019-11-17 12:22:10 +09:00
ptzz
bce6588d24 Fix preview of paths starting with ~/ (#892) 2019-11-01 10:31:41 +09:00
Viacheslav Lotsmanov
359a80e3a3 [History] Fix feedkeys to ignore command-line mappings (#836) 2019-07-04 15:53:22 +02:00
Junegunn Choi
91ed5f4b39 Fix invalid layout example 2019-06-08 23:29:43 +09:00
Tomáš Janoušek
5c87ab86c0 [Tags] Workaround for last-position-jump (#810)
If there's an autocmd for BufReadPost that jumps to the last position,
searching for the tag location sometimes results in vim printing the
wrapscan warning and then requires hit-enter. Execute the search
silently to suppress the warning (errors are still visible!).
2019-05-14 18:46:01 +09:00
Michael Gaffney
ac4e7bfb36 Allow 'fzf-vim.txt' to be listed in the LOCAL ADDITIONS section of help.txt (#805)
The first field on the first line of a help file should be a link to the
help file name. (See :h help-writing)
2019-04-29 13:33:16 +09:00
Junegunn Choi
b31512e2a2 Fix incorrect fzf_layout example (#769) 2019-02-22 10:54:51 +09:00
Miguel Madrid Mencía
9b50e2fd5f Fix preview of symbolic links (#739) 2019-02-21 10:42:10 +09:00
Greg Anders
7bf940d261 Do not remap keys when using feedkeys (#768) 2019-02-21 10:40:13 +09:00
Mars Peng
f0acabf7e8 [Windows] Use {count}tabnext instead of normal {count}gt (#745)
To workaround https://github.com/neovim/neovim/issues/4895
2018-12-11 10:50:14 +09:00
Junegunn Choi
95f025ef2d [doc] fzf#vim#with_preview does not require any argument 2018-11-27 23:05:43 +09:00
Elisha Hastings
ad1833ecbc [preview] Use env to get bash (#737)
This wasn't working on NixOS due to bash not being under `/bin`. Using `env` should make it compatible with more setups.
2018-11-14 22:19:17 +09:00
Junegunn Choi
741d7caabf [preview] Fix fzf#vim#with_preview on Windows
Close #734
2018-11-11 12:00:56 +09:00
Junegunn Choi
0dbcfb28c4 [preview] Clean up preview scripts
- Use preview.sh instead of preview.rb by default
- Try bat syntax highlighter with the highest priority
- Remove "-v" option as the latest version of fzf sets up $LINES
- Allow users to customize the preview command via $FZF_PREVIEW_COMMAND
  - *EXPERIMENTAL / EVOLVING / UNDOCUMENTED*
  - Should be a command template with {} placeholder expression
    - e.g. "nl {}"
2018-11-09 16:11:31 +09:00
Jongwook Choi
b73d141b74 [preview] Support bat for syntax highlighting in preview.rb
One can still take advantage of `bat` as a syntax highlighter,
when ruby is available but other ruby-based highlighter packages
are not installed.
2018-11-09 16:11:31 +09:00
Jongwook Choi
974d366b33 [preview] Use bat for syntax highlighting if available
In the preview.sh script (used when ruby is not installed),
`bat` (a clone of `cat` with syntax highlighting, etc.) can be
used for the sake of syntax highlighting. If bat is not available,
just fallback to the plain cat as before.

[bat]: https://github.com/sharkdp/bat
2018-11-09 16:11:31 +09:00
Junegunn Choi
50707b089b [Commits] FugitiveGenerate -> FugitiveFind
https://github.com/junegunn/fzf.vim/issues/674#issuecomment-431714761
2018-10-22 16:10:28 +09:00
Peter Shih
c6275ee108 [BLines] Fix error on line with tab, fix #699 (#708) 2018-10-01 17:08:25 +09:00
Daniel Schaffrath
c3954d294a [Lines] Unfold after Lines/BLines (#693) 2018-09-12 12:06:51 +09:00
Junegunn Choi
8fa84e0fdf [BLines] Fix incorrect line numbers when run with query (#694) 2018-09-08 02:39:46 +09:00
mg979
aedd47be21 [BLines] Allow multi selection for building quickfix list 2018-09-07 16:37:36 +09:00
Filip Szymański
8224416813 [Filetypes] Remove duplicate file types (#688) 2018-09-02 18:21:20 +09:00
Junegunn Choi
a3459df758 Add Rg for ripgrep 2018-08-31 17:27:35 +09:00
Junegunn Choi
2eb1bccea9 [Lines] Fix formatting error 2018-08-30 13:33:22 +09:00
Junegunn Choi
f52fcd3d6c [Marks] Use foreground color for "Number" highlight group (#581) 2018-08-29 17:54:33 +09:00
Junegunn Choi
e042ec03a2 [Ag] Use base blue colors
Close #454
2018-08-29 17:53:58 +09:00
Junegunn Choi
633c980c05 Fix base ANSI colors (#581) 2018-08-29 17:53:20 +09:00
Junegunn Choi
bd80d334be Fix background color of Lines/BLines
Close #555
2018-08-29 11:09:22 +09:00
Junegunn Choi
f39c92b7ce Use --layout=reverse-list when appropriate (fzf 0.17.4 required) 2018-07-29 01:08:44 +09:00
Junegunn Choi
2a58380051 Update README: external terminal emulator no longer required in GVim 2018-07-29 01:05:00 +09:00
Junegunn Choi
6ce58caad3 [Commits] Use FugitiveGenerate to get proper commit URL
Close #674
2018-07-22 17:08:27 +09:00
Junegunn Choi
8d56bdd6ad Remove duplicate example 2018-07-11 13:28:41 +09:00
Junegunn Choi
1d9e7d2a90 Add global line completion example to README
Close #622
2018-07-11 13:27:50 +09:00
Junegunn Choi
033033daa3 [Buffers] Avoid cleaning up g:fzf#vim#buffers when the plugin is reloaded
Close #643
2018-06-22 12:30:31 +09:00
Junegunn Choi
1b01a5069b [History] Append command to command history
Close #661
Fix #549
2018-06-22 12:13:32 +09:00
Junegunn Choi
6aa1db67a5 [History] Fix #549 - Avoid : or / map 2018-06-22 12:06:33 +09:00
Dylan Chong
34881b707b Update Rg example to use smart-case option (#658) 2018-06-20 18:20:24 +09:00
Ala Ibrahim
ce82e10630 [Buffers] Clean up buffer names (#637)
Issue: While following paths in a file, it might end up in paths like
`a/b/../c/d.ext` or `a/b/./c.ext`, which would be cleaner if displayed
like `a/c/d.ext` and `a/b/c.ext`.

Solution: Expand fullpath to resolve directories before collapsing it to
home directory/relative path.
2018-05-28 16:03:33 +09:00
Håken Lid
88595ebbaa [History] Use fnamemodify instead of expand (#626)
Close #573
2018-04-28 11:05:42 +09:00
Junegunn Choi
dc5f9437fc [BTags] Use sort executable only on Unix (excluding Cygwin) (#620) 2018-04-19 17:55:22 +09:00
Junegunn Choi
3661409e95 [BTags] Group tags by scope
Related #620
2018-04-18 14:09:54 +09:00
Justin M. Keyes
bbda33b402 buffer_tags: sort tags
This is nice for (ab)using :BTags to "browse" functions in a source
file.
2018-04-17 18:26:09 +09:00
Jan Edmund Lazo
dcf49751e9 [BTags][Buffers] use list type for options 2018-04-11 10:11:06 +09:00
Jan Edmund Lazo
9f0bae1248 [Lines][BLines][Tags] use list form for options 2018-04-11 10:11:06 +09:00
Shea Parkes
a362bc58f1 Update GGrep example to work at project level. (#590) 2018-03-09 11:48:46 +09:00
Pascal Lalancette
17d24ae31d [Helptags] Ignore wildignore setting (#567)
If `tags` is set in the `wildignore` option, `:Helptags` command would
always return an empty list.
2018-01-21 19:52:23 +09:00
Junegunn Choi
c0a5fee707 Clarify that "fzf.vim" depends on "fzf" 2018-01-09 01:36:51 +09:00
Junegunn Choi
2686522b2e Remove deprecated function 2018-01-09 01:18:37 +09:00
Jan Edmund Lazo
7e92b73d03 [fzf#vim#with_preview] workaround system() newline (#557)
system() adds an extra newline which breaks the DOS shortname hack
for Neovim on Windows.
Suppress echo so the DOS shortname is the 1st line of the output

Related: https://github.com/neovim/neovim/issues/7788
2018-01-02 18:28:17 +09:00
Junegunn Choi
3d33d4cd66 [fzf#vim#with_preview] Remove unnecessary -v flag 2018-01-02 18:25:30 +09:00
Jan Edmund Lazo
9036680e74 [fzf#vim#with_preview] Escape preview script path (#558)
Close: https://github.com/junegunn/fzf.vim/issues/554
2018-01-02 18:21:14 +09:00
Jan Edmund Lazo
02654656af [Tags] run perl for s:bin.tags (#559) 2018-01-02 18:14:48 +09:00
Junegunn Choi
009c58b481 Use $LINES instead of $FZF_PREVIEW_HEIGHT
Since 0.17.3, fzf exports $LINES and $COLUMNS to preview process.
FZF_PREVIEW_HEIGHT will be deprecated.
2017-12-09 23:22:24 +09:00
Junegunn Choi
11b7fb91e1 Decorate Vim 8 statusline
We used to decorate statusline only on Neovim, but we can do the same
for Vim 8.
2017-12-06 12:32:08 +09:00
Junegunn Choi
76926aa247 [Tags] Ignore optional semicolon after excmd in tag
Close #531
2017-12-03 05:28:58 +09:00
Niraj Thapaliya
d0042b9dee [[B]Commit] Fix preview command for fish shell (#518)
* Fish shell doesn't like <<<

Echo to pipe instead

* Only return the first match

Useful if the commit message has a project tracker id that looks
similar to a git commit hash
2017-11-24 13:18:55 +09:00
Junegunn Choi
45d39f5711 [[B]Commits] Do not enable preview on narrow screen
Only enable --preview if &columns > 120.

Caveat: When fzf starts in a terminal buffer, &columns does not
represent the width of the window.

Related: #461
2017-11-24 01:13:17 +09:00
Junegunn Choi
6902f6bc1c [[B]Commits] CTRL-Y to yank commit hashes to register
Close #516
2017-11-24 01:07:14 +09:00
Jan Edmund Lazo
ad113a64fc [Tags] Use fnameescape to escape command line arguments (#512)
Port of 7727ad43af

Related: #504
2017-11-21 00:19:13 +09:00
Junegunn Choi
ba7a22888b Update instruction to hide statusline of terminal buffer 2017-11-19 12:14:40 +09:00
Junegunn Choi
be8aa32b1e Add instruction to hide statusline of terminal buffer
https://github.com/junegunn/fzf/issues/1143
2017-11-19 12:12:22 +09:00
Junegunn Choi
18df14c2f6 Revert "[GitFiles] Support files with special characters (#500)" (#509)
This reverts commit 004af25150.
2017-11-16 19:30:14 +09:00
Michael Budde
004af25150 [GitFiles] Support files with special characters (#500)
By default git will quote filenames that contain special characters.
From the git help on the `core.quotepath` config:

> The commands that output paths (e.g. `ls-files`, `diff`), when not given
> the `-z` option, will quote "unusual" characters in the pathname by
> enclosing the pathname in a double-quote pair and with backslashes the
> same way strings in C source code are quoted. If this variable is set
> to false, the bytes higher than 0x80 are not quoted but output as
> verbatim. Note that double quote, backslash and control characters are
> always quoted without `-z` regardless of the setting of this variable.

This quoting behaviour means that GitFiles cannot be used to open files
that contain any special characters. Fix this by using the `-z` option
to `ls-files` together with the `--read0` option on fzf.
2017-11-16 15:11:27 +09:00
Josh Pencheon
4b9e2a03fe [GFiles] Avoid duplicate entries (#473)
It is presumed that duplicates in `git ls-files` are contiguous.
2017-11-14 12:54:07 +09:00
Michael Kaiser
5c6cee878a [fzf#vim#colors] Pick up colorschemes from opt packages (#489) 2017-11-02 21:35:48 +09:00
Josh Pencheon
f31a2925fe [BCommits] Remove --graph option (#474) 2017-10-25 18:57:27 +09:00
Jan Edmund Lazo
b51382fe9e [fzf#vim#preview] Use ruby in Windows if available (#471)
Close #459
2017-10-22 22:50:12 +09:00
Junegunn Choi
fbfbd04870 Clean up README 2017-10-21 09:27:18 +09:00
Junegunn Choi
852b38db2a Update installation instruction 2017-10-21 09:25:24 +09:00
Junegunn Choi
6ac8d1f742 Update vimdoc and remove duplicate tags
Close #467
2017-10-17 02:21:57 +09:00
Junegunn Choi
121bd70fcf [[B]Commits] Enable preview window by default
Close #461
2017-10-08 03:45:31 +09:00
Junegunn Choi
b24038960e Fix incorrect --query option in completion
s:complete_trigger should prepend the default options instead of
appending them. The bug was introduced in 25ea637.

/tmp/foo<ctrl-x><ctrl-f> should give fzf prompt "/tmp/" and default
query "foo". But it used to give "/tmp//tmp/foo".
2017-09-26 15:20:27 +09:00
Junegunn Choi
36f6e6b5b0 Fix s:wrap for Vim 7.4
Close #446
2017-09-14 19:13:11 +09:00
Jan Edmund Lazo
2fd046fa76 [Files] Port junegunn/fzf/pull/1043 (#442) 2017-09-07 11:03:56 +09:00
Junegunn Choi
e7928d154a [Files] Do not set up lengthy prompt on narrow screen 2017-09-05 18:50:18 +09:00
Jan Edmund Lazo
df79877245 [fzf#vim#preview] works with Windows default command (#441) 2017-09-04 22:50:37 +09:00
Junegunn Choi
0b0d9f0912 [Ag] Print error message when ag is not found on $PATH
Close #440
2017-09-01 11:10:42 +09:00
Junegunn Choi
39f0c2d0a4 Merge pull request #436 from janlazo/Windows_complete
[fzf#vim#complete#path] works in Windows
2017-08-28 22:38:41 +09:00
Jan Edmund Lazo
34ceec14d2 [fzf#vim#complete] append --no-expect to options
Reference: https://github.com/junegunn/fzf.vim/pull/436#discussion_r135379047
2017-08-27 08:50:35 -04:00
Jan Edmund Lazo
b73cec55f0 [fzf#vim#complete#path] works in Windows 2017-08-27 08:50:35 -04:00
Jan Edmund Lazo
25ea6371b2 [s:complete_trigger] use list type for options 2017-08-27 08:50:35 -04:00
Junegunn Choi
4e603e4fab [Commits] Fix formatting of commit log 2017-08-27 05:10:51 +09:00
Junegunn Choi
13b27c45c8 Merge pull request #429 from janlazo/Windows_Ag
[Ag, fzf#vim#grep] works in Windows
2017-08-25 22:57:55 +09:00
Junegunn Choi
e246016844 [History] Remove duplicates and print list in MRU order
Close #434
2017-08-24 02:58:27 +09:00
Jan Edmund Lazo
a4d4986d18 Make 8.3 filename via cmd.exe for Neovim 2017-08-22 06:02:30 -04:00
Jan Edmund Lazo
b0baf7593d [Commits,BCommits] Windows support (#430)
Works only in s:execute of fzf's Vim plugin.
s:execute_term corrupts the output of fzf#shellescape.
2017-08-22 02:13:06 +09:00
Jan Edmund Lazo
dda682ad69 Revert "Run preview script in batchfile for Windows"
The reverted commit is broken.
Keep it simple by sticking with the fnamemodify hack.
Hope that Neovim supports 8.3 filenames
2017-08-20 22:55:47 -04:00
Jan Edmund Lazo
71cc4c5037 Run preview script in batchfile for Windows
Bypasses the following issues in Windows:
1. Neovim does not support 8.3 filenames
   ie. fnamemodify(path, ':8')
2. fzf binary cannot parse output of fzf#shellescape
   It assumes that preview command is run in sh, not cmd.exe
2017-08-20 22:42:45 -04:00
Jan Edmund Lazo
057853a248 [s:fzf] join the option list for preview script check 2017-08-20 21:42:09 -04:00
Jan Edmund Lazo
3334d62749 [fzf#vim#with_preview] works with Ag in Windows
- disabled on Files because the preview scripts cannot resolve the network drive
- use 8.3 filepath for s:bin.preview to bypass escape issues in fzf binary
2017-08-20 21:21:32 -04:00
Jan Edmund Lazo
469ac6bfce [Ag] works in Windows
[fzf#vim#grep] use list type for options
2017-08-20 17:35:28 -04:00
Jan Edmund Lazo
fa91d53f5c [Tags] Support Windows-style absolute filepaths (#428) 2017-08-20 23:14:31 +09:00
Jan Edmund Lazo
1e40de4f2d [Tags, BTags] Windows support (#427) 2017-08-20 22:11:42 +09:00
Jan Edmund Lazo
61bcdb146f [s:q] Use fzf#shellescape for Windows (#425)
Fixes Lines, BLines, Buffers on Windows
2017-08-20 16:59:09 +09:00
Jan Edmund Lazo
d62ec0b113 [GFiles?] Windows suppport: use list type for options (#424)
Requires msysgit or cygwin in Windows
2017-08-20 16:55:15 +09:00
Jan Edmund Lazo
914355df94 [Helptags] Windows support (#423) 2017-08-20 12:26:07 +09:00
Jack O'Connor
7e868c49ac Exclude the current file from History (#422)
Close #367
2017-08-18 02:14:43 +09:00
Jan Edmund Lazo
43a570d6e6 [Files] runs in Windows (#418)
* [Files] runs in Windows

* Use fzf#shellescape() and copy() in s:merge_opts()

* [fzf#vim#preview] uses list type for options

- fixed s:merge_opts for extending the option list

* [fzf#vim#with_preview] no-op in Windows

Reference: https://github.com/junegunn/fzf.vim/pull/418#issuecomment-322645632

* [fzf#vim#with_preview] return passed dict in Windows
2017-08-17 13:12:10 +09:00
Junegunn Choi
b9b275a897 Ignore Funcref actions in g:fzf_action
A Funcref action in g:fzf_action only handles a list of file paths so
they can't be used to open windows.

Related:
- #185
- 2069bbc8b5
2017-08-14 17:42:33 +09:00
Junegunn Choi
d3b9fed9c2 [Ag] Drop --nth to make search faster 2017-07-30 20:14:17 +09:00
Junegunn Choi
685f9aae97 [Tags] Remove --with-nth option to speed up loading 2017-07-24 02:35:21 +09:00
Junegunn Choi
55f6bc8367 [Tags/Helptags] Do not proceed if perl is not found
Related: https://github.com/junegunn/fzf.vim/issues/22#issuecomment-311873515
2017-07-01 01:18:01 +09:00
Junegunn Choi
e1c3bba14b Update README regarding Windows support
Related: #372
2017-06-29 12:35:10 +09:00
Junegunn Choi
348a57a4a4 Allow fzf#complete to take hash argument with sink
This allows us to use the return value of fzf#wrap function with
fzf#complete.

This commit also removes obsolete g:fzf#vim#default_layout and
fzf#vim#layout.
2017-06-28 21:19:11 +09:00
Junegunn Choi
ccc32c3164 Do not depend on fugitive for finding git root
Revert #239
Close #387
2017-06-16 10:39:50 +09:00
Junegunn Choi
cf60e54647 [Commits] Commit hash can be longer 2017-06-10 03:44:52 +09:00
Junegunn Choi
990834ab6c [Helptags] Fix globpath pattern
Close #376
2017-05-22 01:29:48 +09:00
Junegunn Choi
536b6ace35 [[B]Tags] Proceed to the next command if the output is empty
Close #375
2017-05-20 01:52:19 +09:00
Junegunn Choi
d99169da2d Use FZF_PREVIEW_HEIGHT if available. Requires fzf 0.16.7.
Close #361
2017-04-30 12:06:41 +09:00
Junegunn Choi
8ffd3fb0ba [Maps] Fix parse error in non-US locales
Close #324

Caveat: The fix assumes that the paths of Vimscript files do not contain
whitespaces. Maps will report incorrect paths if they do.
2017-04-24 10:48:31 +09:00
Junegunn Choi
f3c3646c81 Fix <plug>(fzf-complete-buffer-line)
Reported by Roland Emmerich
2017-04-24 10:34:40 +09:00
Junegunn Choi
605d9da512 Update documentation 2017-03-18 02:14:43 +09:00
Blaž Hrastnik
4f00962a81 Add support for the rouge highlighter. (#336)
https://github.com/jneen/rouge
2017-03-18 02:07:06 +09:00
Junegunn Choi
2eaff04946 Show how to set up fzf#vim#files with fzf#vim#with_preview 2017-03-13 19:42:16 +09:00
Junegunn Choi
2b69c15226 Fix fzf#vim#with_preview: missing parentheses
Close #334
2017-03-13 19:28:40 +09:00
Junegunn Choi
b7a19efa46 Update .github/ISSUE_TEMPLATE.md
Provide the latest vimrc for testing.

Reference: https://gist.github.com/atenni/5604615
2017-03-13 12:13:25 +09:00
Junegunn Choi
06a8b870c0 [Tags] Support multiple tags files
We also apply --nth 1..2 by default to limit the search scope.

Close #106
Related #5, #329
2017-03-10 17:04:52 +09:00
Junegunn Choi
e4f79f6e98 Use shellescape instead of manual escaping
Close #328
2017-03-07 23:17:04 +09:00
Junegunn Choi
87a910a127 [[B]Commits] Enable sort by default 2017-03-03 12:20:44 +09:00
Junegunn Choi
364fea3ca0 [Tags] Temporarily unset autochdir
Close #269
2017-02-26 00:01:00 +09:00
Junegunn Choi
fcca65bbe5 [BTags] Fix "tag commnads" argument 2017-02-18 13:51:06 +09:00
sangwook
dade777e6d Check for exact command name (#306) 2017-02-08 11:58:58 +09:00
Junegunn Choi
1bf68a978b Do not override existing commands
So that we don't have to use VimEnter autocmd to override the commands
2017-02-07 11:40:31 +09:00
Junegunn Choi
4329721384 [Tags] Fall back to --algo=v1 if tags file is too large (> 200MB) 2017-02-03 12:34:20 +09:00
Junegunn Choi
f77b644797 Revert "Replace --tiebreak=index with --nth 1,.."
The original issue with --tiebreak=begin will be fixed in fzf 0.16.4 so
we should use --tiebreak=begin again to avoid tokenization overhead.
2017-02-03 12:24:27 +09:00
Junegunn Choi
22e59c4da0 Replace --tiebreak=index with --nth 1,..
Currently, --tiebreak=begin does not guarantee the best result due to
performance considerations. But --nth 1,.. works better in these cases
anyway.
2017-01-25 10:17:30 +09:00
Junegunn Choi
51a4d3090f Use 24-bit colors (fzf 0.16.2)
Close https://github.com/junegunn/fzf/issues/789
2017-01-24 01:49:00 +09:00
Junegunn Choi
f54ec7caf1 Do not preview binary files 2017-01-23 10:28:08 +09:00
Theo Belaire
3e8ac82cbb [Buffers] Allow query argument (#286) 2017-01-11 11:24:07 +09:00
Andreas Gerstmayr
bac82a954f [Tags] Add -a option to grep (#284)
Somehow the tags file generated by ctags for the linux kernel, tag
v4.10-rc1 contains non-ASCII characters. grep stops when it detects
non-ASCII characters. This patch adds the -a option to the grep command
to treat the tags file as ASCII text.

Signed-off-by: Andreas Gerstmayr <andreas.gerstmayr@gmail.com>
2017-01-07 10:56:29 +09:00
Matthew Klein
2066643243 [fzf#vim#colors] Remove duplicate colorschemes (#278)
Use s:uniq() instead of uniq() for older versions of Vim.

We don't sort the list before passing it to s:uniq() because
1. s:uniq() can process unsorted lists.
2. And in that way, we can list color schemes from plugins before
   the default ones provided by Vim.
2016-12-25 01:27:53 +09:00
Junegunn Choi
7460b4382c [GFiles?] Apply --tiebreak=index for status code filtering 2016-12-15 10:31:25 +09:00
Oscar Morrison
3d7dfc7068 Change to macOS (#268) 2016-12-11 21:20:59 +09:00
Junegunn Choi
abdf894edf [fzf#vim#with_preview] Expand relative path
Close #261
2016-12-08 13:30:06 +09:00
alex
42086bee57 Add preview.sh for ruby-less previews. (#259) 2016-12-05 02:11:22 +09:00
Junegunn Choi
eb9e5803b1 [Files] Fix path display when cwd is ~ 2016-12-03 01:16:01 +09:00
Junegunn Choi
59eb2b19ac [Files] Display relative path in prompt 2016-12-02 21:07:37 +09:00
Junegunn Choi
eb1f9b02f7 [fzf#vim#with_preview] Escape --bind expression
Close #256
2016-11-27 19:30:28 +09:00
Junegunn Choi
6e50206adf Apply -bar option to commands that do not take arguments 2016-11-26 21:51:24 +09:00
Nate
77db64ef2c Allow restyling of the fzf[123] groups (#254) 2016-11-26 14:59:06 +09:00
Didier Prophete
28a1835ce4 Redirect STDERR of ctags to /dev/null (#252) 2016-11-26 14:17:00 +09:00
Junegunn Choi
9ce2c2179f Add fzf#vim#with_preview function for previewing search result
Close #225
2016-11-26 14:11:27 +09:00
Junegunn Choi
3fbcfdb9ea [Buffers] Ignore quickfix Windows (#249) 2016-11-26 13:00:57 +09:00
Junegunn Choi
dc9364c137 [Tags] Case-insensitive Y/N prompt
Close #247
2016-11-22 12:36:18 +09:00
16 changed files with 2144 additions and 600 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*.sh text eol=lf

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
github: junegunn

View File

@@ -1,29 +0,0 @@
<!-- Check all that apply [x] -->
- Category
- [ ] Question
- [ ] Bug
- [ ] Suggestion
- OS
- [ ] Linux
- [ ] Mac OS X
- [ ] Windows
- [ ] Etc.
- Vim
- [ ] Vim
- [ ] Neovim
<!--
Before submitting
=================
- Make sure that you have the latest version of fzf and fzf.vim
- Check if your problem is reproducible with a minimal configuration
Start Vim with a minimal configuration
======================================
vim -Nu <(curl https://gist.githubusercontent.com/junegunn/6936bf79fedd3a079aeb1dd2f3c81ef5/raw/vimrc)
-->

49
.github/ISSUE_TEMPLATE/issue.yml vendored Normal file
View File

@@ -0,0 +1,49 @@
---
name: Issue Template
description: Report a problem or bug related to fzf.vim to help us improve
body:
- type: markdown
attributes:
value: |
Check the version of fzf used by running
```vim
:echo system(fzf#exec() .. ' --version')
```
If you don't have the latest version, run the following code to download it
```vim
:call fzf#install()
```
- type: checkboxes
attributes:
label: Checklist
options:
- label: I have fzf 0.54.0 or later
required: true
- label: I have searched through the existing issues
required: true
- type: input
attributes:
label: Output of `:echo system(fzf#exec() .. ' --version')`
validations:
required: true
- type: checkboxes
attributes:
label: OS
options:
- label: Linux
- label: macOS
- label: Windows
- label: Etc.
- type: textarea
attributes:
label: Problem / Steps to reproduce
validations:
required: true

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Junegunn Choi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

446
README.md
View File

@@ -6,16 +6,12 @@ Things you can do with [fzf][fzf] and Vim.
Rationale
---------
[fzf][fzf] in itself is not a Vim plugin, and the official repository only
provides the [basic wrapper function][run] for Vim and it's up to the users to
[fzf][fzf] itself is not a Vim plugin, and the official repository only
provides the [basic wrapper function][run] for Vim. It's up to the users to
write their own Vim commands with it. However, I've learned that many users of
fzf are not familiar with Vimscript and are looking for the "default"
implementation of the features they can find in the alternative Vim plugins.
This repository is a bundle of fzf-based commands and mappings extracted from
my [.vimrc][vimrc] to address such needs. They are *not* designed to be
flexible or configurable, and there's no guarantee of backward-compatibility.
Why you should use fzf on Vim
-----------------------------
@@ -27,60 +23,82 @@ is small, which is the case for many of the commands provided here.
Nevertheless I wrote them anyway since it's really easy to implement custom
selector with fzf.
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
note that fzf currently does not compile on Windows.
Installation
------------
Using [vim-plug](https://github.com/junegunn/vim-plug):
fzf.vim depends on the basic Vim plugin of [the main fzf
repository][fzf-main], which means you need to **set up both "fzf" and
"fzf.vim" on Vim**. To learn more about fzf/Vim integration, see
[README-VIM][README-VIM].
[fzf-main]: https://github.com/junegunn/fzf
[README-VIM]: https://github.com/junegunn/fzf/blob/master/README-VIM.md
### Using [vim-plug](https://github.com/junegunn/vim-plug)
```vim
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
```
- `dir` and `do` options are not mandatory
- 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
`fzf#install()` makes sure that you have the latest binary, but it's optional,
so you can omit it if you use a plugin manager that doesn't support hooks.
### Dependencies
- [fzf][fzf-main] 0.54.0 or above
- For syntax-highlighted preview, install [bat](https://github.com/sharkdp/bat)
- If [delta](https://github.com/dandavison/delta) is available, `GF?`,
`Commits` and `BCommits` will use it to format `git diff` output.
- `Ag` requires [The Silver Searcher (ag)][ag]
- `Rg` requires [ripgrep (rg)][rg]
- `Tags` and `Helptags` require Perl
- `Tags PREFIX` requires `readtags` command from [Universal Ctags](https://ctags.io/)
```sh
# Installing dependencies using Homebrew
brew install fzf bat ripgrep the_silver_searcher perl universal-ctags
```
Commands
--------
| Command | List |
| --- | --- |
| `Files [PATH]` | Files (similar to `:FZF`) |
| `GFiles [OPTS]` | Git files (`git ls-files`) |
| `GFiles?` | Git files (`git status`) |
| `Buffers` | Open buffers |
| `Colors` | Color schemes |
| `Ag [PATTERN]` | [ag][ag] search result (`ALT-A` to select all, `ALT-D` to deselect all) |
| `Lines [QUERY]` | Lines in loaded buffers |
| `BLines [QUERY]` | Lines in the current buffer |
| `Tags [QUERY]` | Tags in the project (`ctags -R`) |
| `BTags [QUERY]` | Tags in the current buffer |
| `Marks` | Marks |
| `Windows` | Windows |
| `Locate PATTERN` | `locate` command output |
| `History` | `v:oldfiles` and open buffers |
| `History:` | Command history |
| `History/` | Search history |
| `Snippets` | Snippets ([UltiSnips][us]) |
| `Commits` | Git commits (requires [fugitive.vim][f]) |
| `BCommits` | Git commits for the current buffer |
| `Commands` | Commands |
| `Maps` | Normal mode mappings |
| `Helptags` | Help tags <sup id="a1">[1](#helptags)</sup> |
| `Filetypes` | File types
| Command | List |
| --- | --- |
| `:Files [PATH]` | Files (runs `$FZF_DEFAULT_COMMAND` if defined) |
| `:GFiles [OPTS]` | Git files (`git ls-files`) |
| `:GFiles?` | Git files (`git status`) |
| `:Buffers` | Open buffers |
| `:Colors` | Color schemes |
| `:Ag [PATTERN]` | [ag][ag] search result (`ALT-A` to select all, `ALT-D` to deselect all) |
| `:Rg [PATTERN]` | [rg][rg] search result (`ALT-A` to select all, `ALT-D` to deselect all) |
| `:RG [PATTERN]` | [rg][rg] search result; relaunch ripgrep on every keystroke |
| `:Lines [QUERY]` | Lines in loaded buffers |
| `:BLines [QUERY]` | Lines in the current buffer |
| `:Tags [PREFIX]` | Tags in the project (`ctags -R`) |
| `:BTags [QUERY]` | Tags in the current buffer |
| `:Changes` | Changelist across all open buffers |
| `:Marks` | Marks |
| `:BMarks` | Marks in the current buffer |
| `:Jumps` | Jumps |
| `:Windows` | Windows |
| `:Locate PATTERN` | `locate` command output |
| `:History` | `v:oldfiles` and open buffers |
| `:History:` | Command history |
| `:History/` | Search history |
| `:Snippets` | Snippets ([UltiSnips][us]) |
| `:Commits [LOG_OPTS]` | Git commits (requires [fugitive.vim][f]) |
| `:BCommits [LOG_OPTS]` | Git commits for the current buffer; visual-select lines to track changes in the range |
| `:Commands` | Commands |
| `:Maps` | Normal mode mappings |
| `:Helptags` | Help tags <sup id="a1">[1](#helptags)</sup> |
| `:Filetypes` | File types
- 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
- 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
- e.g. `let g:fzf_command_prefix = 'Fzf'` and you have `FzfFiles`, etc.
- You can set `g:fzf_vim.command_prefix` to give the same prefix to the commands
- e.g. `let g:fzf_vim.command_prefix = 'Fzf'` and you have `FzfFiles`, etc.
(<a name="helptags">1</a>: `Helptags` will shadow the command of the same name
from [pathogen][pat]. But its functionality is still available via `call
@@ -89,81 +107,237 @@ pathogen#helptags()`. [↩](#a1))
[pat]: https://github.com/tpope/vim-pathogen
[f]: https://github.com/tpope/vim-fugitive
### Customization
Customization
-------------
#### Global options
### Configuration options of the base plugin
Every command in fzf.vim internally calls `fzf#wrap` function of the main
repository which supports a set of global option variables. So please read
through [README-VIM][README-VIM] to learn more about them.
### Configuration options for fzf.vim
All configuration values for this plugin are stored in `g:fzf_vim` dictionary,
so **make sure to initialize it before assigning any configuration values to
it**.
```vim
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
" In Neovim, you can set up fzf window using a Vim command
let g:fzf_layout = { 'window': 'enew' }
let g:fzf_layout = { 'window': '-tabnew' }
" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" Enable per-command history.
" CTRL-N and CTRL-P will be automatically bound to next-history and
" previous-history instead of down and up. If you don't like the change,
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history'
" Initialize configuration dictionary
let g:fzf_vim = {}
```
#### Command-local options
#### Preview window
Some commands will show the preview window on the right. You can customize the
behavior with `g:fzf_vim.preview_window`. Here are some examples:
```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.'"'
" This is the default option:
" - Preview window on the right with 50% width
" - CTRL-/ will toggle preview window.
" - Note that this array is passed as arguments to fzf#vim#with_preview function.
" - To learn more about preview window options, see `--preview-window` section of `man fzf`.
let g:fzf_vim.preview_window = ['right,50%', 'ctrl-/']
" [Buffers] Jump to the existing window if possible
let g:fzf_buffers_jump = 1
" Preview window is hidden by default. You can toggle it with ctrl-/.
" It will show on the right with 50% width, but if the width is smaller
" than 70 columns, it will show above the candidate list
let g:fzf_vim.preview_window = ['hidden,right,50%,<70(up,40%)', 'ctrl-/']
" Empty value to disable preview window altogether
let g:fzf_vim.preview_window = []
" fzf.vim needs bash to display the preview window.
" On Windows, fzf.vim will first see if bash is in $PATH, then if
" Git bash (C:\Program Files\Git\bin\bash.exe) is available.
" If you want it to use a different bash, set this variable.
" let g:fzf_vim = {}
" let g:fzf_vim.preview_bash = 'C:\Git\bin\bash.exe'
```
#### Command-level options
```vim
" [Buffers] Jump to the existing window if possible (default: 0)
let g:fzf_vim.buffers_jump = 1
" [Ag|Rg|RG] Display path on a separate line for narrow screens (default: 0)
" * Requires Perl and fzf 0.56.0 or later
let g:fzf_vim.grep_multi_line = 0
" PATH:LINE:COL:LINE
let g:fzf_vim.grep_multi_line = 1
" PATH:LINE:COL:
" LINE
let g:fzf_vim.grep_multi_line = 2
" PATH:LINE:COL:
" LINE
" (empty line between items using --gap option)
" [[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_vim.commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
" [Tags] Command to generate tags file
let g:fzf_tags_command = 'ctags -R'
let g:fzf_vim.tags_command = 'ctags -R'
" [Commands] --expect expression for directly executing the command
let g:fzf_commands_expect = 'alt-enter,ctrl-x'
let g:fzf_vim.commands_expect = 'alt-enter,ctrl-x'
```
#### Advanced customization using autoload functions
#### Command-level fzf options
You can use autoload functions to define your own commands.
You can set fzf options for each command by setting
`g:fzf_vim.{command}_options`.
```vim
" git grep
command! -bang -nargs=* GGrep
\ call fzf#vim#grep('git grep --line-number '.shellescape(<q-args>), 0, <bang>0)
" In string
let g:fzf_vim.buffers_options = '--style full --border-label " Open Buffers "'
" We use VimEnter event so that the code is run after fzf.vim is loaded
autocmd VimEnter * command! Colors
\ call fzf#vim#colors({'left': '15%', 'options': '--reverse --margin 30%,0'})
" In list (No need to quote or escape values)
let g:fzf_vim.buffers_options = ['--style', 'full', '--border-label', ' Open Buffers ']
```
#### List type to handle multiple selections
The following commands will fill the quickfix list when multiple entries are
selected.
* `Ag`
* `Rg` / `RG`
* `Lines` / `BLines`
* `Tags` / `BTags`
By setting `g:fzf_vim.listproc`, you can make them use location list instead.
```vim
" Default: Use quickfix list
let g:fzf_vim.listproc = { list -> fzf#vim#listproc#quickfix(list) }
" Use location list instead of quickfix list
let g:fzf_vim.listproc = { list -> fzf#vim#listproc#location(list) }
```
You can customize the list type per command by defining variables named
`g:fzf_vim.listproc_{command_name_in_lowercase}`.
```vim
" Command-wise customization
let g:fzf_vim.listproc_ag = { list -> fzf#vim#listproc#quickfix(list) }
let g:fzf_vim.listproc_rg = { list -> fzf#vim#listproc#location(list) }
```
You can further customize the behavior by providing a custom function to
process the list instead of using the predefined `fzf#vim#listproc#quickfix`
or `fzf#vim#listproc#location`.
```vim
" A customized version of fzf#vim#listproc#quickfix.
" The last two lines are commented out not to move to the first entry.
function! g:fzf_vim.listproc(list)
call setqflist(a:list)
copen
wincmd p
" cfirst
" normal! zvzz
endfunction
```
### Advanced customization
#### Vim functions
Each command in fzf.vim is backed by a Vim function. You can override
a command or define a variation of it by calling its corresponding function.
| Command | Vim function |
| --- | --- |
| `Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])` |
| `GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])` |
| `GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])` |
| `Buffers` | `fzf#vim#buffers([query string], [bufnrs list], [spec dict], [fullscreen bool])` |
| `Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])` |
| `Rg` | `fzf#vim#grep(command, [spec dict], [fullscreen bool])` |
| `RG` | `fzf#vim#grep2(command_prefix, query, [spec dict], [fullscreen bool])` |
| ... | ... |
(We can see that the last two optional arguments of each function are
identical. They are directly passed to `fzf#wrap` function. If you haven't
read [README-VIM][README-VIM] already, please read it before proceeding.)
#### Example: Customizing `Files` command
This is the default definition of `Files` command:
```vim
command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, <bang>0)
```
Let's say you want to a variation of it called `ProjectFiles` that only
searches inside `~/projects` directory. Then you can do it like this:
```vim
command! -bang ProjectFiles call fzf#vim#files('~/projects', <bang>0)
```
Or, if you want to override the command with different fzf options, just pass
a custom spec to the function.
```vim
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline']}, <bang>0)
```
Want a preview window?
```vim
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', 'cat {}']}, <bang>0)
```
It kind of works, but you probably want a nicer previewer program than `cat`.
fzf.vim ships [a versatile preview script](bin/preview.sh) you can readily
use. It internally executes [bat](https://github.com/sharkdp/bat) for syntax
highlighting, so make sure to install it.
```vim
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh {}']}, <bang>0)
```
However, it's not ideal to hard-code the path to the script which can be
different in different circumstances. So in order to make it easier to set up
the previewer, fzf.vim provides `fzf#vim#with_preview` helper function.
Similarly to `fzf#wrap`, it takes a spec dictionary and returns a copy of it
with additional preview options.
```vim
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0)
```
You can just omit the spec argument if you only want the previewer.
```vim
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
```
#### Example: `git grep` wrapper
The following example implements `GGrep` command that works similarly to
predefined `Ag` or `Rg` using `fzf#vim#grep`.
- We set the base directory to git root by setting `dir` attribute in spec
dictionary.
- [The preview script](bin/preview.sh) supports `grep` format
(`FILE_PATH:LINE_NO:...`), so we can just wrap the spec with
`fzf#vim#with_preview` as before to enable previewer.
```vim
command! -bang -nargs=* GGrep
\ call fzf#vim#grep(
\ 'git grep --line-number -- '.fzf#shellescape(<q-args>),
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
```
Mappings
@@ -178,12 +352,9 @@ Mappings
| `<plug>(fzf-complete-word)` | `cat /usr/share/dict/words` |
| `<plug>(fzf-complete-path)` | Path completion using `find` (file + dir) |
| `<plug>(fzf-complete-file)` | File completion using `find` |
| `<plug>(fzf-complete-file-ag)` | File completion using `ag` |
| `<plug>(fzf-complete-line)` | Line completion (all open buffers) |
| `<plug>(fzf-complete-buffer-line)` | Line completion (current buffer only) |
### Usage
```vim
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
@@ -193,22 +364,38 @@ omap <leader><tab> <plug>(fzf-maps-o)
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
" Advanced customization using autoload functions
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'})
```
### Completion helper
Completion functions
--------------------
`fzf#complete` is a helper function for creating custom fuzzy completion using
fzf. If the first parameter is a command string or a Vim list, it will be used
as the source.
| Function | Description |
| --- | --- |
| `fzf#vim#complete#path(command, [spec])` | Path completion |
| `fzf#vim#complete#word([spec])` | Word completion |
| `fzf#vim#complete#line([spec])` | Line completion (all open buffers) |
| `fzf#vim#complete#buffer_line([spec])` | Line completion (current buffer only) |
```vim
" Path completion with custom source command
inoremap <expr> <c-x><c-f> fzf#vim#complete#path('fd')
inoremap <expr> <c-x><c-f> fzf#vim#complete#path('rg --files')
" Word completion with custom spec with popup layout option
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }})
```
Custom completion
-----------------
`fzf#vim#complete` is a helper function for creating custom fuzzy completion
using fzf. If the first parameter is a command string or a Vim list, it will
be used as the source.
```vim
" Replace the default dictionary completion with fzf-based fuzzy completion
inoremap <expr> <c-x><c-k> fzf#complete('cat /usr/share/dict/words')
inoremap <expr> <c-x><c-k> fzf#vim#complete('cat /usr/share/dict/words')
```
For advanced uses, you can pass an options dictionary to the function. The set
@@ -222,24 +409,47 @@ following exceptions:
- Or a function to extract completion prefix
- Both `source` and `options` can be given as funcrefs that take the
completion prefix as the argument and return the final value
- `sink` or `sink*` are not allowed
- `sink` or `sink*` are ignored
#### Reducer example
```vim
" Global line completion (not just open buffers. ripgrep required.)
inoremap <expr> <c-x><c-l> fzf#vim#complete(fzf#wrap({
\ 'prefix': '^.*$',
\ 'source': 'rg -n ^ --color always',
\ 'options': '--ansi --delimiter : --nth 3..',
\ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }}))
```
### Reducer example
```vim
function! s:make_sentence(lines)
return substitute(join(a:lines), '^.', '\=toupper(submatch(0))', '').'.'
endfunction
inoremap <expr> <c-x><c-s> fzf#complete({
inoremap <expr> <c-x><c-s> fzf#vim#complete({
\ 'source': 'cat /usr/share/dict/words',
\ 'reducer': function('<sid>make_sentence'),
\ 'options': '--multi --reverse --margin 15%,0',
\ 'left': 20})
```
Status line (neovim)
--------------------
Status line of terminal buffer
------------------------------
When fzf starts in a terminal buffer (see [fzf/README-VIM.md][termbuf]), you
may want to customize the statusline of the containing buffer.
[termbuf]: https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzf-inside-terminal-buffer
### Hide statusline
```vim
autocmd! FileType fzf set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
```
### Custom statusline
```vim
function! s:fzf_statusline()
@@ -259,7 +469,7 @@ License
MIT
[fzf]: https://github.com/junegunn/fzf
[run]: https://github.com/junegunn/fzf#usage-as-vim-plugin
[vimrc]: https://github.com/junegunn/dotfiles/blob/master/vimrc
[run]: https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzfrun
[ag]: https://github.com/ggreer/the_silver_searcher
[rg]: https://github.com/BurntSushi/ripgrep
[us]: https://github.com/SirVer/ultisnips

1188
autoload/fzf/vim.vim Normal file → Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -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)
@@ -46,9 +47,10 @@ else
endif
function! fzf#vim#complete#word(...)
let sources = empty(&dictionary) ? ['/usr/share/dict/words'] : split(&dictionary, ',')
return fzf#vim#complete(s:extend({
\ 'source': 'cat /usr/share/dict/words'},
\ get(a:000, 0, g:fzf#vim#default_layout)))
\ 'source': 'cat ' . join(map(sources, 'fzf#shellescape(v:val)'))},
\ get(a:000, 0, fzf#wrap())))
endfunction
" ----------------------------------------------------------------------------
@@ -58,25 +60,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)
@@ -128,7 +131,7 @@ function! fzf#vim#complete#path(command, ...)
return fzf#vim#complete(s:extend({
\ 'prefix': s:function('s:fname_prefix'),
\ 'source': s:function('s:file_source'),
\ 'options': s:function('s:file_options')}, get(a:000, 0, g:fzf#vim#default_layout)))
\ 'options': s:function('s:file_options')}, get(a:000, 0, fzf#wrap())))
endfunction
" ----------------------------------------------------------------------------
@@ -147,13 +150,13 @@ function! fzf#vim#complete#line(...)
\ 'prefix': '^.*$',
\ 'source': lines,
\ 'options': '--tiebreak=index --ansi --nth '.nth.'.. --tabstop=1',
\ 'reducer': s:function('s:reduce_line')}, get(a:000, 0, g:fzf#vim#default_layout)))
\ 'reducer': s:function('s:reduce_line')}, get(a:000, 0, fzf#wrap())))
endfunction
function! fzf#vim#complete#buffer_line(...)
call fzf#vim#complete(s:extend({
return fzf#vim#complete(s:extend({
\ 'prefix': '^.*$',
\ 'source': s:uniq(getline(1, '$'))}, get(a:000, 0, g:fzf#vim#default_layout)))
\ 'source': fzf#vim#_uniq(getline(1, '$'))}, get(a:000, 0, fzf#wrap())))
endfunction
let &cpo = s:cpo_save

95
autoload/fzf/vim/ipc.vim Normal file
View File

@@ -0,0 +1,95 @@
" Copyright (c) 2024 Junegunn Choi
"
" MIT License
"
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be
" included in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
function! s:warn(message)
echohl WarningMsg
echom a:message
echohl None
return 0
endfunction
function! fzf#vim#ipc#start(Callback)
if !exists('*job_start') && !exists('*jobstart')
call s:warn('job_start/jobstart function not supported')
return ''
endif
if !executable('mkfifo')
call s:warn('mkfifo is not available')
return ''
endif
call fzf#vim#ipc#stop()
let g:fzf_ipc = { 'fifo': tempname(), 'callback': a:Callback }
if !filereadable(g:fzf_ipc.fifo)
call system('mkfifo '..shellescape(g:fzf_ipc.fifo))
if v:shell_error
call s:warn('Failed to create fifo')
endif
endif
call fzf#vim#ipc#restart()
return g:fzf_ipc.fifo
endfunction
function! fzf#vim#ipc#restart()
if !exists('g:fzf_ipc')
throw 'fzf#vim#ipc not started'
endif
let Callback = g:fzf_ipc.callback
if exists('*job_start')
let g:fzf_ipc.job = job_start(
\ ['cat', g:fzf_ipc.fifo],
\ {'out_cb': { _, msg -> call(Callback, [msg]) },
\ 'exit_cb': { _, status -> status == 0 ? fzf#vim#ipc#restart() : '' }}
\ )
else
let eof = ['']
let g:fzf_ipc.job = jobstart(
\ ['cat', g:fzf_ipc.fifo],
\ {'stdout_buffered': 1,
\ 'on_stdout': { j, msg, e -> msg != eof ? call(Callback, msg) : '' },
\ 'on_exit': { j, status, e -> status == 0 ? fzf#vim#ipc#restart() : '' }}
\ )
endif
endfunction
function! fzf#vim#ipc#stop()
if !exists('g:fzf_ipc')
return
endif
let job = g:fzf_ipc.job
if exists('*job_stop')
call job_stop(job)
else
call jobstop(job)
call jobwait([job])
endif
call delete(g:fzf_ipc.fifo)
unlet g:fzf_ipc
endfunction

View File

@@ -0,0 +1,38 @@
" Copyright (c) 2023 Junegunn Choi
"
" MIT License
"
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be
" included in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
function! fzf#vim#listproc#quickfix(list)
call setqflist(a:list)
copen
wincmd p
cfirst
normal! zvzz
endfunction
function! fzf#vim#listproc#location(list)
call setloclist(0, a:list)
lopen
wincmd p
lfirst
normal! zvzz
endfunction

3
bin/preview.rb Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
puts 'preview.rb is deprecated. Use preview.sh instead.'

93
bin/preview.sh Executable file
View File

@@ -0,0 +1,93 @@
#!/usr/bin/env bash
REVERSE="\x1b[7m"
RESET="\x1b[m"
if [[ $# -lt 1 ]]; then
echo "usage: $0 [--tag] FILENAME[:LINENO][:IGNORED]"
exit 1
fi
if [[ $1 = --tag ]]; then
shift
"$(dirname "${BASH_SOURCE[0]}")/tagpreview.sh" "$@"
exit $?
fi
# Ignore if an empty path is given
[[ -z $1 ]] && exit
IFS=':' read -r -a INPUT <<< "$1"
FILE=${INPUT[0]}
CENTER=${INPUT[1]}
if [[ "$1" =~ ^[A-Za-z]:\\ ]]; then
FILE=$FILE:${INPUT[1]}
CENTER=${INPUT[2]}
fi
if [[ -n "$CENTER" && ! "$CENTER" =~ ^[0-9] ]]; then
exit 1
fi
CENTER=${CENTER/[^0-9]*/}
# MS Win support
if [[ "$FILE" =~ '\' ]]; then
if [ -z "$MSWINHOME" ]; then
MSWINHOME="$HOMEDRIVE$HOMEPATH"
fi
if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null ; then
MSWINHOME="${MSWINHOME//\\/\\\\}"
FILE="${FILE/#\~\\/$MSWINHOME\\}"
FILE=$(wslpath -u "$FILE")
elif [ -n "$MSWINHOME" ]; then
FILE="${FILE/#\~\\/$MSWINHOME\\}"
fi
fi
FILE="${FILE/#\~\//$HOME/}"
if [ ! -r "$FILE" ]; then
if [[ "${INPUT[0]}" != '[No Name]' ]]; then
echo "File not found ${FILE}"
fi
exit 1
fi
if [ -z "$CENTER" ]; then
CENTER=0
fi
# Sometimes bat is installed as batcat.
if [[ -z "$BATCAT" ]]; then
if command -v batcat > /dev/null; then
BATCAT="batcat"
elif command -v bat > /dev/null; then
BATCAT="bat"
fi
fi
if [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${BATCAT:+x}" ] && [[ ! -d "$FILE" ]] ; then
${BATCAT} --style="${BAT_STYLE:-numbers}" --color=always --pager=never \
--highlight-line=$CENTER -- "$FILE"
exit $?
fi
FILE_LENGTH=${#FILE}
MIME=$(file --dereference --mime -- "$FILE")
if [[ "${MIME:FILE_LENGTH}" =~ binary ]] && [[ ! -d "$FILE" ]]; then
echo "$MIME"
exit 0
fi
DEFAULT_COMMAND="highlight -O ansi -l {} || coderay {} || rougify {} || cat {}"
if [[ -d "$FILE" ]]; then
DEFAULT_COMMAND="tree -C -L2 {} || ls -l --color=always {}"
fi
CMD=${FZF_PREVIEW_COMMAND:-$DEFAULT_COMMAND}
CMD=${CMD//{\}/"$(printf %q "$FILE")"}
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); \
}"

73
bin/tagpreview.sh Executable file
View File

@@ -0,0 +1,73 @@
#!/usr/bin/env bash
REVERSE="\x1b[7m"
RESET="\x1b[m"
if [ -z "$1" ]; then
echo "usage: $0 FILENAME:TAGFILE:EXCMD"
exit 1
fi
IFS=':' read -r FILE TAGFILE EXCMD <<< "$*"
# Complete file paths which are relative to the given tag file
if [ "${FILE:0:1}" != "/" ]; then
FILE="$(dirname "${TAGFILE}")/${FILE}"
fi
if [ ! -r "$FILE" ]; then
echo "File not found ${FILE}"
exit 1
fi
# If users aren't using vim, they are probably using neovim
if command -v vim > /dev/null; then
VIMNAME="vim"
elif command -v nvim > /dev/null; then
VIMNAME="nvim"
else
echo "Cannot preview tag: vim or nvim unavailable"
exit 1
fi
CENTER="$("${VIMNAME}" -R -i NONE -u NONE -e -m -s "${FILE}" \
-c "set nomagic" \
-c "silent ${EXCMD}" \
-c 'let l=line(".") | new | put =l | print | qa!')" || exit
START_LINE="$(( CENTER - FZF_PREVIEW_LINES / 2 ))"
if (( START_LINE <= 0 )); then
START_LINE=1
fi
END_LINE="$(( START_LINE + FZF_PREVIEW_LINES - 1 ))"
# Sometimes bat is installed as batcat.
if command -v batcat > /dev/null; then
BATNAME="batcat"
elif command -v bat > /dev/null; then
BATNAME="bat"
fi
if [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${BATNAME:+x}" ]; then
${BATNAME} --style="${BAT_STYLE:-numbers}" \
--color=always \
--pager=never \
--wrap=never \
--terminal-width="${FZF_PREVIEW_COLUMNS}" \
--line-range="${START_LINE}:${END_LINE}" \
--highlight-line="${CENTER}" \
"$FILE"
exit $?
fi
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 "{ \
if (NR >= $START_LINE && NR <= $END_LINE) { \
if (NR == $CENTER) \
{ gsub(/\x1b[[0-9;]*m/, \"&$REVERSE\"); printf(\"$REVERSE%s\n$RESET\", \$0); } \
else printf(\"$RESET%s\n\", \$0); \
} \
}"

23
bin/tags.pl Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env perl
use strict;
my $prefix = shift @ARGV;
foreach my $file (@ARGV) {
my $lines;
if ($prefix eq "") {
open $lines, $file;
} else {
# https://perldoc.perl.org/perlopentut#Expressing-the-command-as-a-list
open $lines, '-|', 'readtags', '-t', $file, '-e', '-p', '-', $prefix;
}
while (<$lines>) {
unless (/^\!/) {
s/^[^\t]*/sprintf("%-24s", $&)/e;
s/$/\t$file/;
print;
}
}
close $lines;
}

View File

@@ -1,20 +1,35 @@
fzf-vim.txt fzf-vim Last change: September 20 2015
fzf-vim.txt fzf-vim Last change: June 8 2025
FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc*
==============================================================================
fzf :heart: vim
Rationale
Why you should use fzf on Vim
Installation
Commands
Customization
Mappings
Usage
Completion helper
Reducer example
License
fzf :heart: vim |fzf-vim-fzfheart-vim|
Rationale |fzf-vim-rationale|
Why you should use fzf on Vim |fzf-vim-why-you-should-use-fzf-on-vim|
Installation |fzf-vim-installation|
Using vim-plug |fzf-vim-using-vim-plug|
Dependencies |fzf-vim-dependencies|
Commands |fzf-vim-commands|
Customization |fzf-vim-customization|
Configuration options of the base plugin |fzf-vim-configuration-options-of-the-base-plugin|
Configuration options for fzf.vim |fzf-vim-configuration-options-for-fzf-vim|
Preview window |fzf-vim-preview-window|
Command-level options |fzf-vim-command-level-options|
Command-level fzf options |fzf-vim-command-level-fzf-options|
List type to handle multiple selections |fzf-vim-list-type-to-handle-multiple-selections|
Advanced customization |fzf-vim-advanced-customization|
Vim functions |fzf-vim-vim-functions|
Example: Customizing Files command |fzf-vim-example-customizing-files-command|
Example: git grep wrapper |fzf-vim-example-git-grep-wrapper|
Mappings |fzf-vim-mappings|
Completion functions |fzf-vim-completion-functions|
Custom completion |fzf-vim-custom-completion|
Reducer example |fzf-vim-reducer-example|
Status line of terminal buffer |fzf-vim-status-line-of-terminal-buffer|
Hide statusline |fzf-vim-hide-statusline|
Custom statusline |fzf-vim-custom-statusline|
License |fzf-vim-license|
FZF :HEART: VIM *fzf-vim-fzf-heart-vim*
FZF :HEART: VIM *fzf-vim-fzfheart-vim*
==============================================================================
Things you can do with {fzf}{1} and Vim.
@@ -25,19 +40,14 @@ Things you can do with {fzf}{1} and Vim.
RATIONALE *fzf-vim-rationale*
==============================================================================
{fzf}{1} in itself is not a Vim plugin, and the official repository only
provides the {basic wrapper function}{2} for Vim and it's up to the users to
write their own Vim commands with it. However, I've learned that many users of
fzf are not familiar with Vimscript and are looking for the "default"
implementation of the features they can find in the alternative Vim plugins.
{fzf}{1} itself is not a Vim plugin, and the official repository only provides
the {basic wrapper function}{2} for Vim. It's up to the users to write their
own Vim commands with it. However, I've learned that many users of fzf are not
familiar with Vimscript and are looking for the "default" implementation of
the features they can find in the alternative Vim plugins.
This repository is a bundle of fzf-based commands and mappings extracted from
my {.vimrc}{3} to address such needs. They are not designed to be flexible or
configurable, and there's no guarantee of backward-compatibility.
{1} https://github.com/junegunn/fzf
{2} https://github.com/junegunn/fzf#usage-as-vim-plugin
{3} https://github.com/junegunn/dotfiles/blob/master/vimrc
{1} https://github.com/junegunn/fzf
{2} https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzfrun
WHY YOU SHOULD USE FZF ON VIM *fzf-vim-why-you-should-use-fzf-on-vim*
@@ -51,147 +61,356 @@ is small, which is the case for many of the commands provided here.
Nevertheless I wrote them anyway since it's really easy to implement custom
selector with fzf.
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
note that fzf currently does not compile on Windows.
INSTALLATION *fzf-vim-installation*
==============================================================================
Using {vim-plug}{4}:
fzf.vim depends on the basic Vim plugin of {the main fzf repository}{1}, which
means you need to set up both "fzf" and "fzf.vim" on Vim. To learn more about
fzf/Vim integration, see {README-VIM}{3}.
{1} https://github.com/junegunn/fzf
{3} https://github.com/junegunn/fzf/blob/master/README-VIM.md
< Using vim-plug >____________________________________________________________~
*fzf-vim-using-vim-plug*
>
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
<
{4} https://github.com/junegunn/vim-plug
`fzf#install()` makes sure that you have the latest binary, but it's optional,
so you can omit it if you use a plugin manager that doesn't support hooks.
< Dependencies >______________________________________________________________~
*fzf-vim-dependencies*
- {fzf}{1} 0.54.0 or above
- For syntax-highlighted preview, install {bat}{4}
- If {delta}{5} is available, `GF?`, `Commits` and `BCommits` will use it to
format `git diff` output.
- `Ag` requires {The Silver Searcher (ag)}{6}
- `Rg` requires {ripgrep (rg)}{7}
- `Tags` and `Helptags` require Perl
- `Tags PREFIX` requires `readtags` command from {Universal Ctags}{8}
>
# Installing dependencies using Homebrew
brew install fzf bat ripgrep the_silver_searcher perl universal-ctags
<
{1} https://github.com/junegunn/fzf
{4} https://github.com/sharkdp/bat
{5} https://github.com/dandavison/delta
{6} https://github.com/ggreer/the_silver_searcher
{7} https://github.com/BurntSushi/ripgrep
{8} https://ctags.io/
COMMANDS *fzf-vim-commands*
==============================================================================
*:Files* *:GFiles* *:Buffers* *:Colors* *:Ag* *:Rg* *:RG* *:Lines* *:BLines* *:Tags* *:BTags*
*:Changes* *:Marks* *:BMarks* *:Jumps* *:Windows* *:Locate* *:History* *:Snippets* *:Commits*
*:BCommits* *:Commands* *:Maps* *:Helptags* *:Filetypes*
-----------------+-------------------------------------------------------------------
Command | List ~
-----------------+-------------------------------------------------------------------
`Files[PATH]` | Files (similar to `:FZF` )
`GFiles [OPTS]` | Git files (git ls-files)
`GFiles?` | Git files (git status)
`Buffers` | Open buffers
`Colors` | Color schemes
`Ag[PATTERN]` | {ag}{5} search result (ALT-A to select all, ALT-D to deselect all)
`Lines [QUERY]` | Lines in loaded buffers
`BLines [QUERY]` | Lines in the current buffer
`Tags[QUERY]` | Tags in the project ( `ctags-R` )
`BTags[QUERY]` | Tags in the current buffer
`Marks` | Marks
`Windows` | Windows
`LocatePATTERN` | `locate` command output
`History` | `v:oldfiles` and open buffers
`History:` | Command history
`History/` | Search history
`Snippets` | Snippets ({UltiSnips}{6})
`Commits` | Git commits (requires {fugitive.vim}{7})
`BCommits` | Git commits for the current buffer
`Commands` | Commands
`Maps` | Normal mode mappings
`Helptags` | Help tags [1]
`Filetypes` | File types
-----------------+-------------------------------------------------------------------
-----------------------+--------------------------------------------------------------------------------------
Command | List ~
-----------------------+--------------------------------------------------------------------------------------
`:Files [PATH]` | Files (runs `$FZF_DEFAULT_COMMAND` if defined)
`:GFiles [OPTS]` | Git files ( `git ls-files` )
`:GFiles?` | Git files ( `git status` )
`:Buffers` | Open buffers
`:Colors` | Color schemes
`:Ag [PATTERN]` | {ag}{6} search result ( `ALT-A` to select all, `ALT-D` to deselect all)
`:Rg [PATTERN]` | {rg}{7} search result ( `ALT-A` to select all, `ALT-D` to deselect all)
`:RG [PATTERN]` | {rg}{7} search result; relaunch ripgrep on every keystroke
`:Lines [QUERY]` | Lines in loaded buffers
`:BLines [QUERY]` | Lines in the current buffer
`:Tags [PREFIX]` | Tags in the project ( `ctags -R` )
`:BTags [QUERY]` | Tags in the current buffer
`:Changes` | Changelist across all open buffers
`:Marks` | Marks
`:BMarks` | Marks in the current buffer
`:Jumps` | Jumps
`:Windows` | Windows
`:Locate PATTERN` | `locate` command output
`:History` | `v:oldfiles` and open buffers
`:History:` | Command history
`:History/` | Search history
`:Snippets` | Snippets ({UltiSnips}{9})
`:Commits [LOG_OPTS]` | Git commits (requires {fugitive.vim}{10})
`:BCommits [LOG_OPTS]` | Git commits for the current buffer; visual-select lines to track changes in the range
`:Commands` | Commands
`:Maps` | Normal mode mappings
`:Helptags` | Help tags [1]
`:Filetypes` | File types
-----------------------+--------------------------------------------------------------------------------------
*g:fzf_vim.command_prefix*
- 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
- 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
- e.g. `let g:fzf_command_prefix = 'Fzf'` and you have `FzfFiles`, etc.
- You can set `g:fzf_vim.command_prefix` to give the same prefix to the commands
- e.g. `let g:fzf_vim.command_prefix = 'Fzf'` and you have `FzfFiles`, etc.
(1: `Helptags` will shadow the command of the same name from {pathogen}{8}.
But its functionality is still available via `call pathogen#helptags()`.)
(1: `Helptags` will shadow the command of the same name from {pathogen}{11}.
But its functionality is still available via `call pathogen#helptags()`. [↩])
{5} https://github.com/ggreer/the_silver_searcher
{6} https://github.com/SirVer/ultisnips
{7} https://github.com/tpope/vim-fugitive
{8} https://github.com/tpope/vim-pathogen
{6} https://github.com/ggreer/the_silver_searcher
{7} https://github.com/BurntSushi/ripgrep
{7} https://github.com/BurntSushi/ripgrep
{9} https://github.com/SirVer/ultisnips
{10} https://github.com/tpope/vim-fugitive
{11} https://github.com/tpope/vim-pathogen
< Customization >_____________________________________________________________~
*fzf-vim-customization*
CUSTOMIZATION *fzf-vim-customization*
==============================================================================
*g:fzf_action* *g:fzf_layout* *g:fzf_colors* *g:fzf_commits_log_options*
Global options~
< Configuration options of the base plugin >__________________________________~
*fzf-vim-configuration-options-of-the-base-plugin*
Every command in fzf.vim internally calls `fzf#wrap` function of the main
repository which supports a set of global option variables. So please read
through {README-VIM}{3} to learn more about them.
{3} https://github.com/junegunn/fzf/blob/master/README-VIM.md
< Configuration options for fzf.vim >_________________________________________~
*fzf-vim-configuration-options-for-fzf-vim*
*g:fzf_vim*
All configuration values for this plugin are stored in `g:fzf_vim` dictionary,
so make sure to initialize it before assigning any configuration values to it.
>
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
" In Neovim, you can set up fzf window using a Vim command
let g:fzf_layout = { 'window': 'enew' }
let g:fzf_layout = { 'window': '-tabnew' }
" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" Enable per-command history.
" CTRL-N and CTRL-P will be automatically bound to next-history and
" previous-history instead of down and up. If you don't like the change,
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history'
" Initialize configuration dictionary
let g:fzf_vim = {}
<
Command-local options~
Preview window~
*fzf-vim-preview-window*
*g:fzf_vim.preview_window*
Some commands will show the preview window on the right. You can customize the
behavior with `g:fzf_vim.preview_window`. Here are some examples:
*g:fzf_vim.preview_bash*
>
" [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.'"'
" This is the default option:
" - Preview window on the right with 50% width
" - CTRL-/ will toggle preview window.
" - Note that this array is passed as arguments to fzf#vim#with_preview function.
" - To learn more about preview window options, see `--preview-window` section of `man fzf`.
let g:fzf_vim.preview_window = ['right,50%', 'ctrl-/']
" [Buffers] Jump to the existing window if possible
let g:fzf_buffers_jump = 1
" Preview window is hidden by default. You can toggle it with ctrl-/.
" It will show on the right with 50% width, but if the width is smaller
" than 70 columns, it will show above the candidate list
let g:fzf_vim.preview_window = ['hidden,right,50%,<70(up,40%)', 'ctrl-/']
" Empty value to disable preview window altogether
let g:fzf_vim.preview_window = []
" fzf.vim needs bash to display the preview window.
" On Windows, fzf.vim will first see if bash is in $PATH, then if
" Git bash (C:\Program Files\Git\bin\bash.exe) is available.
" If you want it to use a different bash, set this variable.
" let g:fzf_vim = {}
" let g:fzf_vim.preview_bash = 'C:\Git\bin\bash.exe'
<
Command-level options~
*fzf-vim-command-level-options*
*g:fzf_vim.commands_expect* *g:fzf_vim.tags_command* *g:fzf_vim.commits_log_options*
*g:fzf_vim.buffers_jump*
>
" [Buffers] Jump to the existing window if possible (default: 0)
let g:fzf_vim.buffers_jump = 1
" [Ag|Rg|RG] Display path on a separate line for narrow screens (default: 0)
" * Requires Perl and fzf 0.56.0 or later
let g:fzf_vim.grep_multi_line = 0
" PATH:LINE:COL:LINE
let g:fzf_vim.grep_multi_line = 1
" PATH:LINE:COL:
" LINE
let g:fzf_vim.grep_multi_line = 2
" PATH:LINE:COL:
" LINE
" (empty line between items using --gap option)
" [[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_vim.commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
" [Tags] Command to generate tags file
let g:fzf_tags_command = 'ctags -R'
let g:fzf_vim.tags_command = 'ctags -R'
" [Commands] --expect expression for directly executing the command
let g:fzf_commands_expect = 'alt-enter,ctrl-x'
let g:fzf_vim.commands_expect = 'alt-enter,ctrl-x'
<
Advanced customization using autoload functions~
Command-level fzf options~
*fzf-vim-command-level-fzf-options*
You can use autoload functions to define your own commands.
You can set fzf options for each command by setting
`g:fzf_vim.{command}_options`.
>
" git grep
command! -bang -nargs=* GGrep
\ call fzf#vim#grep('git grep --line-number '.shellescape(<q-args>), 0, <bang>0)
" In string
let g:fzf_vim.buffers_options = '--style full --border-label " Open Buffers "'
" We use VimEnter event so that the code is run after fzf.vim is loaded
autocmd VimEnter * command! Colors
\ call fzf#vim#colors({'left': '15%', 'options': '--reverse --margin 30%,0'})
" In list (No need to quote or escape values)
let g:fzf_vim.buffers_options = ['--style', 'full', '--border-label', ' Open Buffers ']
<
List type to handle multiple selections~
*fzf-vim-list-type-to-handle-multiple-selections*
The following commands will fill the quickfix list when multiple entries are
selected.
- `Ag`
- `Rg` / `RG`
- `Lines` / `BLines`
- `Tags` / `BTags`
*g:fzf_vim.listproc*
By setting `g:fzf_vim.listproc`, you can make them use location list instead.
>
" Default: Use quickfix list
let g:fzf_vim.listproc = { list -> fzf#vim#listproc#quickfix(list) }
" Use location list instead of quickfix list
let g:fzf_vim.listproc = { list -> fzf#vim#listproc#location(list) }
<
You can customize the list type per command by defining variables named
`g:fzf_vim.listproc_{command_name_in_lowercase}`.
*g:fzf_vim.listproc_rg* *g:fzf_vim.listproc_ag*
>
" Command-wise customization
let g:fzf_vim.listproc_ag = { list -> fzf#vim#listproc#quickfix(list) }
let g:fzf_vim.listproc_rg = { list -> fzf#vim#listproc#location(list) }
<
You can further customize the behavior by providing a custom function to
process the list instead of using the predefined `fzf#vim#listproc#quickfix`
or `fzf#vim#listproc#location`.
>
" A customized version of fzf#vim#listproc#quickfix.
" The last two lines are commented out not to move to the first entry.
function! g:fzf_vim.listproc(list)
call setqflist(a:list)
copen
wincmd p
" cfirst
" normal! zvzz
endfunction
<
< Advanced customization >____________________________________________________~
*fzf-vim-advanced-customization*
Vim functions~
*fzf-vim-vim-functions*
Each command in fzf.vim is backed by a Vim function. You can override a
command or define a variation of it by calling its corresponding function.
----------+---------------------------------------------------------------------------------
Command | Vim function ~
----------+---------------------------------------------------------------------------------
`Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])`
`GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])`
`GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])`
`Buffers` | `fzf#vim#buffers([query string], [bufnrs list], [spec dict], [fullscreen bool])`
`Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])`
`Rg` | `fzf#vim#grep(command, [spec dict], [fullscreen bool])`
`RG` | `fzf#vim#grep2(command_prefix, query, [spec dict], [fullscreen bool])`
... | ...
----------+---------------------------------------------------------------------------------
(We can see that the last two optional arguments of each function are
identical. They are directly passed to `fzf#wrap` function. If you haven't
read {README-VIM}{3} already, please read it before proceeding.)
{3} https://github.com/junegunn/fzf/blob/master/README-VIM.md
Example: Customizing Files command~
*fzf-vim-example-customizing-files-command*
This is the default definition of `Files` command:
>
command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, <bang>0)
<
Let's say you want to a variation of it called `ProjectFiles` that only
searches inside `~/projects` directory. Then you can do it like this:
>
command! -bang ProjectFiles call fzf#vim#files('~/projects', <bang>0)
<
Or, if you want to override the command with different fzf options, just pass
a custom spec to the function.
>
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline']}, <bang>0)
<
Want a preview window?
>
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', 'cat {}']}, <bang>0)
<
It kind of works, but you probably want a nicer previewer program than `cat`.
fzf.vim ships {a versatile preview script}{12} you can readily use. It
internally executes {bat}{4} for syntax highlighting, so make sure to install
it.
>
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh {}']}, <bang>0)
<
However, it's not ideal to hard-code the path to the script which can be
different in different circumstances. So in order to make it easier to set up
the previewer, fzf.vim provides `fzf#vim#with_preview` helper function.
Similarly to `fzf#wrap`, it takes a spec dictionary and returns a copy of it
with additional preview options.
>
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0)
<
You can just omit the spec argument if you only want the previewer.
>
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
<
{12} bin/preview.sh
{4} https://github.com/sharkdp/bat
Example: git grep wrapper~
*fzf-vim-example-git-grep-wrapper*
The following example implements `GGrep` command that works similarly to
predefined `Ag` or `Rg` using `fzf#vim#grep`.
- We set the base directory to git root by setting `dir` attribute in spec
dictionary.
- {The preview script}{12} supports `grep` format (`FILE_PATH:LINE_NO:...`), so
we can just wrap the spec with `fzf#vim#with_preview` as before to enable
previewer.
>
command! -bang -nargs=* GGrep
\ call fzf#vim#grep(
\ 'git grep --line-number -- '.fzf#shellescape(<q-args>),
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
<
{12} bin/preview.sh
MAPPINGS *fzf-vim-mappings*
==============================================================================
@@ -203,17 +422,12 @@ MAPPINGS *fzf-vim-mappings*
<plug>(fzf-maps-i) | Insert mode mappings
<plug>(fzf-maps-x) | Visual mode mappings
<plug>(fzf-maps-o) | Operator-pending mappings
<plug>(fzf-complete-word) | `cat/usr/share/dict/words`
<plug>(fzf-complete-word) | `cat /usr/share/dict/words`
<plug>(fzf-complete-path) | Path completion using `find` (file + dir)
<plug>(fzf-complete-file) | File completion using `find`
<plug>(fzf-complete-file-ag) | File completion using `ag`
<plug>(fzf-complete-line) | Line completion (all open buffers)
<plug>(fzf-complete-buffer-line) | Line completion (current buffer only)
---------------------------------+------------------------------------------
< Usage >_____________________________________________________________________~
*fzf-vim-usage*
>
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
@@ -223,22 +437,38 @@ MAPPINGS *fzf-vim-mappings*
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
" Advanced customization using autoload functions
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'})
<
< Completion helper >_________________________________________________________~
*fzf-vim-completion-helper*
COMPLETION FUNCTIONS *fzf-vim-completion-functions*
==============================================================================
`fzf#complete` is a helper function for creating custom fuzzy completion using
fzf. If the first parameter is a command string or a Vim list, it will be used
as the source.
-----------------------------------------+--------------------------------------
Function | Description ~
-----------------------------------------+--------------------------------------
`fzf#vim#complete#path(command, [spec])` | Path completion
`fzf#vim#complete#word([spec])` | Word completion
`fzf#vim#complete#line([spec])` | Line completion (all open buffers)
`fzf#vim#complete#buffer_line([spec])` | Line completion (current buffer only)
-----------------------------------------+--------------------------------------
>
" Path completion with custom source command
inoremap <expr> <c-x><c-f> fzf#vim#complete#path('fd')
inoremap <expr> <c-x><c-f> fzf#vim#complete#path('rg --files')
" Word completion with custom spec with popup layout option
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }})
<
CUSTOM COMPLETION *fzf-vim-custom-completion*
==============================================================================
`fzf#vim#complete` is a helper function for creating custom fuzzy completion
using fzf. If the first parameter is a command string or a Vim list, it will
be used as the source.
>
" Replace the default dictionary completion with fzf-based fuzzy completion
inoremap <expr> <c-x><c-k> fzf#complete('cat /usr/share/dict/words')
inoremap <expr> <c-x><c-k> fzf#vim#complete('cat /usr/share/dict/words')
<
For advanced uses, you can pass an options dictionary to the function. The set
of options is pretty much identical to that for `fzf#run` only with the
@@ -251,23 +481,60 @@ following exceptions:
- Or a function to extract completion prefix
- Both `source` and `options` can be given as funcrefs that take the completion
prefix as the argument and return the final value
- `sink` or `sink*` are not allowed
- `sink` or `sink*` are ignored
>
" Global line completion (not just open buffers. ripgrep required.)
inoremap <expr> <c-x><c-l> fzf#vim#complete(fzf#wrap({
\ 'prefix': '^.*$',
\ 'source': 'rg -n ^ --color always',
\ 'options': '--ansi --delimiter : --nth 3..',
\ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }}))
<
Reducer example~
< Reducer example >___________________________________________________________~
*fzf-vim-reducer-example*
>
function! s:make_sentence(lines)
return substitute(join(a:lines), '^.', '\=toupper(submatch(0))', '').'.'
endfunction
inoremap <expr> <c-x><c-s> fzf#complete({
inoremap <expr> <c-x><c-s> fzf#vim#complete({
\ 'source': 'cat /usr/share/dict/words',
\ 'reducer': function('<sid>make_sentence'),
\ 'options': '--multi --reverse --margin 15%,0',
\ 'left': 20})
<
STATUS LINE OF TERMINAL BUFFER *fzf-vim-status-line-of-terminal-buffer*
==============================================================================
When fzf starts in a terminal buffer (see {fzf/README-VIM.md}{13}), you may
want to customize the statusline of the containing buffer.
{13} https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzf-inside-terminal-buffer
< Hide statusline >___________________________________________________________~
*fzf-vim-hide-statusline*
>
autocmd! FileType fzf set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
<
< Custom statusline >_________________________________________________________~
*fzf-vim-custom-statusline*
>
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*
==============================================================================

View File

@@ -21,53 +21,71 @@
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
if exists('g:loaded_fzf_vim')
finish
endif
let g:loaded_fzf_vim = 1
let s:cpo_save = &cpo
set cpo&vim
let s:is_win = has('win32') || has('win64')
let g:fzf#vim#default_layout = {'down': '~40%'}
function! s:conf(name, default)
let conf = get(g:, 'fzf_vim', {})
let val = get(conf, a:name, get(g:, 'fzf_' . a:name, a:default))
return val
endfunction
function! s:defs(commands)
let prefix = get(g:, 'fzf_command_prefix', '')
let prefix = s:conf('command_prefix', '')
if prefix =~# '^[^A-Z]'
echoerr 'g:fzf_command_prefix must start with an uppercase letter'
return
endif
for command in a:commands
execute substitute(command, '\ze\C[A-Z]', prefix, '')
let name = ':'.prefix.matchstr(command, '\C[A-Z]\S\+')
if 2 != exists(name)
execute substitute(command, '\ze\C[A-Z]', prefix, '')
endif
endfor
endfunction
call s:defs([
\'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=? GFiles call fzf#vim#gitfiles(<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=* BLines call fzf#vim#buffer_lines(<q-args>, <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=* Ag call fzf#vim#ag(<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 Snippets call fzf#vim#snippets(<bang>0)',
\'command! -bang Commands call fzf#vim#commands(<bang>0)',
\'command! -bang Marks call fzf#vim#marks(<bang>0)',
\'command! -bang Helptags call fzf#vim#helptags(<bang>0)',
\'command! -bang Windows call fzf#vim#windows(<bang>0)',
\'command! -bang Commits call fzf#vim#commits(<bang>0)',
\'command! -bang BCommits call fzf#vim#buffer_commits(<bang>0)',
\'command! -bang Maps call fzf#vim#maps("n", <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=? -complete=dir Files call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)',
\'command! -bang -nargs=? GitFiles call fzf#vim#gitfiles(<q-args>, fzf#vim#with_preview(<q-args> == "?" ? { "placeholder": "" } : {}), <bang>0)',
\'command! -bang -nargs=? GFiles call fzf#vim#gitfiles(<q-args>, fzf#vim#with_preview(<q-args> == "?" ? { "placeholder": "" } : {}), <bang>0)',
\'command! -bar -bang -nargs=? -complete=buffer Buffers call fzf#vim#buffers(<q-args>, fzf#vim#with_preview({ "placeholder": "{1}" }), <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! -bar -bang Colors call fzf#vim#colors(<bang>0)',
\'command! -bang -nargs=+ -complete=dir Locate call fzf#vim#locate(<q-args>, fzf#vim#with_preview(), <bang>0)',
\'command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, fzf#vim#with_preview(), <bang>0)',
\'command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case -- ".fzf#shellescape(<q-args>), fzf#vim#with_preview(), <bang>0)',
\'command! -bang -nargs=* RG call fzf#vim#grep2("rg --column --line-number --no-heading --color=always --smart-case -- ", <q-args>, fzf#vim#with_preview(), <bang>0)',
\'command! -bang -nargs=* Tags call fzf#vim#tags(<q-args>, fzf#vim#with_preview({ "placeholder": "--tag {2}:{-1}:{3..}" }), <bang>0)',
\'command! -bang -nargs=* BTags call fzf#vim#buffer_tags(<q-args>, fzf#vim#with_preview({ "placeholder": "{2}:{3..}" }), <bang>0)',
\'command! -bar -bang Snippets call fzf#vim#snippets(<bang>0)',
\'command! -bar -bang Commands call fzf#vim#commands(<bang>0)',
\'command! -bar -bang Jumps call fzf#vim#jumps(fzf#vim#with_preview({ "placeholder": "{2..4}"}), <bang>0)',
\'command! -bar -bang -nargs=* Marks call fzf#vim#marks(<q-args>, <bang>0)',
\'command! -bar -bang -nargs=* BMarks call fzf#vim#marks("abcdefghijklmnopqrstuvwxyz", <bang>0)',
\'command! -bar -bang Changes call fzf#vim#changes(<bang>0)',
\'command! -bar -bang Helptags call fzf#vim#helptags(fzf#vim#with_preview({ "placeholder": "--tag {2}:{3}:{4}" }), <bang>0)',
\'command! -bar -bang Windows call fzf#vim#windows(fzf#vim#with_preview({ "placeholder": "{2}" }), <bang>0)',
\'command! -bar -bang -nargs=* -range=% -complete=file Commits let b:fzf_winview = winsaveview() | <line1>,<line2>call fzf#vim#commits(<q-args>, fzf#vim#with_preview({ "placeholder": "" }), <bang>0)',
\'command! -bar -bang -nargs=* -range=% BCommits let b:fzf_winview = winsaveview() | <line1>,<line2>call fzf#vim#buffer_commits(<q-args>, fzf#vim#with_preview({ "placeholder": "" }), <bang>0)',
\'command! -bar -bang Maps call fzf#vim#maps("n", <bang>0)',
\'command! -bar -bang Filetypes call fzf#vim#filetypes(<bang>0)',
\'command! -bang -nargs=* History call s:history(<q-args>, fzf#vim#with_preview(), <bang>0)'])
function! s:history(arg, bang)
function! s:history(arg, extra, bang)
let bang = a:bang || a:arg[len(a:arg)-1] == '!'
if a:arg[0] == ':'
call fzf#vim#command_history(bang)
elseif a:arg[0] == '/'
call fzf#vim#search_history(bang)
else
call fzf#vim#history(bang)
call fzf#vim#history(a:extra, bang)
endif
endfunction
@@ -75,25 +93,25 @@ function! fzf#complete(...)
return call('fzf#vim#complete', a:000)
endfunction
if has('nvim') && get(g:, 'fzf_nvim_statusline', 1)
if (has('nvim') || has('terminal') && has('patch-8.0.995')) && (s:conf('statusline', 1) || s:conf('nvim_statusline', 1))
function! s:fzf_restore_colors()
if exists('#User#FzfStatusLine')
doautocmd User FzfStatusLine
else
if $TERM !~ "256color"
highlight fzf1 ctermfg=1 ctermbg=8 guifg=#E12672 guibg=#565656
highlight fzf2 ctermfg=2 ctermbg=8 guifg=#BCDDBD guibg=#565656
highlight fzf3 ctermfg=7 ctermbg=8 guifg=#D9D9D9 guibg=#565656
highlight default fzf1 ctermfg=1 ctermbg=8 guifg=#E12672 guibg=#565656
highlight default fzf2 ctermfg=2 ctermbg=8 guifg=#BCDDBD guibg=#565656
highlight default fzf3 ctermfg=7 ctermbg=8 guifg=#D9D9D9 guibg=#565656
else
highlight fzf1 ctermfg=161 ctermbg=238 guifg=#E12672 guibg=#565656
highlight fzf2 ctermfg=151 ctermbg=238 guifg=#BCDDBD guibg=#565656
highlight fzf3 ctermfg=252 ctermbg=238 guifg=#D9D9D9 guibg=#565656
highlight default fzf1 ctermfg=161 ctermbg=238 guifg=#E12672 guibg=#565656
highlight default fzf2 ctermfg=151 ctermbg=238 guifg=#BCDDBD guibg=#565656
highlight default fzf3 ctermfg=252 ctermbg=238 guifg=#D9D9D9 guibg=#565656
endif
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
endif
endfunction
function! s:fzf_nvim_term()
function! s:fzf_vim_term()
if get(w:, 'airline_active', 0)
let w:airline_disabled = 1
autocmd BufWinLeave <buffer> let w:airline_disabled = 0
@@ -106,11 +124,14 @@ if has('nvim') && get(g:, 'fzf_nvim_statusline', 1)
augroup _fzf_statusline
autocmd!
autocmd FileType fzf call s:fzf_nvim_term()
autocmd FileType fzf call s:fzf_vim_term()
augroup END
endif
let g:fzf#vim#buffers = {}
if !exists('g:fzf#vim#buffers')
let g:fzf#vim#buffers = {}
endif
augroup fzf_buffers
autocmd!
if exists('*reltimefloat')
@@ -122,9 +143,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()