LeaderF icon indicating copy to clipboard operation
LeaderF copied to clipboard

cannot scroll the preview window in vim, but it works on nvim

Open benzwt opened this issue 3 years ago • 3 comments

  • vim or neovim?
    • [x] vim
    • [ ] neovim
  • Output of vim --version or nvim --version:
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Aug 03 2022 08:47:08)
Included patches: 1-135
Modified by [email protected]
Compiled by [email protected]
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       +tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
+balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
+browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl              +title
+channel           +ipv6              +persistent_undo   +toolbar
+cindent           +job               +popupwin          +user_commands
+clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby              +wildignore
+cursorbind        +lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con_gui    +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            +X11
+digraphs          +mouse             +sound             -xfontset
+dnd               +mouseshape        +spell             +xim
-ebcdic            +mouse_dec         +startuptime       +xpm
+emacs_tags        +mouse_gpm         +statusline        +xsmp_interact
+eval              -mouse_jsbterm     -sun_workshop      +xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
-farsi             -mouse_sysmouse    -tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/x86_64-linux-gnu -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time -g -O2 -ffile-prefix-map=/build/vim-Z9iOBu/vim-9.0.0105+really.v9.0.0135=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lselinux -lcanberra -lsodium -lacl -lattr -lgpm -L/usr/lib -llua5.2 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.34/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.10/config-3.10-x86_64-linux-gnu -lpython3.10 -lcrypt -ldl -lm -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-3.0 -lm -L/usr/lib
  • Output of :echo has("python"):
0
  • Output of :echo has("python3"):
1
  • Output of :echo &pythondll(only vim, not neovim):
not available
  • Output of :echo &pythonthreedll(only vim, not neovim):
not available
  • Output of :py print(sys.version):
not available
  • Output of :py3 print(sys.version):
3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]
  • Output of :echo g:Lf_Debug_Cmd:
  • Output of :echo g:Lf_FilesFromCache:
  • Operating system:
    • [x] Linux
    • [ ] Mac OS X
    • [ ] Windows
    • [ ] Etc.
  • Configurations related to LeaderF in vimrc:
let g:Lf_StlColorscheme = 'powerline'
let g:Lf_ShowDevIcons = 1
" For GUI vim, the icon font can be specify like this, for example
let g:Lf_DevIconsFont = "DroidSansMono Nerd Font Mono"
" If needs
set ambiwidth=double


let g:Lf_Ctags='/usr/bin/ctags-universal'
let g:Lf_GtagsAutoGenerate = 0
let g:Lf_GtagsGutentags = 1
let g:Lf_CacheDirectory = expand('~') 
let g:Lf_RootMarkers = ['.git', '.svn', '.hg', '.project', '.root']
let g:Lf_WildIgnore = {
		\ 'dir': ['.svn','.git','.hg'],
		\ 'file': ['*.sw?','~$*','*.bak','*.exe','*.o','*.so','*.py[co]']
		\}
" don't show the help in normal mode
let g:Lf_HideHelp = 1
let g:Lf_UseCache = 0
let g:Lf_UseVersionControlTool = 1
let g:Lf_IgnoreCurrentBufferName = 1
" popup mode
let g:Lf_WindowPosition = 'popup'
" let g:Lf_PreviewHorizontalPosition = 'left'
" let g:Lf_PopupPreviewPosition = 'right'
let g:Lf_PreviewInPopup = 1
let g:Lf_PopupWidth = 0.75
let g:Lf_StlSeparator = { 'left': "\ue0b0", 'right': "\ue0b2", 'font': "DejaVu Sans Mono for Powerline" }
let g:Lf_PreviewResult = {
		\ 'File': 0,
		\ 'Buffer': 0,
		\ 'Mru': 0,
		\ 'Tag': 0,
		\ 'BufTag': 0,
		\ 'Function': 1,
		\ 'Line': 0,
		\ 'Colorscheme': 0,
		\ 'Rg': 0,
		\ 'Gtags': 0
		\}
" let g:Lf_PreviewHorizontalPosition = 'right'
" let g:Lf_ShortcutF = "<leader>ff"

" noremap <leader>ff :Leaderf file
noremap <leader>ff :Leaderf function<CR>
noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>
noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>
noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>

noremap <leader>frr :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR>
noremap <leader>frf :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR>
" search visually selected text literally
xnoremap gf :<C-U><C-R>=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual())<CR>
noremap go :<C-U>Leaderf! rg --recall<CR>

let g:Lf_Gtagslabel = 'native-pygments'
" nmap <unique> <leader>fgd <Plug>LeaderfGtagsDefinition
" nmap <unique> <leader>fgr <Plug>LeaderfGtagsReference
" nmap <unique> <leader>sss <Plug>LeaderfGtagsSymbol
" nmap <unique> <leader>fgg <Plug>LeaderfGtagsGrep

" vmap <unique> <leader>fgd <Plug>LeaderfGtagsDefinition
" vmap <unique> <leader>fgr <Plug>LeaderfGtagsReference
" vmap <unique> <leader>fgs <Plug>LeaderfGtagsSymbol
" vmap <unique> <leader>fg <Plug>LeaderfGtagsGrep

noremap <leader>tv :LeaderfBufTag<CR>
" noremap <leader>fr :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR>
" noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR>
noremap <leader>fr :<C-U><C-R>=printf("Leaderf! gtags -r %s", expand("<cword>"))<CR><CR>
noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s", expand("<cword>"))<CR><CR>
noremap <leader>fo :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR>
noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR>
noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>

command LfLine LeaderfLine
command LfSelf LeaderfSelf
command LfFile LeaderfFile
command LfRg LeaderfRg
command LfBuf LeaderfBuffer
command LfBTag LeaderfBufTag

Describe your question, feature request, or bug.

cannot scroll the preview window in vim by pressing <C-Up> or <C-Down>, but it works on nvim

Steps to reproduce

1. trigger file list

:LeaderfFile

2. select a file,  and press <C-p> to preview
3. pressing <C-Up> or <C-Down>

Actual behaviour

the whole popup (filelist and preview) vanishes

Expected behaviour

I should be able to scroll the preview popup by pressing <C-Up> or <C-Down>

benzwt avatar Aug 06 '22 13:08 benzwt

Can not reproduce.

Yggdroot avatar Aug 08 '22 06:08 Yggdroot

Can not reproduce.

I use tmux. I fixed this issue by referring this link.

Several terminal emulators (alacritty, gnome, konsole, etc.) send special
codes for keys with modifiers, but these do not have an entry in the
termcap/terminfo database.  You can make them work by adding a few lines in
your vimrc.  For example, to make the Control modifier work with arrow keys
for the gnome terminal: >
	if &term =~ 'gnome'
	   execute "set <xUp>=\<Esc>[@;*A"
	   execute "set <xDown>=\<Esc>[@;*B"
	   execute "set <xRight>=\<Esc>[@;*C"
	   execute "set <xLeft>=\<Esc>[@;*D"
	endif

thanks!

benzwt avatar Aug 08 '22 07:08 benzwt

Great.

Yggdroot avatar Aug 08 '22 07:08 Yggdroot

Hi, @Yggdroot 我可以复现这个问题, 在此过程中我修改了Lf_CommandMap 我的vim版本是vim9.0, 是否使用tmux均会有此问题

:version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Jun  6 2023 10:02:51)
Included patches: 1-1613
Compiled by hongjiew@hongjiew-Host-Machine
Huge version without GUI.  Features included (+) or not (-):
+acl               +byte_offset       +conceal           -ebcdic            +folding           +jumplist          -lua               +mouse_netterm     +num64             -python            -sodium            -tag_any_white     +title             +visualextra       -xpm
+arabic            +channel           +cryptv            +emacs_tags        -footer            +keymap            +menu              +mouse_sgr         +packages          +python3           -sound             -tcl               -toolbar           +vreplace          -xsmp
+autocmd           +cindent           +cscope            +eval              +fork()            +lambda            +mksession         -mouse_sysmouse    +path_extra        +quickfix          +spell             +termguicolors     +user_commands     +wildignore        -xterm_clipboard
+autochdir         -clientserver      +cursorbind        +ex_extra          +gettext           +langmap           +modify_fname      +mouse_urxvt       -perl              +reltime           +startuptime       +terminal          +vartabs           +wildmenu          -xterm_save
-autoservername    -clipboard         +cursorshape       +extra_search      -hangul_input      +libcall           +mouse             +mouse_xterm       +persistent_undo   +rightleft         +statusline        +terminfo          +vertsplit         +windows
-balloon_eval      +cmdline_compl     +dialog_con        -farsi             +iconv             +linebreak         -mouseshape        +multi_byte        +popupwin          -ruby              -sun_workshop      +termresponse      +vim9script        +writebackup
+balloon_eval_term +cmdline_hist      +diff              +file_in_path      +insert_expand     +lispindent        +mouse_dec         +multi_lang        +postscript        +scrollbind        +syntax            +textobjects       +viminfo           -X11
-browse            +cmdline_info      +digraphs          +find_in_path      +ipv6              +listcmds          -mouse_gpm         -mzscheme          +printer           +signs             +tag_binary        +textprop          +virtualedit       -xfontset
++builtin_terms    +comments          -dnd               +float             +job               +localmap          -mouse_jsbterm     +netbeans_intg     +profile           +smartindent       -tag_old_static    +timers            +visual            -xim
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lm -ltinfo -lrt -ldl -L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu/ -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -lm
Press ENTER or type command to continue

复现步骤:

  1. lf open file list
  2. tab后选择较长的文件, 按p打开preview
  3. 通过<C-J>或者<C-K>在preview窗口中移动光标
  4. 期望光标可以在preview中移动 结果: commit 27bd938a422fc6fcfc453fa88fe2ad453a012074 无法在preview中通过<C-J>移动光标 commit 86013dd6208609e51c722e91e8faa6c4597ed83a 可以通过<C-J>移动光标

特殊改动: let g:Lf_CommandMap = { \ '<C-R>': ['<C-E>'], \ '<C-F>': ['<C-D>'], \ '<C-Up>': ['<C-K>'], \ '<C-Down>': ['<C-J>'], \ }

下面是可以用来复现的vimrc的配置


set nocompatible


let mapleader = ' '
let g:mapleader = ' '

set encoding=utf-8  " must set this value to support chinese work in vimrc

let $MYVIMRC=fnamemodify(expand('<sfile>'), ':p')
let $VIMFILES=fnamemodify(expand('<sfile>'), ':p:h')
set runtimepath+=$VIMFILES

call plug#begin()
    Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
call plug#end()

" 替换leaderf 插件中默认的键
let g:Lf_CommandMap = {
\   '<C-R>': ['<C-E>'],
\   '<C-F>': ['<C-D>'],
\   '<C-Up>': ['<C-K>'],
\   '<C-Down>': ['<C-J>'],
\ }


let g:Lf_PopupPosition = [2 , 0] " popup 窗口位置屏幕中间偏上
let g:Lf_PreviewInPopup = 1 " 是否在popup中preview
let g:Lf_PopupPreviewPosition = 'bottom'
let g:Lf_WindowPosition = 'popup'
let g:Lf_ShortcutF = "<leader>lf"

irreallich avatar Aug 04 '23 10:08 irreallich