ChHaeni / vimtux

Send commands from Vim to Tmux
MIT License
1 stars 0 forks source link

getting 'undefined variable: g:loaded_fzf_vim' #1

Closed emilBeBri closed 10 months ago

emilBeBri commented 1 year ago

Hi So i'm using neovim w. lazy as plugin manager, currently using vim-slime but this seems much more like what I need.

However I get this error:


Error detected while processing function <SNR>25_SendToTmuxMotion[10]..SendToTmux[9]..<SNR>25_TmuxVars:
line    6:
E121: Undefined variable: g:loaded_fzf_vim

In my config I have this:


return {
-- send code from python/r/qmd docuemts to a terminal
  -- like ipython, R, bash
    { 'jpalardy/vim-slime' },
    { 'ChHaeni/vimtux' },

}

and then in a separe lua file for keymaps I have this:

vim.cmd[[

" choose pane visually
if has('nvim')
    let g:vimtux_fzf = 1
else
    let g:vimtux_popup = 1
endif

" motion mapping (r because I'm mostly using vimtux for R scripting)
" now I can send text by using motion commands, e.g. <leader>rap, etc.
" these commands are repeatable using .
nmap <silent> <leader>r <Plug>NormalModeSendToTmuxMotion
" check currently selected pane
nmap <leader>S <Plug>CheckTmux

nmap <Space>T <Plug>SetTmuxVars

]]

as you can see I also put in SetTmuxVars (this is a random attempt) because it seems like it does not know which tmux pane to send to. this gives me this:

Error detected while processing function <SNR>18_TmuxVars:
line    6:
E121: Undefined variable: g:loaded_fzf_vim

Not really sure how to proceed from here. It could seem like the plugin hasn’t been loaded, and perhaps that is because I'm using lazy as my plugin manager. According to (this)[https://www.reddit.com/r/neovim/comments/11pf1z7/vimscript_plugins_config_loading_in_lazynvim/], I tried to force loading vimtux by doing this:

return{

{'ChHaeni/vimtux',     
lazy = false,    
init = function()         
vim.cmd([[ let g:vimtux_fzf = 1 ]])         
end, 
},
}

To no avail.

Any idea what's going on here? I also put the suggested content of the tmux config to my tmux config file.

using neovim 0.9.xxx on manjaro linux, fully updated.

ChHaeni commented 11 months ago

Hi, I'm really sorry for the late response. Somehow I didn't get an issue notification by mail (have to double-check this)...

I'm not familiar with lazy, but g:loaded_fzf_vim is from the plugin fzf and I assume you have to force lazy to load fzf instead...

And thanks for reporting! I'm going to make sure that there will be a better notification/error message if the fzf plugin is not availble (as soon as I'll find the time) & I guess the readme should be improved & also link to the fzf plugin...

So far I thought I'm the only one using this plugin ^^

Let me know if force-loading the fzf plugin is helping...

ChHaeni commented 11 months ago

as you can see I also put in SetTmuxVars (this is a random attempt) because it seems like it does not know which tmux pane to send to.

The plugin should ask you for the session/window/pane if the pane has not yet been specified, however, there are occasions where you want to reset it again or set it beforehand, so a mapping is definitely helpful.

emilBeBri commented 11 months ago

Hi, no problem - thanks for answering!

I hope I'm not the only one, because this thing is exactly what I was looking for, and I hope it'll stay active for years to come!

I think I'm getting closer - when running the primary plugin command:


<Plug>NormalModeSendToTmuxMotion

it actually does send the motion to the last-opened tmux pane. so I guess it's using the dynamic identifier to send the code. If I open another tmux instance, in another terminal for example, it uses that the next time.

however, while sending the motion to the pane it also gives me these error messages:

Error detected while processing function <SNR>40_SendToTmuxMotion[10]..SendToTmux[12]..<SNR>40_SendToTmuxH
elper[3]..<SNR>40_TmuxTarget:
line    1:
E716: Key not present in Dictionary: "pane"
Press ENTER or type command to continue
Error detected while processing function <SNR>40_SendToTmuxMotion[10]..SendToTmux[12]..<SNR>40_SendToTmuxH
elper[3]..<SNR>40_TmuxTarget:
line    1:
E116: Invalid arguments for function len
Press ENTER or type command to continue
Error detected while processing function <SNR>40_SendToTmuxMotion[10]..SendToTmux[12]..<SNR>40_SendToTmuxH
elper[6]..ExecuteKeys[12]..<SNR>40_TmuxTarget:
line    1:
E716: Key not present in Dictionary: "pane"
Press ENTER or type command to continue
Error detected while processing function <SNR>40_SendToTmuxMotion[10]..SendToTmux[12]..<SNR>40_SendToTmuxH
elper[6]..ExecuteKeys[12]..<SNR>40_TmuxTarget:
line    1:
E116: Invalid arguments for function len

sometimes it does send to the pane - sometimes not. If I pkill tmux, and restart nvim, it seems to start over and be able to send to the new '0' pane.

When I run CheckTmux I get:

'no tmux pane defined'

even though it actually does send the code a panel.

using SetTmuxVars gives me:


Error detected while processing function <SNR>25_TmuxVars[7]..<SNR>25_T
muxVarsFZF:
line    5:
E117: Unknown function: fzf#run
Press ENTER or type command to continue

and that is even though I have set fzf to non-lazy load (makes no difference it seems):


    { 'junegunn/fzf.vim', 
lazy = false,    
init = function()         
vim.cmd([[ let g:vimtux_fzf = 1 ]])         
end, 
},
emilBeBri commented 11 months ago

sorry for the not that vigorous testing - I can't seem to find a pattern to test for, so to speak.

ChHaeni commented 11 months ago

I hope I'll find the time to look into this on the weekend!

emilBeBri commented 11 months ago

Cool thank you - but please don't stress about it ! :) it can wait

ChHaeni commented 11 months ago

So I've checked on my OpenSUSE VM with a fresh install of neovim 0.9.1 and first time lazy plugin manager (quite nice I must say!).

I struggled to get fzf to run until I realized that I need to actually install two plugins for fzf to work with Vim (I forgot about this). Once I installed both 'junegunn/fzf' (I ran :call fzf#install() after the installation, although I'm not sure if this is really necessary) and 'junegunn/fzf.vim' I had no issues with vimtux/fzf.

Can you confirm that you have both plugins installed but the issue remains?

emilBeBri commented 10 months ago

YES that did it! Sorry for the delay had alot of stuff going on around me.

Thank you, I hadn't thought of that at all. What a subtle little thing!

PS Yes lazy is very nice! I started using nvim just about a year ago when it was already kinda clear that it would be the best choice when starting from scratch :)

PPS could you enable 'discussions' on this repo? I have some thoughts on how utilize this operator in a keymap that I was thinking could be nice for others to use as inspiration - and perhaps as a sort of brainstorming about how to use it!

ChHaeni commented 10 months ago

Glad we solved it!

I'll enable the discussions in this repo, good idea!