nvim_api/opts/
open_term.rs1use derive_builder::Builder;
2use nvim_types::{self as nvim, Dictionary, Object};
3
4use crate::Buffer;
5use crate::ToFunction;
6
7pub type OnInputArgs = (
16 String, u32, Buffer, nvim::String, );
21
22#[derive(Clone, Debug, Default, Builder)]
23#[builder(default, build_fn(private, name = "fallible_build"))]
24pub struct OpenTermOpts {
25 #[builder(setter(custom))]
26 on_input: Object,
27}
28
29impl OpenTermOpts {
30 #[inline(always)]
31 pub fn builder() -> OpenTermOptsBuilder {
33 OpenTermOptsBuilder::default()
34 }
35}
36
37impl OpenTermOptsBuilder {
38 pub fn on_input<F>(&mut self, fun: F) -> &mut Self
40 where
41 F: ToFunction<OnInputArgs, ()>,
42 {
43 self.on_input = Some(fun.to_object());
44 self
45 }
46
47 pub fn build(&mut self) -> OpenTermOpts {
48 self.fallible_build().expect("never fails, all fields have defaults")
49 }
50}
51
52impl From<&OpenTermOpts> for Dictionary {
53 fn from(opts: &OpenTermOpts) -> Self {
54 Self::from_iter([("on_input", opts.on_input.clone())])
55 }
56}