nvim_api/opts/
get_extmarks.rs

1use derive_builder::Builder;
2use nvim_types::{Dictionary, Object};
3
4/// Options passed to
5/// [`Buffer::get_extmarks`](crate::Buffer::get_extmarks).
6#[derive(Clone, Debug, Default, Builder)]
7#[builder(default, build_fn(private, name = "fallible_build"))]
8pub struct GetExtmarksOpts {
9    /// Whether to include the extmark's
10    /// [`ExtmarkInfos`](crate::types::ExtmarkInfos) as the last element of the
11    /// tuples returned by
12    /// [`Buffer::get_extmarks`](crate::Buffer::get_extmarks).
13    #[builder(setter(strip_option))]
14    details: Option<bool>,
15
16    /// Maximum number of extmarks to return.
17    #[builder(setter(strip_option))]
18    limits: Option<u32>,
19}
20
21impl GetExtmarksOpts {
22    #[inline(always)]
23    /// Creates a new [`GetExtmarksOptsBuilder`].
24    pub fn builder() -> GetExtmarksOptsBuilder {
25        GetExtmarksOptsBuilder::default()
26    }
27}
28
29impl GetExtmarksOptsBuilder {
30    pub fn build(&mut self) -> GetExtmarksOpts {
31        self.fallible_build().expect("never fails, all fields have defaults")
32    }
33}
34
35impl From<&GetExtmarksOpts> for Dictionary {
36    fn from(opts: &GetExtmarksOpts) -> Self {
37        Self::from_iter([
38            ("details", opts.details.into()),
39            ("limits", Object::from(opts.limits)),
40        ])
41    }
42}