Add a neovim-0-11 feature (#243)

This commit is contained in:
Riccardo Mazzarini 2025-05-23 16:56:20 +02:00 committed by GitHub
parent c2d1da63fb
commit dbcbce2216
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 73 additions and 62 deletions

View file

@ -16,10 +16,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
neovim: [v0.10.4, Nightly]
neovim: [v0.10.4, v0.11.1, Nightly]
include:
- neovim: v0.10.4
features: "--features neovim-0-10"
- neovim: v0.11.1
features: "--features neovim-0-11"
- neovim: Nightly
features: "--features neovim-nightly"

View file

@ -43,7 +43,8 @@ rustdoc-args = ["--cfg", "docsrs"]
[features]
neovim-0-10 = ["api/neovim-0-10"]
neovim-nightly = ["neovim-0-10", "api/neovim-nightly"]
neovim-0-11 = ["api/neovim-0-10", "api/neovim-0-11"]
neovim-nightly = ["neovim-0-11", "api/neovim-nightly"]
libuv = ["dep:libuv"]
mlua = ["dep:mlua"]

View file

@ -1,6 +1,11 @@
#[cfg(not(any(feature = "neovim-0-10", feature = "neovim-nightly")))]
#[cfg(not(any(
feature = "neovim-0-10",
feature = "neovim-0-11",
feature = "neovim-nightly"
)))]
compile_error!(
"You must enable one of the features: neovim-0-10, neovim-nightly"
"You must enable one of the features: neovim-0-10, neovim-0-11, \
neovim-nightly"
);
fn main() {

View file

@ -9,7 +9,8 @@ license.workspace = true
[features]
neovim-0-10 = []
neovim-nightly = ["neovim-0-10"]
neovim-0-11 = ["neovim-0-10"]
neovim-nightly = ["neovim-0-11"]
[dependencies]
luajit = { workspace = true }

View file

@ -14,7 +14,7 @@ use crate::{Buffer, Window};
///
/// [1]: https://neovim.io/doc/user/api.html#nvim_exec()
#[cfg_attr(
feature = "neovim-nightly",
feature = "neovim-0-11", // On 0.11 and Nightly.
deprecated(since = "0.5.0", note = "use `exec2` instead")
)]
pub fn exec(src: &str, output: bool) -> Result<Option<String>> {
@ -36,7 +36,7 @@ pub fn exec(src: &str, output: bool) -> Result<Option<String>> {
///
/// [1]: https://neovim.io/doc/user/api.html#nvim_get_current_win()
#[cfg_attr(
feature = "neovim-nightly",
feature = "neovim-0-11", // On 0.11 and Nightly.
deprecated(since = "0.5.0", note = "use `get_hl` instead")
)]
pub fn get_hl_by_id(hl_id: u32, rgb: bool) -> Result<HighlightInfos> {
@ -55,7 +55,7 @@ pub fn get_hl_by_id(hl_id: u32, rgb: bool) -> Result<HighlightInfos> {
///
/// [1]: https://neovim.io/doc/user/api.html#nvim_get_hl_by_name()
#[cfg_attr(
feature = "neovim-nightly",
feature = "neovim-0-11", // On 0.11 and Nightly.
deprecated(since = "0.5.0", note = "use `get_hl` instead")
)]
pub fn get_hl_by_name(name: &str, rgb: bool) -> Result<HighlightInfos> {
@ -78,7 +78,7 @@ pub fn get_hl_by_name(name: &str, rgb: bool) -> Result<HighlightInfos> {
///
/// [1]: https://neovim.io/doc/user/api.html#nvim_get_option()
#[cfg_attr(
feature = "neovim-nightly",
feature = "neovim-0-11", // On 0.11 and Nightly.
deprecated(since = "0.5.0", note = "use `get_option_value` instead")
)]
pub fn get_option<Opt>(name: &str) -> Result<Opt>
@ -97,7 +97,7 @@ where
///
/// [1]: https://neovim.io/doc/user/api.html#nvim_get_option_info()
#[cfg_attr(
feature = "neovim-nightly",
feature = "neovim-0-11", // On 0.11 and Nightly.
deprecated(since = "0.5.0", note = "use `get_option_info2` instead")
)]
pub fn get_option_info(name: &str) -> Result<OptionInfos> {
@ -115,7 +115,7 @@ pub fn get_option_info(name: &str) -> Result<OptionInfos> {
///
/// [1]: https://neovim.io/doc/user/api.html#nvim_set_option()
#[cfg_attr(
feature = "neovim-nightly",
feature = "neovim-0-11", // On 0.11 and Nightly.
deprecated(since = "0.5.0", note = "use `set_option_value` instead")
)]
pub fn set_option<Opt>(name: &str, value: Opt) -> Result<()>
@ -142,7 +142,7 @@ impl Buffer {
///
/// [1]: https://neovim.io/doc/user/api.html#nvim_buf_get_option()
#[cfg_attr(
feature = "neovim-nightly",
feature = "neovim-0-11", // On 0.11 and Nightly.
deprecated(since = "0.5.0", note = "use `get_option_value` instead")
)]
pub fn get_option<Opt>(&self, name: &str) -> Result<Opt>
@ -164,7 +164,7 @@ impl Buffer {
///
/// [1]: https://neovim.io/doc/user/api.html#nvim_buf_set_option()
#[cfg_attr(
feature = "neovim-nightly",
feature = "neovim-0-11", // On 0.11 and Nightly.
deprecated(since = "0.5.0", note = "use `set_option_value` instead")
)]
pub fn set_option<V>(&mut self, name: &str, value: V) -> Result<()>
@ -193,7 +193,7 @@ impl Window {
///
/// [1]: https://neovim.io/doc/user/api.html#nvim_win_get_option()
#[cfg_attr(
feature = "neovim-nightly",
feature = "neovim-0-11", // On 0.11 and Nightly.
deprecated(since = "0.5.0", note = "use `get_option_value` instead")
)]
pub fn get_option<Opt>(&self, name: &str) -> Result<Opt>
@ -215,7 +215,7 @@ impl Window {
///
/// [1]: https://neovim.io/doc/user/api.html#nvim_win_set_option()
#[cfg_attr(
feature = "neovim-nightly",
feature = "neovim-0-11", // On 0.11 and Nightly.
deprecated(since = "0.5.0", note = "use `set_option_value` instead")
)]
pub fn set_option<Opt>(&mut self, name: &str, value: Opt) -> Result<()>

View file

@ -166,7 +166,8 @@ extern "C" {
// https://github.com/neovim/neovim/blob/v0.10.0/src/nvim/api/vim.c#L360
pub(crate) fn nvim_input(
#[cfg(feature = "neovim-nightly")] channel_id: u64,
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
channel_id: u64,
keys: NvimStr,
) -> Integer;

View file

@ -1,5 +1,5 @@
/// Options passed to [`create_augroup()`](crate::create_augroup).
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
#[derive(Clone, Debug, Default, macros::OptsBuilder)]
#[repr(C)]
pub struct CreateAugroupOpts {
@ -12,14 +12,14 @@ pub struct CreateAugroupOpts {
}
/// Options passed to [`create_augroup()`](crate::create_augroup).
#[cfg(not(feature = "neovim-nightly"))] // Only on 0.10.
#[cfg(not(feature = "neovim-0-11"))] // Only on 0.10.
#[derive(Clone, Debug, Default)]
#[repr(C)]
pub struct CreateAugroupOpts {
clear: types::Object,
}
#[cfg(not(feature = "neovim-nightly"))] // Only on 0.10.
#[cfg(not(feature = "neovim-0-11"))] // Only on 0.10.
impl CreateAugroupOpts {
#[inline(always)]
pub fn builder() -> CreateAugroupOptsBuilder {
@ -27,11 +27,11 @@ impl CreateAugroupOpts {
}
}
#[cfg(not(feature = "neovim-nightly"))] // Only on 0.10.
#[cfg(not(feature = "neovim-0-11"))] // Only on 0.10.
#[derive(Clone, Default)]
pub struct CreateAugroupOptsBuilder(CreateAugroupOpts);
#[cfg(not(feature = "neovim-nightly"))] // Only on 0.10.
#[cfg(not(feature = "neovim-0-11"))] // Only on 0.10.
impl CreateAugroupOptsBuilder {
/// Whether to clear existing commands if the group already exists.
#[inline]

View file

@ -1,7 +1,7 @@
use types::{Array, Integer};
use crate::trait_utils::StringOrListOfStrings;
#[cfg(feature = "neovim-nightly")]
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
use crate::types::VirtLinesOverflow;
use crate::types::{ExtmarkHlMode, ExtmarkVirtTextPosition};
@ -28,8 +28,8 @@ pub struct SetExtmarkOpts {
end_col: types::Integer,
/// Name of the highlight group used to highlight this mark.
#[cfg(not(feature = "neovim-nightly"))] // Only on 0.10.
#[cfg_attr(docsrs, doc(cfg(not(feature = "neovim-nightly"))))]
#[cfg(not(feature = "neovim-0-11"))] // Only on 0.10.
#[cfg_attr(docsrs, doc(cfg(not(feature = "neovim-0-11"))))]
#[builder(
generics = "Hl: crate::HlGroup",
argtype = "Hl",
@ -38,8 +38,8 @@ pub struct SetExtmarkOpts {
hl_group: types::HlGroupId,
/// Name of the highlight group used to highlight this mark.
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
#[cfg(feature = "neovim-0-11")] // Only on Nightly.
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-0-11")))]
#[builder(
generics = "Hl: crate::SetExtmarkHlGroup",
argtype = "Hl",
@ -135,8 +135,8 @@ pub struct SetExtmarkOpts {
virt_lines_leftcol: types::Boolean,
/// Controls how to handle virtual lines wider than the window.
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
#[cfg(feature = "neovim-nightly")]
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-0-11")))]
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
#[builder(argtype = "VirtLinesOverflow", inline = "{0}.into()")]
virt_lines_overflow: types::String,
@ -196,8 +196,8 @@ pub struct SetExtmarkOpts {
/// When called, lines in the range are not drawn at all (according to
/// `conceallevel`); the next unconcealed line is drawn instead.
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
#[cfg(feature = "neovim-nightly")]
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-0-11")))]
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
#[builder(argtype = "()", inline = "{let _ = {0}; types::String::new()}")]
conceal_lines: types::String,

View file

@ -76,7 +76,7 @@ pub struct SetHighlightOpts {
#[builder(skip)]
sp: Object,
#[cfg(not(feature = "neovim-nightly"))] // Only on 0.10.
#[cfg(not(feature = "neovim-0-11"))] // Only on 0.10.
#[builder(
generics = "Hl: crate::HlGroup",
argtype = "Hl",
@ -84,7 +84,7 @@ pub struct SetHighlightOpts {
)]
link: Object,
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
#[builder(
generics = "Hl: crate::HlGroup",
argtype = "Hl",
@ -92,11 +92,11 @@ pub struct SetHighlightOpts {
)]
link: types::HlGroupId,
#[cfg(not(feature = "neovim-nightly"))] // Only on 0.10.
#[cfg(not(feature = "neovim-0-11"))] // Only on 0.10.
#[builder(skip)]
global_link: Object,
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
#[builder(skip)]
global_link: types::HlGroupId,

View file

@ -169,13 +169,13 @@ impl HlGroup for &str {
/// A trait implemented by types that can be passed to
/// [`SetExtmarkOptsBuilder::hl_group`](crate::opts::SetExtmarkOptsBuilder::hl_group).
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-0-11")))]
pub trait SetExtmarkHlGroup {
fn into_object(self) -> Object;
}
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
impl SetExtmarkHlGroup for Integer {
#[inline]
fn into_object(self) -> Object {
@ -183,7 +183,7 @@ impl SetExtmarkHlGroup for Integer {
}
}
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
impl SetExtmarkHlGroup for &str {
#[inline]
fn into_object(self) -> Object {
@ -191,7 +191,7 @@ impl SetExtmarkHlGroup for &str {
}
}
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
impl<T: StringOrInt> SetExtmarkHlGroup for Vec<T> {
#[inline]
fn into_object(self) -> Object {

View file

@ -179,19 +179,19 @@ pub(crate) struct ParseCmdOutput {
nargs: Object,
// Only on 0.10.
#[cfg(not(feature = "neovim-nightly"))]
#[cfg(not(feature = "neovim-0-11"))]
addr: Object,
// Only on Nightly.
#[cfg(feature = "neovim-nightly")]
// On 0.11 and Nightly.
#[cfg(feature = "neovim-0-11")]
addr: NvimString,
// Only on 0.10.
#[cfg(not(feature = "neovim-nightly"))]
#[cfg(not(feature = "neovim-0-11"))]
nextcmd: Object,
// Only on 0.10.
#[cfg(feature = "neovim-nightly")]
#[cfg(feature = "neovim-0-11")]
nextcmd: NvimString,
}
@ -279,9 +279,9 @@ impl TryFrom<ParseCmdOutput> for CmdInfos {
}
Ok(Self {
#[cfg(not(feature = "neovim-nightly"))] // Only on 0.10.
#[cfg(not(feature = "neovim-0-11"))] // Only on 0.10.
addr: utils::none_literal_is_none(Deserializer::new(addr))?,
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
addr: utils::none_literal_is_none(Deserializer::new(addr.into()))?,
args: deserialize(args)?,
bang: deserialize(bang)?,
@ -290,11 +290,11 @@ impl TryFrom<ParseCmdOutput> for CmdInfos {
magic: deserialize(magic)?,
mods: deserialize(mods)?,
nargs: deserialize(nargs)?,
#[cfg(not(feature = "neovim-nightly"))] // Only on 0.10.
#[cfg(not(feature = "neovim-0-11"))] // Only on 0.10.
nextcmd: utils::empty_string_is_none(Deserializer::new(
nextcmd,
))?,
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
nextcmd: utils::empty_string_is_none(Deserializer::new(
nextcmd.into(),
))?,

View file

@ -23,13 +23,13 @@ pub struct ExtmarkInfos {
#[serde(default)]
pub hl_eol: Option<bool>,
#[cfg(not(feature = "neovim-nightly"))] // Only on 0.10.
#[cfg_attr(docsrs, doc(cfg(not(feature = "neovim-nightly"))))]
#[cfg(not(feature = "neovim-0-11"))] // Only on 0.10.
#[cfg_attr(docsrs, doc(cfg(not(feature = "neovim-0-11"))))]
#[serde(default)]
pub hl_group: Option<String>,
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-0-11")))]
#[serde(default)]
pub hl_group: Option<super::OneOrMore<String>>,

View file

@ -53,8 +53,8 @@ pub struct WindowConfig {
pub hide: Option<bool>,
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-0-11")))]
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
#[serde(default)]
pub mouse: bool,
@ -294,8 +294,8 @@ pub struct WindowOpts {
bufpos: Array,
external: Boolean,
focusable: Boolean,
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
#[cfg(feature = "neovim-nightly")]
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-0-11")))]
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
mouse: Boolean,
vertical: Boolean,
zindex: Integer,
@ -361,7 +361,7 @@ impl From<&WindowConfig> for WindowOpts {
builder.focusable(focusable);
}
#[cfg(feature = "neovim-nightly")]
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
builder.mouse(config.mouse);
if let Some(vertical) = config.vertical {
@ -429,7 +429,7 @@ impl TryFrom<WindowOpts> for WindowConfig {
footer_pos,
height,
hide,
#[cfg(feature = "neovim-nightly")]
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
mouse,
noautocmd,
relative,
@ -503,7 +503,7 @@ impl TryFrom<WindowOpts> for WindowConfig {
))?,
height: deserialize(height)?,
hide: deserialize(hide)?,
#[cfg(feature = "neovim-nightly")]
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
mouse,
noautocmd: deserialize(noautocmd)?,
relative,

View file

@ -483,7 +483,7 @@ where
{
unsafe {
nvim_input(
#[cfg(feature = "neovim-nightly")]
#[cfg(feature = "neovim-0-11")] // On 0.11 and Nightly.
LUA_INTERNAL_CALL,
keys.into().as_nvim_str(),
)

View file

@ -10,7 +10,8 @@ crate-type = ["cdylib"]
[features]
default = ["neovim-0-10"]
neovim-0-10 = ["nvim-oxi/neovim-0-10"]
neovim-nightly = ["neovim-0-10", "nvim-oxi/neovim-nightly"]
neovim-0-11 = ["neovim-0-10", "nvim-oxi/neovim-0-11"]
neovim-nightly = ["neovim-0-11", "nvim-oxi/neovim-nightly"]
[dependencies]
all_asserts = "2.3"

View file

@ -285,7 +285,7 @@ fn set_get_del_var() {
}
// `api::{get,set}_option()` were deprecated on 0.11, so only test on 0.10.
#[cfg(not(feature = "neovim-nightly"))]
#[cfg(not(feature = "neovim-0-11"))] // Only on 0.10.
#[nvim_oxi::test]
fn set_get_option() {
api::set_option("modified", true).unwrap();