junegunn / fzf.vim

fzf :heart: vim
MIT License
9.51k stars 581 forks source link

Regression/error when running :Tags #1521

Closed JonnyRa closed 5 months ago

JonnyRa commented 5 months ago

Hi!

I've been using fzf and fzf-vim for 5+ years. It's an excellent tool, thanks for making it :smile:

I recently did a :PlugUpdate for the first time in a long time (could be more than one year) and it seems like the :Tags function in fzf-vim is now broken - it doesn't appear to work for any of my tags no matter how I try and open the location (eg Enter vs Ctrl-x).

The error message I get is as follows:

Error detected while processing function 425[30]..<SNR>30_callback:                                                                                                                                                  
line   23:                                                                                                                                                                                                           
Vim(let):E119: Not enough arguments for function: bufnr 

I'm on version 0.45.0 (202401011) of fzf

I've skimmed the recommended bits of documentation but not sure the purpose would be in this case really.

Things like :Files and :Buffers are working fine.

I have the following in my .vimrc related to fzf but don't think it would be relevant as I've just been running :Tags as a command directly

"fuzzy find
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'

nnoremap <C-t> :Tags<cr> 
nnoremap <C-_> :execute "Tags ".expand('<cword>')<cr>
command! -bang -nargs=? -complete=dir HFiles
  \ call fzf#vim#files(<q-args>, {'source': 'ag -u --ignore .hg -g ""'}, <bang>0)
nnoremap <C-n> :Files<cr>
let g:fzf_action = {
  \ 'ctrl-t': 'tab split',
  \ 'ctrl-x': 'split',
  \ 'ctrl-v': 'vsplit',
  \ 'ctrl-p': 'pedit'}

Also I did the recommended to start vim with minimal config and it had the same problem, although I'm not sure exactly what that did and how isolated it was from my .vimrc/other stuff.

Tags are present and working with native vim functions such as <C-]>

JonnyRa commented 5 months ago

Also just had a check and I see the same problem in a different project/folder/vim instance, although both projects are haskell and using the same .vimrc and Tag generation (https://github.com/elaforge/fast-tags)

Please let me know if I can help in anyway. I tried to relate the error message to the code but line 23 of the plugin isn't a function and neither is 425 (the function name?)

I noticed that perl is mentioned in one of the readme's as a dependency for the tag stuff. It's on the path/installed and at the following version

This is perl 5, version 34, subversion 0 (v5.34.0) built for x86_64-linux-gnu-thread-multi
(with 60 registered patches, see perl -V for more detail)
JonnyRa commented 5 months ago

Done a bit more digging and the function in question seems to be

   function 452(id, code, ...) dict                                                                                                                                                                                  
        Last set from ~/.fzf/plugin/fzf.vim line 886                                                                                                                                                                 
1      if s:getpos() == self.ppos " {'window': 'enew'}                                                                                                                                                               
2        for [opt, val] in items(self.winopts)                                                                                                                                                                       
3          execute 'let' opt '=' val                                                                                                                                                                                 
4        endfor                                                                                                                                                                                                      
5        call self.switch_back(1)                                                                                                                                                                                    
6      else                                                                                                                                                                                                          
7        if bufnr('') == self.buf                                                                                                                                                                                    
8          " We use close instead of bd! since Vim does not close the split when                                                                                                                                     
9          " there's no other listed buffer (nvim +'set nobuflisted')                                                                                                                                                
10         close                                                                                                                                                                                                     
11       endif                                                                                                                                                                                                       
12       silent! execute 'tabnext' self.ppos.tab                                                                                                                                                                     
13       silent! execute self.ppos.win.'wincmd w'                                                                                                                                                                    
14     endif                                                                                                                                                                                                         
15                                                                                                                                                                                                                   
16     if bufexists(self.buf)                                                                                                                                                                                        
17       execute 'bd!' self.buf                                                                                                                                                                                      
18     endif                                                                                                                                                                                                         
19                                                                                                                                                                                                                   
20     if &lines == self.lines && &columns == self.columns && s:getpos() == self.ppos                                                                                                                                
21       execute self.winrest                                                                                                                                                                                        
22     endif                                                                                                                                                                                                         
23                                                                                                                                                                                                                   
24     let lines = s:collect(self.temps)                                                                                                                                                                             
25     if !s:exit_handler(a:code, self.command, 1)                                                                                                                                                                   
26       return                                                                                                                                                                                                      
27     endif                                                                                                                                                                                                         
28                                                                                                                                                                                                                   
29     call s:pushd(self.dict)                                                                                                                                                                                       
30     call s:callback(self.dict, lines)                                                                                                                                                                             
31     call self.switch_back(s:getpos() == self.ppos)                                                                                                                                                                
32                                                                                                                                                                                                                   
33     if &buftype == 'terminal'                                                                                                                                                                                     
34       call feedkeys(&filetype == 'fzf' ? "\<Plug>(fzf-insert)" : "\<Plug>(fzf-normal)")                                                                                                                           
35     endif                                                                                                                                                                                                         
   endfunction   

Line 23 doesn't fit with that really, it's a blank line in there but there is a call to bufnr in there. However calling bufnr via the commandline seems to work fine.

I'm wondering if it's something to do with this

2        for [opt, val] in items(self.winopts)                                                                                                                                                                       
3          execute 'let' opt '=' val                                                                                                                                                                                 
4        endfor                                                                                                                                                                                                      

since the error message mentions let.

Having said that I've tried searching for that code in your repo and it doesn't seem to show up - I was looking for one of the error message fragments "We use close instead of bd" and couldn't find it.
Also there are only 162 lines in the github version of fzf.vim whereas bizarrely looking at that file/line number on my local disk does show that function and the file has 1098 lines!! So somewhat baffled.

In that file it looks like we're in fzf.on_exit which is nested within execute_term, 23 lines down from the top of execute_term is the execute 'let' call so seems likely the error is from there. Again searching your repo for execute_term only yields a mention in a commit message from 2017, not any actual code https://github.com/junegunn/fzf.vim/commit/b0baf7593d9dbfca0759e3767281861647d53bff

I'm on a pretty old vim at this point which I just noticed has -perl in it's version info:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 11 2018 16:36:20)
Included patches: 1-567
Compiled by ...
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            +farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    -tcl
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
+balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
+browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          +toolbar
+cindent           +insert_expand     +path_extra        +user_commands
+clientserver      +job               -perl              +vartabs
+clipboard         +jumplist          +persistent_undo   +vertsplit
+cmdline_compl     +keymap            +postscript        +virtualedit
+cmdline_hist      +lambda            +printer           +visual
+cmdline_info      +langmap           +profile           +visualextra
+comments          +libcall           -python            +viminfo
+conceal           +linebreak         -python3           +vreplace
+cryptv            +lispindent        +quickfix          +wildignore
+cscope            +listcmds          +reltime           +wildmenu
+cursorbind        +localmap          +rightleft         +windows
+cursorshape       -lua               -ruby              +writebackup
+dialog_con_gui    +menu              +scrollbind        +X11
+diff              +mksession         +signs             -xfontset
+digraphs          +modify_fname      +smartindent       +xim
+dnd               +mouse             +startuptime       -xpm
-ebcdic            +mouseshape        +statusline        +xsmp_interact
+emacs_tags        +mouse_dec         -sun_workshop      +xterm_clipboard
+eval              -mouse_gpm         +syntax            -xterm_save
+ex_extra          -mouse_jsbterm     +tag_binary        

Is this relevant?

JonnyRa commented 5 months ago

Have just built myself a new version of vim and the plugin now works again :tada:

SKOHscripts commented 4 months ago

Hi, I just got the same issue with :Tags. Except I have +perl in my vim version (quite old too, but can’t build a new version). What could you recommend ? Thx for your help

JonnyRa commented 4 months ago

Compiling vim is relatively easy, IIRC you basically just git pull and then run a couple of make commands.

If you can't do that though it's probably worth trying to source a new version another way. I think I originally went for a custom compiled one (in 2018!) because I wanted to get vim 8 which wasn't available from apt at the time (I'm on ubuntu) and/or I wanted to turn on a particular feature. So I'd try get an update from your system packages as a first port of call. I'm not actually sure how/where to get a precompiled one apart from that, looking at the vim website https://www.vim.org/download.php they only seem to offer precompiled stuff for windows which I think was why I went for compiling from source this time since they give you instructions for how to do that.

I don't know if -perl was actually relevant but probably worth dumping/diffing your vim --version output with what you get after updating to check that you still have features you actually need...

SKOHscripts commented 3 months ago

I think there is something else… It used to work, I have probably missed something. The error is :

Error detected while processing function 429[30]..<SNR>56_callback:                                                                                                                                                  
line   23:                                                                                                                                                                                                           
Vim(let):E119: Not enough arguments for function: bufnr 

and vim --version returns :

VIM - Vi IMproved 8.1 (2018 May 18, compilé Sep 27 2023 19:47:00)
Rustines incluses : 1-875, 878, 881, 883-884, 936, 948, 1046, 1365-1368, 1382, 1401, 4120, 4151-4152, 4214, 4218, 4397, 4428, 4899, 4919, 4921, 4977, 5023-5024, 805, 5043, 5063, 5126, 1858, 1873
Rustines extra : 8.2.3402, 8.2.3403, 8.2.3409, 8.2.3428, 9.0.0490, 9.0.0530, 9.0.0614
Modifié par team+vim@tracker.debian.org
Compilé par team+vim@tracker.debian.org
Énorme version avec interface graphique GTK3.
  Fonctionnalités incluses (+) ou non (-) :
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            +farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    +tcl
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
+balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
+browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +textprop
+byte_offset       -hangul_input      +num64             +timers
+channel           +iconv             +packages          +title
+cindent           +insert_expand     +path_extra        +toolbar
+clientserver      +job               +perl              +user_commands
+clipboard         +jumplist          +persistent_undo   +vartabs
+cmdline_compl     +keymap            +postscript        +vertsplit
+cmdline_hist      +lambda            +printer           +virtualedit
+cmdline_info      +langmap           +profile           +visual
+comments          +libcall           -python            +visualextra
+conceal           +linebreak         +python3           +viminfo
+cryptv            +lispindent        +quickfix          +vreplace
+cscope            +listcmds          +reltime           +wildignore
+cursorbind        +localmap          +rightleft         +wildmenu
+cursorshape       +lua               +ruby              +windows
+dialog_con_gui    +menu              +scrollbind        +writebackup
+diff              +mksession         +signs             +X11
+digraphs          +modify_fname      +smartindent       -xfontset
+dnd               +mouse             +startuptime       +xim
-ebcdic            +mouseshape        +statusline        +xpm
+emacs_tags        +mouse_dec         -sun_workshop      +xsmp_interact
+eval              +mouse_gpm         +syntax            +xterm_clipboard
+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save

@junegunn I don’t really know could be the problem. I haven’t changed my vim version and it used to work. :Tags correcly shows tags, but selection is broken. @JonnyRa I tried to build vim, but I haven’t root access and it seems to imply a lot of disfunction (.local/share/vim files can’t be found).

JonnyRa commented 3 months ago

Looks very similar symptoms to me and your vim is > 5 years old. I think the cause must be issue with versioning between the plugin and vim - perhaps the plugin now calls a function in a way that didn't exist in older vims.

I think there are basically 2 options - either get a newer vim or get an older version of the plugin

Newer vim:

Older plugin:

Not sure I can help with any further specifics, you'll have to google things. I suspect going for a newer vim would be the way to go and which way you do it probably depends how useful/available the sys admin is! Good luck!

SKOHscripts commented 3 months ago

I was a little suspicious that my version of vim was too old, but I'm not going to be able to do much on it, my environment is forcing it on me at the moment.

For an older version of the plugin, it might be an idea. I could try to do some archaeology to find out which commit made the fatal change.

Anyway, thanks for your help and your great response.

junegunn commented 3 months ago

I believe https://github.com/junegunn/fzf.vim/commit/45d96c9cb1213204479593236dfabf911ff15443 should fix the problem. Please update and test it.