Skip to content

Commit 72352f2

Browse files
committed
api: update GetExtmarkOpts for nightly
1 parent 8b22cb6 commit 72352f2

File tree

3 files changed

+77
-3
lines changed

3 files changed

+77
-3
lines changed

crates/oxi-api/src/extmark.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ impl Buffer {
168168
opts: &GetExtmarksOpts,
169169
) -> Result<impl SuperIterator<(u32, usize, usize, Option<ExtmarkInfos>)>>
170170
{
171+
#[cfg(not(feature = "neovim-nightly"))]
171172
let opts = Dictionary::from(opts);
172173
let mut err = nvim::Error::new();
173174
let extmarks = unsafe {
@@ -176,7 +177,10 @@ impl Buffer {
176177
ns_id as Integer,
177178
start.into(),
178179
end.into(),
180+
#[cfg(not(feature = "neovim-nightly"))]
179181
opts.non_owning(),
182+
#[cfg(feature = "neovim-nightly")]
183+
opts,
180184
&mut err,
181185
)
182186
};

crates/oxi-api/src/ffi/extmark.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ extern "C" {
5555
ns_id: Integer,
5656
start: Object,
5757
end: Object,
58-
opts: NonOwning<Dictionary>,
58+
#[cfg(not(feature = "neovim-nightly"))] opts: NonOwning<Dictionary>,
59+
#[cfg(feature = "neovim-nightly")] opts: *const GetExtmarksOpts,
5960
err: *mut Error,
6061
) -> Array;
6162

crates/oxi-api/src/opts/get_extmarks.rs

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,41 @@
1+
#[cfg(feature = "neovim-nightly")]
2+
use oxi_types::{self as nvim, Boolean, Integer, String as NvimString};
3+
#[cfg(not(feature = "neovim-nightly"))]
14
use oxi_types::{Dictionary, Object};
25

36
/// Options passed to
47
/// [`Buffer::get_extmarks()`](crate::Buffer::get_extmarks).
8+
#[cfg(not(feature = "neovim-nightly"))]
59
#[derive(Clone, Debug, Default)]
10+
#[repr(C)]
611
pub struct GetExtmarksOpts {
712
details: Object,
813
limits: Object,
914
}
1015

16+
#[cfg(feature = "neovim-nightly")]
17+
#[derive(Clone, Debug, Default)]
18+
#[repr(C)]
19+
pub struct GetExtmarksOpts {
20+
/// <overlap><hl_name><details><limit><type>1
21+
mask: u64,
22+
23+
/// 2nd in the mask.
24+
limits: Integer,
25+
26+
/// 3rd in the mask.
27+
details: Boolean,
28+
29+
/// 4th in the mask.
30+
hl_name: Boolean,
31+
32+
/// 5th in the mask.
33+
overlap: Boolean,
34+
35+
/// 1st in the mask.
36+
ty: NvimString,
37+
}
38+
1139
impl GetExtmarksOpts {
1240
#[inline(always)]
1341
/// Creates a new [`GetExtmarksOptsBuilder`].
@@ -26,13 +54,53 @@ impl GetExtmarksOptsBuilder {
2654
/// [`Buffer::get_extmarks()`](crate::Buffer::get_extmarks).
2755
#[inline]
2856
pub fn details(&mut self, details: bool) -> &mut Self {
29-
self.0.details = details.into();
57+
#[cfg(not(feature = "neovim-nightly"))]
58+
{
59+
self.0.details = details.into();
60+
}
61+
#[cfg(feature = "neovim-nightly")]
62+
{
63+
self.0.details = details;
64+
self.0.mask |= 0b1001;
65+
}
66+
self
67+
}
68+
69+
#[cfg(feature = "neovim-nightly")]
70+
#[inline]
71+
pub fn hl_name(&mut self, hl_name: bool) -> &mut Self {
72+
self.0.hl_name = hl_name;
73+
self.0.mask |= 0b10001;
3074
self
3175
}
3276

3377
#[inline]
3478
pub fn limits(&mut self, limits: bool) -> &mut Self {
35-
self.0.limits = limits.into();
79+
#[cfg(not(feature = "neovim-nightly"))]
80+
{
81+
self.0.limits = limits.into();
82+
}
83+
#[cfg(feature = "neovim-nightly")]
84+
{
85+
self.0.limits = limits as Integer;
86+
self.0.mask |= 0b101;
87+
}
88+
self
89+
}
90+
91+
#[cfg(feature = "neovim-nightly")]
92+
#[inline]
93+
pub fn overlap(&mut self, overlap: bool) -> &mut Self {
94+
self.0.overlap = overlap;
95+
self.0.mask |= 0b100001;
96+
self
97+
}
98+
99+
#[cfg(feature = "neovim-nightly")]
100+
#[inline]
101+
pub fn ty<S: Into<nvim::String>>(&mut self, ty: S) -> &mut Self {
102+
self.0.ty = ty.into();
103+
self.0.mask |= 0b11;
36104
self
37105
}
38106

@@ -43,6 +111,7 @@ impl GetExtmarksOptsBuilder {
43111
}
44112
}
45113

114+
#[cfg(not(feature = "neovim-nightly"))]
46115
impl From<&GetExtmarksOpts> for Dictionary {
47116
fn from(opts: &GetExtmarksOpts) -> Self {
48117
Self::from_iter([

0 commit comments

Comments
 (0)