nvim_api/types/
keymap_infos.rs1use nvim_types::{
2 conversion::{self, FromObject},
3 serde::Deserializer,
4 Function,
5 Object,
6};
7use serde::Deserialize;
8
9use super::Mode;
10use crate::serde_utils as utils;
11
12#[non_exhaustive]
13#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize)]
14pub struct KeymapInfos {
15 #[serde(deserialize_with = "utils::bool_from_int")]
17 pub buffer: bool,
18
19 pub callback: Option<Function<(), ()>>,
21
22 #[serde(deserialize_with = "utils::bool_from_int")]
24 pub expr: bool,
25
26 pub lhs: String,
28
29 #[serde(deserialize_with = "utils::zero_is_none")]
31 pub lnum: Option<u32>,
32
33 pub mode: Mode,
35
36 #[serde(deserialize_with = "utils::bool_from_int")]
38 pub noremap: bool,
39
40 #[serde(deserialize_with = "utils::bool_from_int")]
44 pub nowait: bool,
45
46 #[serde(default, deserialize_with = "utils::empty_string_is_none")]
48 pub rhs: Option<String>,
49
50 #[serde(deserialize_with = "utils::bool_from_int")]
52 pub script: bool,
53
54 pub sid: i32,
56
57 #[serde(deserialize_with = "utils::bool_from_int")]
59 pub silent: bool,
60}
61
62impl FromObject for KeymapInfos {
63 fn from_object(obj: Object) -> Result<Self, conversion::Error> {
64 Self::deserialize(Deserializer::new(obj)).map_err(Into::into)
65 }
66}