Commit Graph
46 Commits
Author SHA1 Message Date
Junegunn Choi 5ad2fa7bed Show no preview when the address does not reach Vim
Ex mode starts on the last line, so an empty $FZFVIM_EXCMD centered the preview
at the end of the file and said nothing. Quit with an error instead, which the
existing '|| exit' turns into a blank preview.
2026-09-28 01:29:03 +09:00
Junegunn Choi 777e783382 Name the preview variable in WSLENV
WSL shares only the variables listed there with a Windows vim.exe, as
s:preview_cmd already does for MSWINHOME. Untested, no WSL here.
2026-09-28 00:49:38 +09:00
Junegunn Choi 81ae642d5b Keep the whole tag address inside the preview sandbox
':sandbox' is a modifier and covers only the command up to the first '|', so an
address like '/pat/|!touch file' still ran the shell command as soon as an entry
was highlighted. ':execute' on a value taken from the environment keeps all of
it inside the sandbox, and takes the address out of the '-c' string as well.

:Helptags previews a plugin's doc/tags through the same script.
2026-09-28 00:08:49 +09:00
Junegunn Choi 9705771895 Run the tag address in a sandbox in the preview too
A preview runs as soon as an entry is highlighted, so a crafted tags file did
not even need to be selected to get a shell command out of
'vim -c "silent {excmd}"'.

The preview Vim starts with '-u NONE' and exits right after, so the sandbox
alone is enough there; nothing it still permits outlives the process.
2026-09-27 23:20:27 +09:00
Max Coplan 3ed6ac56d0 feat(preview): teach preview.sh to print directories (#1590) 2025-05-24 19:00:23 +09:00
Junegunn Choi 6f28c8c7bb [Tags] Fix preview on Vim 9.1
Fix #1555
2024-08-01 15:20:41 +09:00
zzmandJunegunn Choi 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 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 d91dd754a9 [preview.sh] Fix handling of backslashes in paths on Windows 2024-05-14 09:34:55 +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 2c501dc5a2 [Windows] Add preview
Close #1487
2023-09-06 18:26:23 +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
peelz 0452b71830 Fix preview failing on files with special characters (#1337) 2021-10-10 21:55:15 +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
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
GrueslayerandJan Stocker 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
Ingo Meyer 36de5db9f0 [Tagpreview] Handle absolute file paths correctly (#1229)
Fix #1228
2021-01-20 20:34:56 +09:00
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
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 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
RichardNee 2bf85d25e2 Fix preview.sh not running when the file path contains "binary" (#1055) 2020-06-21 17:54: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
uzxmx 48a2d80a24 [fzf#vim#preview] Respect $BAT_STYLE (#953) 2020-02-19 12:16:32 +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 76669c3c1d Deprecate preview.rb 2019-12-22 18:11:18 +09:00
Junegunn Choi 206ec5efe9 Use --line-range and --highlight-line options of bat 2019-12-17 14:19:59 +09:00
ptzz bce6588d24 Fix preview of paths starting with ~/ (#892) 2019-11-01 10:31:41 +09:00
Miguel Madrid Mencía 9b50e2fd5f Fix preview of symbolic links (#739) 2019-02-21 10:42:10 +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 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 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
Jan Edmund Lazo b51382fe9e [fzf#vim#preview] Use ruby in Windows if available (#471)
Close #459
2017-10-22 22:50:12 +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 d99169da2d Use FZF_PREVIEW_HEIGHT if available. Requires fzf 0.16.7.
Close #361
2017-04-30 12:06:41 +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 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 f54ec7caf1 Do not preview binary files 2017-01-23 10:28:08 +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 9ce2c2179f Add fzf#vim#with_preview function for previewing search result
Close #225
2016-11-26 14:11:27 +09:00