Skip to content

Commit 3c297e5

Browse files
committed
fix(api): update GetExtmarksOpts on nightly
1 parent 28c2c5c commit 3c297e5

File tree

1 file changed

+49
-32
lines changed

1 file changed

+49
-32
lines changed

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

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

63
/// Options passed to
74
/// [`Buffer::get_extmarks()`](crate::Buffer::get_extmarks).
8-
#[cfg(not(feature = "neovim-nightly"))]
9-
#[derive(Clone, Debug, Default)]
10-
#[repr(C)]
11-
pub struct GetExtmarksOpts {
12-
details: Object,
13-
limits: Object,
14-
}
15-
16-
#[cfg(feature = "neovim-nightly")]
5+
#[cfg(any(feature = "neovim-0-8", feature = "neovim-0-9"))]
176
#[derive(Clone, Debug, Default)]
187
#[repr(C)]
198
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,
9+
details: types::Object,
10+
limits: types::Object,
3711
}
3812

13+
#[cfg(any(feature = "neovim-0-8", feature = "neovim-0-9"))]
3914
impl GetExtmarksOpts {
4015
#[inline(always)]
4116
/// Creates a new [`GetExtmarksOptsBuilder`].
@@ -44,9 +19,11 @@ impl GetExtmarksOpts {
4419
}
4520
}
4621

22+
#[cfg(any(feature = "neovim-0-8", feature = "neovim-0-9"))]
4723
#[derive(Clone, Default)]
4824
pub struct GetExtmarksOptsBuilder(GetExtmarksOpts);
4925

26+
#[cfg(any(feature = "neovim-0-8", feature = "neovim-0-9"))]
5027
impl GetExtmarksOptsBuilder {
5128
/// Whether to include the extmark's
5229
/// [`ExtmarkInfos`](crate::types::ExtmarkInfos) as the last element of
@@ -111,12 +88,52 @@ impl GetExtmarksOptsBuilder {
11188
}
11289
}
11390

114-
#[cfg(not(feature = "neovim-nightly"))]
115-
impl From<&GetExtmarksOpts> for Dictionary {
91+
#[cfg(any(feature = "neovim-0-8", feature = "neovim-0-9"))]
92+
impl From<&GetExtmarksOpts> for types::Dictionary {
11693
fn from(opts: &GetExtmarksOpts) -> Self {
11794
Self::from_iter([
11895
("details", opts.details.clone()),
11996
("limits", opts.limits.clone()),
12097
])
12198
}
12299
}
100+
101+
#[cfg(feature = "neovim-nightly")]
102+
#[derive(Clone, Debug, Default, oxi_macros::OptsBuilder)]
103+
#[repr(C)]
104+
/// Options passed to
105+
/// [`Buffer::get_extmarks()`](crate::Buffer::get_extmarks).
106+
pub struct GetExtmarksOpts {
107+
#[builder(mask)]
108+
mask: u64,
109+
110+
#[builder(
111+
method = "limits",
112+
argtype = "bool",
113+
inline = "{0} as types::Integer"
114+
)]
115+
limit: types::Integer,
116+
117+
/// Whether to include the extmark's
118+
/// [`ExtmarkInfos`](crate::types::ExtmarkInfos) as the last element of
119+
/// the tuples returned by
120+
/// [`Buffer::get_extmarks()`](crate::Buffer::get_extmarks).
121+
#[builder(argtype = "bool")]
122+
details: types::Boolean,
123+
124+
#[builder(argtype = "bool")]
125+
hl_name: types::Boolean,
126+
127+
#[builder(argtype = "bool")]
128+
overlap: types::Boolean,
129+
130+
// TODO: fix `Into`.
131+
// TODO: name it `type` instead of `ty`.
132+
// #[builder(Into)]
133+
#[builder(
134+
generics = "S: Into<types::String>",
135+
argtype = "S",
136+
inline = "{0}.into()"
137+
)]
138+
ty: types::String,
139+
}

0 commit comments

Comments
 (0)