Closed ReeceStevens closed 2 years ago
What version of Neovim does this happen on?
I feel pretty foolish for this oversight-- it is happening on neovim 0.8.0. Looking back at my linux box, I was still running 0.7.2 on there, and after upgrading I also see a segfault. So, my assumption about this being macos-specific seems to be incorrect.
I will try and downgrade my macOS neovim instance to 0.7.2 and see if my test case starts working again. Is there any other information you need that might be helpful?
Plugins created with nvim-oxi
are compiled against a specific version of Neovim. Before Neovim 0.8.0 was released the default was to build against 0.7.2, and we had a nightly
feature flag to enable for targeting Neovim nightly. I'm assuming you didn't enable that feature so your plugin is being compiled for 0.7.2 but loaded by 0.8.0, causing the segfault.
With that said, this system has been recently rewritten to be more explicit, and it'll be added in the 0.2.0
release of nvim-oxi
in the coming days.
In the meantime I'd suggest using the latest master of nvim-oxi
in your Cargo.toml
. Then you'll have to enable one of the neovim-0-7
, neovim-0-8
or neovim-nightly
features depending on the Neovim version you're targeting.
There were also some breaking changes since 0.1.3
so the code above won't compile. This should however:
use nvim_oxi as oxi;
use nvim_oxi::api::{
self,
opts::CreateCommandOpts,
types::{CommandArgs, CommandNArgs, CommandRange},
};
#[oxi::module]
fn vim_plugin_test() -> oxi::Result<u32> {
let opts = CreateCommandOpts::builder().build();
let greetings = move |args: CommandArgs| {
api::out_write("Test");
Ok(())
};
api::create_user_command("Greetings", greetings, &opts)?;
Ok(42)
}
(btw, you can use CreateCommandOpts::default()
instead of builder().build()
).
@noib3 thank you so much for your quick, detailed, and very helpful responses. You were right on the money; I needed to compile against neovim 0.8.0. After doing so, I was able to get my plugin up and running.
I'm going to go ahead and close this issue. I appreciate the help!
Hi all!
Firstly, thank you for the awesome work y'all are doing to make Rust accessible for neovim plugin writers!
I'm using
nvim-oxi
to write a plugin and have run into what appears to be a macos-specific issue. I only have access to an M1 mac, so I don't know for sure if this happens on intel macs or not. I do have access to a linux box, and I have confirmed the issue does not show up on linux (arch linux x86).I'm seeing segfaults any time I try to execute a user-defined command. Here's my reproducible code snippet:
I also have the linker arguments for macos as described in your examples directory:
My project builds with no issues, and I can confirm the user-defined command is accessible from neovim-- it shows up in tab completion. However, when I actually run
:Greetings<CR>
, neovim dies withSegmentation fault: 11
.I don't think this is an issue with code signing-- I got a different error (
Killed: 9
) when that was the case. I am now runningcodesign
on the produced libraries and that seems to work just fine.Any advice you have on next investigation steps would be much appreciated. Unfortunately GDB does not work on M1 architectures, but I have run neovim through
lldb
and got the following stack trace on the error:My best parse of this is that it's related to argument parsing or handling during the processing of the user-defined command. Perhaps relatedly, I noticed that using
CommandNArgs::One
in the creation of the command caused an immediate crash of neovim on launch with the following error:If you have any bandwidth to review these stack traces and let me know what you think, I would really appreciate it. Thanks again!