nvim_oxi_api/opts/
create_command.rs

1use types::conversion::ToObject;
2
3use crate::Buffer;
4use crate::types::{
5    CommandAddr,
6    CommandArgs,
7    CommandComplete,
8    CommandNArgs,
9    CommandRange,
10};
11
12/// Options passed to [`create_user_command`](crate::create_user_command) and
13/// [`Buffer::create_user_command()`](crate::Buffer::create_user_command).
14#[derive(Clone, Debug, Default, macros::OptsBuilder)]
15#[repr(C)]
16pub struct CreateCommandOpts {
17    #[builder(mask)]
18    mask: u64,
19
20    #[builder(argtype = "CommandAddr", inline = "{0}.to_object().unwrap()")]
21    addr: types::Object,
22
23    #[builder(argtype = "bool")]
24    bang: types::Boolean,
25
26    #[builder(argtype = "bool")]
27    bar: types::Boolean,
28
29    #[builder(
30        argtype = "CommandComplete",
31        inline = "{0}.to_object().unwrap()"
32    )]
33    complete: types::Object,
34
35    // TODO: fix `builder(Into)`.
36    #[builder(
37        generics = "C: Into<types::Integer>",
38        argtype = "C",
39        inline = "{0}.into().into()"
40    )]
41    count: types::Object,
42
43    /// Description for the command.
44    #[builder(
45        generics = "C: Into<types::String>",
46        argtype = "C",
47        inline = "{0}.into().into()"
48    )]
49    desc: types::Object,
50
51    #[builder(argtype = "bool")]
52    force: types::Boolean,
53
54    #[builder(argtype = "bool")]
55    keepscript: types::Boolean,
56
57    #[builder(argtype = "CommandNArgs", inline = "{0}.to_object().unwrap()")]
58    nargs: types::Object,
59
60    #[builder(
61        generics = r#"F: Into<types::Function<(CommandArgs, Option<u32>, Option<Buffer>), u8>>"#,
62        argtype = "F",
63        inline = "{0}.into().into()"
64    )]
65    preview: types::Object,
66
67    #[builder(argtype = "CommandRange", inline = "{0}.to_object().unwrap()")]
68    range: types::Object,
69
70    #[builder(method = "register", argtype = "bool")]
71    register_: types::Boolean,
72}