nvim_oxi_api/opts/
decoration_provider.rs1use types::Object;
2
3use crate::ToFunction;
4use crate::{Buffer, Window};
5
6pub type OnBufArgs = (
10 String, Buffer, );
13
14pub type OnEndArgs = (
17 String, u32, );
20
21pub type OnLineArgs = (
24 String, Window, Buffer, usize, );
29
30pub type OnStartArgs = (
33 String, u32, u32, );
37
38pub type OnWinArgs = (
41 String, Window, Buffer, u32, u32, );
47
48pub type DontSkipRedrawCycle = bool;
51
52pub type DontSkipOnLines = bool;
55
56#[derive(Clone, Debug, Default)]
59#[repr(C)]
60pub struct DecorationProviderOpts {
61 on_start: Object,
62 on_buf: Object,
63 on_win: Object,
64 on_line: Object,
65 on_end: Object,
66 _on_hl_def: Object,
67 _on_spell_nav: Object,
68}
69
70impl DecorationProviderOpts {
71 #[inline(always)]
72 pub fn builder() -> DecorationProviderOptsBuilder {
74 DecorationProviderOptsBuilder::default()
75 }
76}
77
78#[derive(Clone, Default)]
79pub struct DecorationProviderOptsBuilder(DecorationProviderOpts);
80
81impl DecorationProviderOptsBuilder {
82 #[inline]
83 pub fn on_buf<F>(&mut self, fun: F) -> &mut Self
84 where
85 F: ToFunction<OnBufArgs, ()>,
86 {
87 self.0.on_buf = Object::from_luaref(fun.into_luaref());
88 self
89 }
90
91 #[inline]
92 pub fn on_end<F>(&mut self, fun: F) -> &mut Self
93 where
94 F: ToFunction<OnEndArgs, ()>,
95 {
96 self.0.on_end = Object::from_luaref(fun.into_luaref());
97 self
98 }
99
100 #[inline]
101 pub fn on_line<F>(&mut self, fun: F) -> &mut Self
102 where
103 F: ToFunction<OnLineArgs, ()>,
104 {
105 self.0.on_line = Object::from_luaref(fun.into_luaref());
106 self
107 }
108
109 #[inline]
110 pub fn on_start<F>(&mut self, fun: F) -> &mut Self
111 where
112 F: ToFunction<OnStartArgs, DontSkipRedrawCycle>,
113 {
114 self.0.on_start = Object::from_luaref(fun.into_luaref());
115 self
116 }
117
118 #[inline]
119 pub fn on_win<F>(&mut self, fun: F) -> &mut Self
120 where
121 F: ToFunction<OnWinArgs, DontSkipOnLines>,
122 {
123 self.0.on_win = Object::from_luaref(fun.into_luaref());
124 self
125 }
126
127 #[inline]
128 pub fn build(&mut self) -> DecorationProviderOpts {
129 std::mem::take(&mut self.0)
130 }
131}