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

Issue when trying to use the api example open_window() command. #101

Open
MostHated opened this issue Mar 4, 2023 · 5 comments
Open

Issue when trying to use the api example open_window() command. #101

MostHated opened this issue Mar 4, 2023 · 5 comments

Comments

@MostHated
Copy link

MostHated commented Mar 4, 2023

Hey there,
I am having issues with the API examples (api.open_window() command). I came across a testing script in another thread and gave it a try to see if it was just me that was doing something wrong or not.
I ran the script and ended up with the same issue as my original plugin: E5108: Error executing lua Value of type () couldn't be pushed on the stack: "non-float cannot have \'row\'"..
When I ran the tests that were included in ths repo (using nightly nvim), all the window ones passed, which threw me off a bit.

Doing some searching on the issue, it seems like it may have something to do with setting row/column and then having to set the window relative setting again after that? Unfortunately, I don't know enough about the nvim backend yet to try and do much more diagnostic, myself, outside of doing something silly:

I didn't expect much from this, but figured it might be worth a shot, lol.

let config = WindowConfig::builder()
     .relative(WindowRelativeTo::Editor)
     .width(10)
     .row(3)
     .col(3)
     .relative(WindowRelativeTo::Editor)
     .build();

Upon running the script, it looks like there might be another issue with the mlua example that I had not noticed, but wanted to still report it.

_ ✗  ./examples.sh
=== example: api ===
Hello from Rust
Error detected while processing command line:
E5108: Error executing lua Value of type () couldn\'t be pushed on the stack: "non-float cannot have \'row\'"
stack traceback:
        [C]: in function 'open_window'
        [string ":lua"]:7: in main chunk
hello
=== example: mlua ===
Hello from nvim-oxi..
..and goodbye from mlua!
Error detected while processing command line:
E5108: Error executing lua [string ":lua"]:1: attempt to index a boolean value
stack traceback:
        [string ":lua"]:1: in main chunk
=== example: calc ===
42
42
42
42
=== example: mechanic ===
Hands on the wheel!!
@noib3
Copy link
Owner

noib3 commented Apr 21, 2023

That error message is pretty confusing but the issue is that you're not setting the height field. Note that doing the equivalent in Lua also results in an error:

:lua vim.api.nvim_open_win(0, false, {relative="editor", width=10, row=3, col=3})
->
Error [..] Must specify 'height'

@MostHated
Copy link
Author

MostHated commented Apr 21, 2023

I appreciate the reply.

I first saw this error from a fresh clone of the repo, built the example/api, setup nvim as specified, then ran the open_window command and got that error. Everything else after that (the examples in my initial post) were me just trying different things to see if I could figure out what was wrong.

I had made a number of changes to things in my local repo, trying different things, just to see what would happen, so I removed that and did a fresh clone again just now, built the api example and tried to run it and it segfaulted when doing the open_window command. That might be my fault, though. I see there has been a lot of commits since I made this post and setup my example plugin, so I will go back and review to see if there is anything new I missed that has to be done on my end.

That said, I am not sure if the height field was missing from the example/api at the time I made this post? I had made no changes to it prior to my first attempt and receiving that error, but it's been a decent amount of time, so I do not recall now that I removed the original repo.

Thanks,
-MH

@noib3
Copy link
Owner

noib3 commented Apr 21, 2023

Can you try running your code again using v0.3.0? I just ran that example and it works fine for me on Neovim 0.9.0. If you're still experiencing this issue can you post the exact code that you're running?

@MostHated
Copy link
Author

MostHated commented Apr 21, 2023

The segfault I received was from doing a fresh clone of main moments before my reply. I switched branch to v0.3.0 and tried again with the same process and result.

cargo b --example api --features neovim-nightly
cp ./target/debug/examples/libapi.so ~/.local/share/nvim/api/lua/api.so

I had this in my config at first, but causes nvim to segfault right off the rip.
I commented out the actual call (leaving in the rtp addition), then opened it up and tried to just run lua require('api') and it segfaulted again.

-- init.lua
-- plugin location ~/.local/share/nvim/api/lua/api.so
vim.cmd(string.format('set runtimepath+=%s', "~/.local/share/nvim/api"))

local status_ok, _ = pcall(require, "api")
if status_ok then
    vim.notify("nvim api loaded!")
else 
    vim.notify("Failed to load nvim api test")
end
NVIM v0.9.0-dev-554+g6f25623e7
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Looking over the readme and such again, it doesn't appear that I am doing anything incorrectly, but if I am, I do apologize, I am not catching what that might be.

@MostHated
Copy link
Author

MostHated commented May 5, 2023

Just to be sure I was not losing my marbles with my original post, I found the project I made from a copy of the api example which was build with 0.2, which is what prompted making this issue post. I did indeed have height, width, col, row.

I also tried a fresh pull of the repo just now, and tried again to build the api demo and loaded it up in nvim with the same result as prior:

I tried checking both the nvim logs as well as syslog, but didn't see any mention of anything in there. Are there any oxi logs that I am not seeing that I should check and post?

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