Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: let preview command highlight line #1489

Closed
nkh opened this issue Jul 16, 2023 · 3 comments
Closed

Feature Request: let preview command highlight line #1489

nkh opened this issue Jul 16, 2023 · 3 comments

Comments

@nkh
Copy link

nkh commented Jul 16, 2023

I've set FZF_PREVIEW_COMMAND, which is used in fzf.vim/bin/tagpreview.sh.

tagpreview.sh highlights a line by reversing it which has the unfortunate effect of making it look like kitchy Christmas tree.

screenshot_2023-07-17_01-10-08

Fzf --preview gets more information, the line, the size of the window, ... Those could be used in the external viewer highlight the line and the match. In my case it would also allow the preview command to render just the part needed in the preview (since there's no possibility to scroll in the preview window, right?)

@junegunn
Copy link
Owner

Why don't you unset FZF_PREVIEW_COMMAND, install bat, and let the script uses it? I'll look better because it uses --highlight-line option of bat instead of reversing the colors of the line.

since there's no possibility to scroll in the preview window, right?

FYI, unlike tagpreview.sh, preview.sh feeds the entire file to fzf, properly setting the scroll offset using +N expression, so you can scroll upwards and downwards.

\ '--delimiter', ':', '--preview-window', '+{2}-/2']

(Used in :Rg, and the likes)

@nkh
Copy link
Author

nkh commented Jul 17, 2023

I have bat installed, and that's a good default, but I prefer to use my own which uses vim so I get a consistent preview.

I will use $CENTER to highlight the line, but the the AWK code would still reverse it.

So far I've modified preview.sh, to replace $REVERSE with a simple ">>" tag, but I'd prefer not to modify it.

Is the pane size set somewhere? If the line to be shown is at the top of the file, not rendering 2000 lines but just the necessary lines is faster. I'm considering adding a cache the preview are not re-rendered at all.

I don't see any bindings to scroll the preview window in the documentation, did I miss it?

@junegunn
Copy link
Owner

junegunn commented Jul 23, 2023

Is the pane size set somewhere?

$FZF_PREVIEW_LINES. Please refer to the man page for more info.

I don't see any bindings to scroll the preview window in the documentation, did I miss it?

Using your mouse. By scrolling over the area or dragging the area.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants