nvim_oxi_api/opts/
get_extmarks.rs

1/// Options passed to
2/// [`Buffer::get_extmarks()`](crate::Buffer::get_extmarks).
3#[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
4#[derive(Clone, Debug, Default)]
5#[repr(C)]
6pub struct GetExtmarksOpts {
7    details: types::Object,
8    limits: types::Object,
9}
10
11#[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
12impl GetExtmarksOpts {
13    #[inline(always)]
14    /// Creates a new [`GetExtmarksOptsBuilder`].
15    pub fn builder() -> GetExtmarksOptsBuilder {
16        GetExtmarksOptsBuilder::default()
17    }
18}
19
20#[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
21#[derive(Clone, Default)]
22pub struct GetExtmarksOptsBuilder(GetExtmarksOpts);
23
24#[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
25impl GetExtmarksOptsBuilder {
26    /// Whether to include the extmark's
27    /// [`ExtmarkInfos`](crate::types::ExtmarkInfos) as the last element of
28    /// the tuples returned by
29    /// [`Buffer::get_extmarks()`](crate::Buffer::get_extmarks).
30    #[inline]
31    pub fn details(&mut self, details: bool) -> &mut Self {
32        #[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
33        {
34            self.0.details = details.into();
35        }
36        #[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
37        {
38            self.0.details = details;
39            self.0.mask |= 0b1001;
40        }
41        self
42    }
43
44    #[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
45    #[inline]
46    pub fn hl_name(&mut self, hl_name: bool) -> &mut Self {
47        self.0.hl_name = hl_name;
48        self.0.mask |= 0b10001;
49        self
50    }
51
52    #[inline]
53    pub fn limits(&mut self, limits: bool) -> &mut Self {
54        #[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
55        {
56            self.0.limits = limits.into();
57        }
58        #[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
59        {
60            self.0.limits = limits as Integer;
61            self.0.mask |= 0b101;
62        }
63        self
64    }
65
66    #[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
67    #[inline]
68    pub fn overlap(&mut self, overlap: bool) -> &mut Self {
69        self.0.overlap = overlap;
70        self.0.mask |= 0b100001;
71        self
72    }
73
74    #[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
75    #[inline]
76    pub fn ty<S: Into<nvim::String>>(&mut self, ty: S) -> &mut Self {
77        self.0.ty = ty.into();
78        self.0.mask |= 0b11;
79        self
80    }
81
82    /// Maximum number of extmarks to return.
83    #[inline]
84    pub fn build(&mut self) -> GetExtmarksOpts {
85        std::mem::take(&mut self.0)
86    }
87}
88
89#[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
90impl From<&GetExtmarksOpts> for types::Dictionary {
91    fn from(opts: &GetExtmarksOpts) -> Self {
92        Self::from_iter([
93            ("details", opts.details.clone()),
94            ("limits", opts.limits.clone()),
95        ])
96    }
97}
98
99#[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
100#[derive(Clone, Debug, Default, macros::OptsBuilder)]
101#[repr(C)]
102/// Options passed to
103/// [`Buffer::get_extmarks()`](crate::Buffer::get_extmarks).
104pub struct GetExtmarksOpts {
105    #[builder(mask)]
106    mask: u64,
107
108    #[builder(
109        method = "limits",
110        argtype = "bool",
111        inline = "{0} as types::Integer"
112    )]
113    limit: types::Integer,
114
115    /// Whether to include the extmark's
116    /// [`ExtmarkInfos`](crate::types::ExtmarkInfos) as the last element of
117    /// the tuples returned by
118    /// [`Buffer::get_extmarks()`](crate::Buffer::get_extmarks).
119    #[builder(argtype = "bool")]
120    details: types::Boolean,
121
122    #[builder(argtype = "bool")]
123    hl_name: types::Boolean,
124
125    #[builder(argtype = "bool")]
126    overlap: types::Boolean,
127
128    // TODO: fix `Into`.
129    // TODO: name it `type` instead of `ty`.
130    // #[builder(Into)]
131    #[builder(
132        generics = "S: Into<types::String>",
133        argtype = "S",
134        inline = "{0}.into()"
135    )]
136    ty: types::String,
137}