use nvim_types::{
conversion::{self, FromObject},
serde::Deserializer,
Object,
};
use serde::Deserialize;
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq, Deserialize)]
pub struct OptionInfos {
pub allows_duplicates: bool,
pub commalist: bool,
pub default: Object,
pub flaglist: bool,
pub global_local: bool,
pub last_set_chan: i64,
pub last_set_linenr: usize,
pub last_set_sid: i32,
pub name: String,
pub scope: OptionScope,
pub shortname: String,
pub was_set: bool,
}
impl FromObject for OptionInfos {
fn from_object(obj: Object) -> Result<Self, conversion::Error> {
Self::deserialize(Deserializer::new(obj)).map_err(Into::into)
}
}
#[non_exhaustive]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Deserialize)]
pub enum OptionScope {
#[serde(rename = "buf")]
Buffer,
#[serde(rename = "global")]
Global,
#[serde(rename = "win")]
Window,
}
impl OptionScope {
#[inline]
pub const fn is_buffer(&self) -> bool {
matches!(self, OptionScope::Buffer)
}
#[inline]
pub const fn is_global(&self) -> bool {
matches!(self, OptionScope::Global)
}
#[inline]
pub const fn is_window(&self) -> bool {
matches!(self, OptionScope::Window)
}
}