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

g:fzf_preview_preview_key_bindings not working #174

Closed
phongvcao opened this issue Aug 28, 2020 · 9 comments
Closed

g:fzf_preview_preview_key_bindings not working #174

phongvcao opened this issue Aug 28, 2020 · 9 comments

Comments

@phongvcao
Copy link

phongvcao commented Aug 28, 2020

Problems summary

g:fzf_preview_preview_key_bindings not working. The keybindings weren't helping me scrolling in the preview buffer of fzf-preview.vim. My same keybindings worked fine using original FZF's default preview mode.

Environment Information

  • fzf-preview version (package.json): 0.4.9

  • OS: macOS Catalina 10.15.5 19F101 x86_64

  • Vim/Neovim version:

$ nvim --version
NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/build/config -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/src -I/usr/local/include -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/deps-build/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/build/src/nvim/auto -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/build/include
Compiled by brew@Catalina.local

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.4.3/share/nvim"

Run :checkhealth for more info

Provide a minimal init.vim

call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'ryanoasis/vim-devicons'
call plug#end()

let g:coc_global_extensions = ['coc-fzf-preview']
let g:fzf_preview_preview_key_bindings = 'ctrl-k:preview-up,ctrl-j:preview-down,?:toggle-preview'
@yuki-yano
Copy link
Owner

It certainly doesn't seem to be working.
I've checked and it looks like it's going to take a little bit of work to fix, so could you please wait a bit?

@phongvcao
Copy link
Author

yes I can wait.

@yuki-yano
Copy link
Owner

I was able to fix it sooner than expected.
Fixed: 0eba9be

Please check.

@phongvcao
Copy link
Author

so when I set my vimrc like this:

call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'ryanoasis/vim-devicons'
call plug#end()

let g:coc_global_extensions = ['coc-fzf-preview']
let g:fzf_preview_preview_key_bindings = 'ctrl-k:preview-up,ctrl-j:preview-down,?:toggle-preview'

then Ctrl-J works, but Ctrl-K doesn't work for some reasons (it does scroll up, but it only scrolls up for like 5-10 lines before the current line, not scrolling up for forever. In contrast, Ctrl-J can literally scroll down very far.

@phongvcao
Copy link
Author

phongvcao commented Sep 5, 2020

Ok so you can try my config, and then do this:

  1. Open :CocCommand fzf-preview.Lines
  2. Type some search term in the search prompt
  3. Try scrolling down using <C-j> (should work - you can literally scroll down as far as you want)
  4. Try scrolling up using <C-k> (you can only scroll up to a certain point - say 5-10 lines above the search-result line, but not more, where as original FZF can scroll up till first line of file).

The ability to scroll up till the first line is important, as most functions in my code are longer than 5-10 lines. Hence it would be great if the codes 20-30 lines above the searched result line can be seen.

To illustrate my point, this is what I did & how far I can scroll up (only 5-10 lines above the search result line and the scroll stops):

Screenshot at Sep 05 14-17-06

@yuki-yano
Copy link
Owner

The fzf preview cannot show the result of scrolling.
Therefore, grep results are displayed by cropping the file to show the matches first.

You can change grep's preview script to show the entire file, but it will start at the beginning of the file.

@phongvcao
Copy link
Author

You can change grep's preview script to show the entire file, but it will start at the beginning of the file.

How exactly do I do this? Is there a way I can specify this via an option (e.g. g:fzf_preview_*?). Is it possible to have an option that center the matched result line in the preview screen, or let users customize how many lines above the matched result line?

@yuki-yano
Copy link
Owner

You can set it up with g:fzf_preview_grep_preview_cmd .
The default script is https://github.com/yuki-ycino/fzf-preview.vim/blob/master/bin/preview_fzf_grep

@phongvcao
Copy link
Author

ok thanks Yuki I'll look into it.

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