Iron-E / nvim-libmodal

Create new "modes" for Neovim!
Other
118 stars 7 forks source link

"Error while calling lua chunk for luaeval()... Undefined variable: _instruction" #8

Closed chardskarth closed 4 years ago

chardskarth commented 4 years ago

Awesome work @Iron-E! But it'd be best if I can make this work.

image

Iron-E commented 4 years ago

Thanks for the report!

It seems like nvim-libmodal is installed, which is only for Neovim. The function in the error comes from this file on that other repo.

These two plugins (vim-libmodal and nvim-libmodal) are somewhat cross-compatable but can't be installed at the same time. Can you confirm the following for me? It will help in debugging this issue:

Thanks!

chardskarth commented 4 years ago

Neovim: 0.4.3 nvim-libmodal: dee1f0f

vim-libmodal: e842912 works somehow. Awesome work! I'm very thankful for your library.


Edit: Sorry I dont know how to get the version. I cded to the plugins directory and simply did a glol

chardskarth commented 4 years ago

I dont have vim-libmodal installed. Here's my neovim autoload folder:

image

Iron-E commented 4 years ago

I transferred this issue to this repo since you're using nvim-libmodal.

Thanks for the clear version statements, that really helps :+1:

As for the issue, I see this:

command! WindowMode call libmodal#Enter('Window', funcref('s:WindowMode'))

The lua-vim interface doesn't like to process funcrefs. You can read more about that here, but in short:

So the command would look like this:

command! WindowMode call libmodal#Enter('Window', 's:WindowMode')

Thought it won't work without 0.5.

The reason it works with vim-libmodal is that it is written entirely in Vimscript, so it never has to cross that barrier from Lua to Vim (and thus never has to deal with resolving the funcref()).

You can test this solution out by downloading Neovim 0.5 and replacing the command with the one I provided.

Let me know if it works!


Edit: Another way to get around this would be to write your mode in Lua. This approach doesn't require Neovim 0.5

Start by defining a module:

-- yourproject/lua/window_mode.lua
local libmodal = require('libmodal')

local function WindowMode()
    -- logic goes here
end

return function() 
    libmodal.mode.enter('Window', WindowMode) 
end

Then define the Vimscript bindings:

command! WindowMode lua require('window_mode')()

Both approaches will work.

chardskarth commented 4 years ago

I'll have to make do with using vim-libmodal for now. Thank you very much. Closing this issue now.

PS I can't thank you enough for this plugin. This really helped me in my workflow!

Iron-E commented 4 years ago

Happy to help! I posted another solution that doesn't require 0.5, which you can take a look at.

In the meantime, feel free to open any additional tickets as necessary :+1: