nvim_api/types/
autocmd_infos.rs

1use nvim_types::{
2    conversion::{self, FromObject},
3    serde::Deserializer,
4    Object,
5};
6use serde::Deserialize;
7
8use crate::Buffer;
9
10/// Informations related to an autocommand.
11#[non_exhaustive]
12#[derive(Clone, Debug, Eq, PartialEq, Hash, Deserialize)]
13pub struct AutocmdInfos {
14    /// The `Buffer` associated to the autocommand. Only present if `buflocal`
15    /// is `true`.
16    pub buffer: Option<Buffer>,
17
18    /// Whether the autocommand is a buffer-local one.
19    pub buflocal: bool,
20
21    /// The command executed by the autocommand.
22    pub command: String,
23
24    /// The autocommand's description.
25    #[serde(default)]
26    pub desc: Option<String>,
27
28    /// The event triggering the autocommand.
29    pub event: String,
30
31    /// The autocommand group's id. Only present if the autocommand belongs to
32    /// an autocommand group.
33    #[serde(default)]
34    pub group: Option<u32>,
35
36    /// The autocommand group's name. Only present if the autocommand belongs
37    /// to an autocommand group.
38    #[serde(default)]
39    pub group_name: Option<String>,
40
41    /// The autocommand id.
42    #[serde(default)]
43    pub id: Option<u32>,
44
45    /// Whether the autocommand is only run once.
46    pub once: bool,
47
48    /// The autocommand's pattern.
49    pub pattern: String,
50}
51
52impl FromObject for AutocmdInfos {
53    fn from_object(obj: Object) -> Result<Self, conversion::Error> {
54        Self::deserialize(Deserializer::new(obj)).map_err(Into::into)
55    }
56}