nvim_oxi_api/opts/
create_autocmd.rs

1use crate::Buffer;
2use crate::StringOrInt;
3use crate::types::AutocmdCallbackArgs;
4
5pub type ShouldDeleteAutocmd = bool;
6
7/// Options passed to [`create_autocmd()`](crate::create_autocmd).
8#[derive(Clone, Debug, Default, macros::OptsBuilder)]
9#[repr(C)]
10pub struct CreateAutocmdOpts {
11    #[builder(mask)]
12    mask: u64,
13
14    /// A specific `Buffer` for buffer-local autocommands.
15    #[builder(argtype = "Buffer", inline = "{0}.0")]
16    buffer: types::BufHandle,
17
18    /// Callback to execute when the autocommand is triggered. Cannot be used
19    /// together with `command`.
20    #[builder(
21        generics = r#"F: Into<types::Function<AutocmdCallbackArgs, ShouldDeleteAutocmd>>"#,
22        argtype = "F",
23        inline = "{0}.into().into()"
24    )]
25    callback: types::Object,
26
27    /// Vim command to execute when the autocommand is triggered. Cannot be
28    /// used together with `callback`.
29    // TODO: fix builder(Into).
30    #[builder(
31        generics = "S: Into<types::String>",
32        argtype = "S",
33        inline = "{0}.into()"
34    )]
35    command: types::String,
36
37    /// Description of the autocommand.
38    // TODO: fix builder(Into).
39    #[builder(
40        generics = "S: Into<types::String>",
41        argtype = "S",
42        inline = "{0}.into()"
43    )]
44    desc: types::String,
45
46    /// The autocommand group name or id to match against.
47    #[builder(
48        generics = "G: StringOrInt",
49        argtype = "G",
50        inline = "{0}.to_object()"
51    )]
52    group: types::Object,
53
54    /// Run nested autocommands.
55    #[builder(argtype = "bool")]
56    nested: types::Boolean,
57
58    /// Only run the autocommand once.
59    #[builder(argtype = "bool")]
60    once: types::Boolean,
61
62    /// Patterns to match against.
63    #[builder(
64        generics = "'a, I: IntoIterator<Item = &'a str>",
65        method = "patterns",
66        argtype = "I",
67        inline = "types::Array::from_iter({0}).into()"
68    )]
69    pattern: types::Object,
70}