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