nvim_api/types/
option_infos.rs1use nvim_types::{
2 conversion::{self, FromObject},
3 serde::Deserializer,
4 Object,
5};
6use serde::Deserialize;
7
8#[non_exhaustive]
11#[derive(Clone, Debug, PartialEq, Deserialize)]
12pub struct OptionInfos {
13 pub allows_duplicates: bool,
15
16 pub commalist: bool,
18
19 pub default: Object,
21
22 pub flaglist: bool,
24
25 pub global_local: bool,
27
28 pub last_set_chan: i64,
30
31 pub last_set_linenr: usize,
33
34 pub last_set_sid: i32,
36
37 pub name: String,
39
40 pub scope: OptionScope,
42
43 pub shortname: String,
45
46 pub was_set: bool,
48}
49
50impl FromObject for OptionInfos {
51 fn from_object(obj: Object) -> Result<Self, conversion::Error> {
52 Self::deserialize(Deserializer::new(obj)).map_err(Into::into)
53 }
54}
55
56#[non_exhaustive]
57#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Deserialize)]
58pub enum OptionScope {
59 #[serde(rename = "buf")]
60 Buffer,
61
62 #[serde(rename = "global")]
63 Global,
64
65 #[serde(rename = "win")]
66 Window,
67}
68
69impl OptionScope {
70 #[inline]
71 pub const fn is_buffer(&self) -> bool {
72 matches!(self, OptionScope::Buffer)
73 }
74
75 #[inline]
76 pub const fn is_global(&self) -> bool {
77 matches!(self, OptionScope::Global)
78 }
79
80 #[inline]
81 pub const fn is_window(&self) -> bool {
82 matches!(self, OptionScope::Window)
83 }
84}