1use futures::io::AsyncWrite;
5
6use crate::{
7 error::CallError,
8 neovim::*,
9 rpc::{unpack::TryUnpack, *},
10 Buffer, Tabpage, Window,
11};
12
13impl<W> Buffer<W>
14where
15 W: AsyncWrite + Send + Unpin + 'static,
16{
17 #[must_use]
18 pub fn new(code_data: Value, neovim: Neovim<W>) -> Buffer<W> {
19 Buffer { code_data, neovim }
20 }
21
22 #[must_use]
24 pub fn get_value(&self) -> &Value {
25 &self.code_data
26 }
27
28 pub async fn line_count(&self) -> Result<i64, Box<CallError>> {
30 self
31 .neovim
32 .call("nvim_buf_line_count", call_args![self.code_data.clone()])
33 .await??
34 .try_unpack()
35 .map_err(|v| Box::new(CallError::WrongValueType(v)))
36 }
37 pub async fn attach(
39 &self,
40 send_buffer: bool,
41 opts: Vec<(Value, Value)>,
42 ) -> Result<bool, Box<CallError>> {
43 self
44 .neovim
45 .call(
46 "nvim_buf_attach",
47 call_args![self.code_data.clone(), send_buffer, opts],
48 )
49 .await??
50 .try_unpack()
51 .map_err(|v| Box::new(CallError::WrongValueType(v)))
52 }
53 pub async fn detach(&self) -> Result<bool, Box<CallError>> {
55 self
56 .neovim
57 .call("nvim_buf_detach", call_args![self.code_data.clone()])
58 .await??
59 .try_unpack()
60 .map_err(|v| Box::new(CallError::WrongValueType(v)))
61 }
62 pub async fn get_lines(
64 &self,
65 start: i64,
66 end: i64,
67 strict_indexing: bool,
68 ) -> Result<Vec<String>, Box<CallError>> {
69 self
70 .neovim
71 .call(
72 "nvim_buf_get_lines",
73 call_args![self.code_data.clone(), start, end, strict_indexing],
74 )
75 .await??
76 .try_unpack()
77 .map_err(|v| Box::new(CallError::WrongValueType(v)))
78 }
79 pub async fn set_lines(
81 &self,
82 start: i64,
83 end: i64,
84 strict_indexing: bool,
85 replacement: Vec<String>,
86 ) -> Result<(), Box<CallError>> {
87 self
88 .neovim
89 .call(
90 "nvim_buf_set_lines",
91 call_args![
92 self.code_data.clone(),
93 start,
94 end,
95 strict_indexing,
96 replacement
97 ],
98 )
99 .await??
100 .try_unpack()
101 .map_err(|v| Box::new(CallError::WrongValueType(v)))
102 }
103 pub async fn set_text(
105 &self,
106 start_row: i64,
107 start_col: i64,
108 end_row: i64,
109 end_col: i64,
110 replacement: Vec<String>,
111 ) -> Result<(), Box<CallError>> {
112 self
113 .neovim
114 .call(
115 "nvim_buf_set_text",
116 call_args![
117 self.code_data.clone(),
118 start_row,
119 start_col,
120 end_row,
121 end_col,
122 replacement
123 ],
124 )
125 .await??
126 .try_unpack()
127 .map_err(|v| Box::new(CallError::WrongValueType(v)))
128 }
129 pub async fn get_text(
131 &self,
132 start_row: i64,
133 start_col: i64,
134 end_row: i64,
135 end_col: i64,
136 opts: Vec<(Value, Value)>,
137 ) -> Result<Vec<String>, Box<CallError>> {
138 self
139 .neovim
140 .call(
141 "nvim_buf_get_text",
142 call_args![
143 self.code_data.clone(),
144 start_row,
145 start_col,
146 end_row,
147 end_col,
148 opts
149 ],
150 )
151 .await??
152 .try_unpack()
153 .map_err(|v| Box::new(CallError::WrongValueType(v)))
154 }
155 pub async fn get_offset(&self, index: i64) -> Result<i64, Box<CallError>> {
157 self
158 .neovim
159 .call(
160 "nvim_buf_get_offset",
161 call_args![self.code_data.clone(), index],
162 )
163 .await??
164 .try_unpack()
165 .map_err(|v| Box::new(CallError::WrongValueType(v)))
166 }
167 pub async fn get_var(&self, name: &str) -> Result<Value, Box<CallError>> {
169 self
170 .neovim
171 .call("nvim_buf_get_var", call_args![self.code_data.clone(), name])
172 .await??
173 .try_unpack()
174 .map_err(|v| Box::new(CallError::WrongValueType(v)))
175 }
176 pub async fn get_changedtick(&self) -> Result<i64, Box<CallError>> {
178 self
179 .neovim
180 .call(
181 "nvim_buf_get_changedtick",
182 call_args![self.code_data.clone()],
183 )
184 .await??
185 .try_unpack()
186 .map_err(|v| Box::new(CallError::WrongValueType(v)))
187 }
188 pub async fn get_keymap(
190 &self,
191 mode: &str,
192 ) -> Result<Vec<Vec<(Value, Value)>>, Box<CallError>> {
193 self
194 .neovim
195 .call(
196 "nvim_buf_get_keymap",
197 call_args![self.code_data.clone(), mode],
198 )
199 .await??
200 .try_unpack()
201 .map_err(|v| Box::new(CallError::WrongValueType(v)))
202 }
203 pub async fn set_keymap(
205 &self,
206 mode: &str,
207 lhs: &str,
208 rhs: &str,
209 opts: Vec<(Value, Value)>,
210 ) -> Result<(), Box<CallError>> {
211 self
212 .neovim
213 .call(
214 "nvim_buf_set_keymap",
215 call_args![self.code_data.clone(), mode, lhs, rhs, opts],
216 )
217 .await??
218 .try_unpack()
219 .map_err(|v| Box::new(CallError::WrongValueType(v)))
220 }
221 pub async fn del_keymap(
223 &self,
224 mode: &str,
225 lhs: &str,
226 ) -> Result<(), Box<CallError>> {
227 self
228 .neovim
229 .call(
230 "nvim_buf_del_keymap",
231 call_args![self.code_data.clone(), mode, lhs],
232 )
233 .await??
234 .try_unpack()
235 .map_err(|v| Box::new(CallError::WrongValueType(v)))
236 }
237 pub async fn set_var(
239 &self,
240 name: &str,
241 value: Value,
242 ) -> Result<(), Box<CallError>> {
243 self
244 .neovim
245 .call(
246 "nvim_buf_set_var",
247 call_args![self.code_data.clone(), name, value],
248 )
249 .await??
250 .try_unpack()
251 .map_err(|v| Box::new(CallError::WrongValueType(v)))
252 }
253 pub async fn del_var(&self, name: &str) -> Result<(), Box<CallError>> {
255 self
256 .neovim
257 .call("nvim_buf_del_var", call_args![self.code_data.clone(), name])
258 .await??
259 .try_unpack()
260 .map_err(|v| Box::new(CallError::WrongValueType(v)))
261 }
262 pub async fn get_name(&self) -> Result<String, Box<CallError>> {
264 self
265 .neovim
266 .call("nvim_buf_get_name", call_args![self.code_data.clone()])
267 .await??
268 .try_unpack()
269 .map_err(|v| Box::new(CallError::WrongValueType(v)))
270 }
271 pub async fn set_name(&self, name: &str) -> Result<(), Box<CallError>> {
273 self
274 .neovim
275 .call(
276 "nvim_buf_set_name",
277 call_args![self.code_data.clone(), name],
278 )
279 .await??
280 .try_unpack()
281 .map_err(|v| Box::new(CallError::WrongValueType(v)))
282 }
283 pub async fn is_loaded(&self) -> Result<bool, Box<CallError>> {
285 self
286 .neovim
287 .call("nvim_buf_is_loaded", call_args![self.code_data.clone()])
288 .await??
289 .try_unpack()
290 .map_err(|v| Box::new(CallError::WrongValueType(v)))
291 }
292 pub async fn delete(
294 &self,
295 opts: Vec<(Value, Value)>,
296 ) -> Result<(), Box<CallError>> {
297 self
298 .neovim
299 .call("nvim_buf_delete", call_args![self.code_data.clone(), opts])
300 .await??
301 .try_unpack()
302 .map_err(|v| Box::new(CallError::WrongValueType(v)))
303 }
304 pub async fn is_valid(&self) -> Result<bool, Box<CallError>> {
306 self
307 .neovim
308 .call("nvim_buf_is_valid", call_args![self.code_data.clone()])
309 .await??
310 .try_unpack()
311 .map_err(|v| Box::new(CallError::WrongValueType(v)))
312 }
313 pub async fn del_mark(&self, name: &str) -> Result<bool, Box<CallError>> {
315 self
316 .neovim
317 .call(
318 "nvim_buf_del_mark",
319 call_args![self.code_data.clone(), name],
320 )
321 .await??
322 .try_unpack()
323 .map_err(|v| Box::new(CallError::WrongValueType(v)))
324 }
325 pub async fn set_mark(
327 &self,
328 name: &str,
329 line: i64,
330 col: i64,
331 opts: Vec<(Value, Value)>,
332 ) -> Result<bool, Box<CallError>> {
333 self
334 .neovim
335 .call(
336 "nvim_buf_set_mark",
337 call_args![self.code_data.clone(), name, line, col, opts],
338 )
339 .await??
340 .try_unpack()
341 .map_err(|v| Box::new(CallError::WrongValueType(v)))
342 }
343 pub async fn get_mark(
345 &self,
346 name: &str,
347 ) -> Result<(i64, i64), Box<CallError>> {
348 self
349 .neovim
350 .call(
351 "nvim_buf_get_mark",
352 call_args![self.code_data.clone(), name],
353 )
354 .await??
355 .try_unpack()
356 .map_err(|v| Box::new(CallError::WrongValueType(v)))
357 }
358 pub async fn create_user_command(
360 &self,
361 name: &str,
362 command: Value,
363 opts: Vec<(Value, Value)>,
364 ) -> Result<(), Box<CallError>> {
365 self
366 .neovim
367 .call(
368 "nvim_buf_create_user_command",
369 call_args![self.code_data.clone(), name, command, opts],
370 )
371 .await??
372 .try_unpack()
373 .map_err(|v| Box::new(CallError::WrongValueType(v)))
374 }
375 pub async fn del_user_command(
377 &self,
378 name: &str,
379 ) -> Result<(), Box<CallError>> {
380 self
381 .neovim
382 .call(
383 "nvim_buf_del_user_command",
384 call_args![self.code_data.clone(), name],
385 )
386 .await??
387 .try_unpack()
388 .map_err(|v| Box::new(CallError::WrongValueType(v)))
389 }
390 pub async fn get_commands(
392 &self,
393 opts: Vec<(Value, Value)>,
394 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
395 self
396 .neovim
397 .call(
398 "nvim_buf_get_commands",
399 call_args![self.code_data.clone(), opts],
400 )
401 .await??
402 .try_unpack()
403 .map_err(|v| Box::new(CallError::WrongValueType(v)))
404 }
405 pub async fn get_number(&self) -> Result<i64, Box<CallError>> {
407 self
408 .neovim
409 .call("nvim_buf_get_number", call_args![self.code_data.clone()])
410 .await??
411 .try_unpack()
412 .map_err(|v| Box::new(CallError::WrongValueType(v)))
413 }
414 pub async fn clear_highlight(
416 &self,
417 ns_id: i64,
418 line_start: i64,
419 line_end: i64,
420 ) -> Result<(), Box<CallError>> {
421 self
422 .neovim
423 .call(
424 "nvim_buf_clear_highlight",
425 call_args![self.code_data.clone(), ns_id, line_start, line_end],
426 )
427 .await??
428 .try_unpack()
429 .map_err(|v| Box::new(CallError::WrongValueType(v)))
430 }
431 pub async fn add_highlight(
433 &self,
434 ns_id: i64,
435 hl_group: &str,
436 line: i64,
437 col_start: i64,
438 col_end: i64,
439 ) -> Result<i64, Box<CallError>> {
440 self
441 .neovim
442 .call(
443 "nvim_buf_add_highlight",
444 call_args![
445 self.code_data.clone(),
446 ns_id,
447 hl_group,
448 line,
449 col_start,
450 col_end
451 ],
452 )
453 .await??
454 .try_unpack()
455 .map_err(|v| Box::new(CallError::WrongValueType(v)))
456 }
457 pub async fn set_virtual_text(
459 &self,
460 src_id: i64,
461 line: i64,
462 chunks: Vec<Value>,
463 opts: Vec<(Value, Value)>,
464 ) -> Result<i64, Box<CallError>> {
465 self
466 .neovim
467 .call(
468 "nvim_buf_set_virtual_text",
469 call_args![self.code_data.clone(), src_id, line, chunks, opts],
470 )
471 .await??
472 .try_unpack()
473 .map_err(|v| Box::new(CallError::WrongValueType(v)))
474 }
475 pub async fn get_option(&self, name: &str) -> Result<Value, Box<CallError>> {
477 self
478 .neovim
479 .call(
480 "nvim_buf_get_option",
481 call_args![self.code_data.clone(), name],
482 )
483 .await??
484 .try_unpack()
485 .map_err(|v| Box::new(CallError::WrongValueType(v)))
486 }
487 pub async fn set_option(
489 &self,
490 name: &str,
491 value: Value,
492 ) -> Result<(), Box<CallError>> {
493 self
494 .neovim
495 .call(
496 "nvim_buf_set_option",
497 call_args![self.code_data.clone(), name, value],
498 )
499 .await??
500 .try_unpack()
501 .map_err(|v| Box::new(CallError::WrongValueType(v)))
502 }
503 pub async fn get_extmark_by_id(
505 &self,
506 ns_id: i64,
507 id: i64,
508 opts: Vec<(Value, Value)>,
509 ) -> Result<Vec<i64>, Box<CallError>> {
510 self
511 .neovim
512 .call(
513 "nvim_buf_get_extmark_by_id",
514 call_args![self.code_data.clone(), ns_id, id, opts],
515 )
516 .await??
517 .try_unpack()
518 .map_err(|v| Box::new(CallError::WrongValueType(v)))
519 }
520 pub async fn get_extmarks(
522 &self,
523 ns_id: i64,
524 start: Value,
525 end: Value,
526 opts: Vec<(Value, Value)>,
527 ) -> Result<Vec<Value>, Box<CallError>> {
528 self
529 .neovim
530 .call(
531 "nvim_buf_get_extmarks",
532 call_args![self.code_data.clone(), ns_id, start, end, opts],
533 )
534 .await??
535 .try_unpack()
536 .map_err(|v| Box::new(CallError::WrongValueType(v)))
537 }
538 pub async fn set_extmark(
540 &self,
541 ns_id: i64,
542 line: i64,
543 col: i64,
544 opts: Vec<(Value, Value)>,
545 ) -> Result<i64, Box<CallError>> {
546 self
547 .neovim
548 .call(
549 "nvim_buf_set_extmark",
550 call_args![self.code_data.clone(), ns_id, line, col, opts],
551 )
552 .await??
553 .try_unpack()
554 .map_err(|v| Box::new(CallError::WrongValueType(v)))
555 }
556 pub async fn del_extmark(
558 &self,
559 ns_id: i64,
560 id: i64,
561 ) -> Result<bool, Box<CallError>> {
562 self
563 .neovim
564 .call(
565 "nvim_buf_del_extmark",
566 call_args![self.code_data.clone(), ns_id, id],
567 )
568 .await??
569 .try_unpack()
570 .map_err(|v| Box::new(CallError::WrongValueType(v)))
571 }
572 pub async fn clear_namespace(
574 &self,
575 ns_id: i64,
576 line_start: i64,
577 line_end: i64,
578 ) -> Result<(), Box<CallError>> {
579 self
580 .neovim
581 .call(
582 "nvim_buf_clear_namespace",
583 call_args![self.code_data.clone(), ns_id, line_start, line_end],
584 )
585 .await??
586 .try_unpack()
587 .map_err(|v| Box::new(CallError::WrongValueType(v)))
588 }
589}
590
591impl<W> Window<W>
592where
593 W: AsyncWrite + Send + Unpin + 'static,
594{
595 #[must_use]
596 pub fn new(code_data: Value, neovim: Neovim<W>) -> Window<W> {
597 Window { code_data, neovim }
598 }
599
600 #[must_use]
602 pub fn get_value(&self) -> &Value {
603 &self.code_data
604 }
605
606 pub async fn get_option(&self, name: &str) -> Result<Value, Box<CallError>> {
608 self
609 .neovim
610 .call(
611 "nvim_win_get_option",
612 call_args![self.code_data.clone(), name],
613 )
614 .await??
615 .try_unpack()
616 .map_err(|v| Box::new(CallError::WrongValueType(v)))
617 }
618 pub async fn set_option(
620 &self,
621 name: &str,
622 value: Value,
623 ) -> Result<(), Box<CallError>> {
624 self
625 .neovim
626 .call(
627 "nvim_win_set_option",
628 call_args![self.code_data.clone(), name, value],
629 )
630 .await??
631 .try_unpack()
632 .map_err(|v| Box::new(CallError::WrongValueType(v)))
633 }
634 pub async fn set_config(
636 &self,
637 config: Vec<(Value, Value)>,
638 ) -> Result<(), Box<CallError>> {
639 self
640 .neovim
641 .call(
642 "nvim_win_set_config",
643 call_args![self.code_data.clone(), config],
644 )
645 .await??
646 .try_unpack()
647 .map_err(|v| Box::new(CallError::WrongValueType(v)))
648 }
649 pub async fn get_config(
651 &self,
652 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
653 self
654 .neovim
655 .call("nvim_win_get_config", call_args![self.code_data.clone()])
656 .await??
657 .try_unpack()
658 .map_err(|v| Box::new(CallError::WrongValueType(v)))
659 }
660 pub async fn set_buf(
662 &self,
663 buffer: &Buffer<W>,
664 ) -> Result<(), Box<CallError>> {
665 self
666 .neovim
667 .call(
668 "nvim_win_set_buf",
669 call_args![self.code_data.clone(), buffer],
670 )
671 .await??
672 .try_unpack()
673 .map_err(|v| Box::new(CallError::WrongValueType(v)))
674 }
675 pub async fn get_cursor(&self) -> Result<(i64, i64), Box<CallError>> {
677 self
678 .neovim
679 .call("nvim_win_get_cursor", call_args![self.code_data.clone()])
680 .await??
681 .try_unpack()
682 .map_err(|v| Box::new(CallError::WrongValueType(v)))
683 }
684 pub async fn set_cursor(
686 &self,
687 pos: (i64, i64),
688 ) -> Result<(), Box<CallError>> {
689 self
690 .neovim
691 .call(
692 "nvim_win_set_cursor",
693 call_args![self.code_data.clone(), pos],
694 )
695 .await??
696 .try_unpack()
697 .map_err(|v| Box::new(CallError::WrongValueType(v)))
698 }
699 pub async fn get_height(&self) -> Result<i64, Box<CallError>> {
701 self
702 .neovim
703 .call("nvim_win_get_height", call_args![self.code_data.clone()])
704 .await??
705 .try_unpack()
706 .map_err(|v| Box::new(CallError::WrongValueType(v)))
707 }
708 pub async fn set_height(&self, height: i64) -> Result<(), Box<CallError>> {
710 self
711 .neovim
712 .call(
713 "nvim_win_set_height",
714 call_args![self.code_data.clone(), height],
715 )
716 .await??
717 .try_unpack()
718 .map_err(|v| Box::new(CallError::WrongValueType(v)))
719 }
720 pub async fn get_width(&self) -> Result<i64, Box<CallError>> {
722 self
723 .neovim
724 .call("nvim_win_get_width", call_args![self.code_data.clone()])
725 .await??
726 .try_unpack()
727 .map_err(|v| Box::new(CallError::WrongValueType(v)))
728 }
729 pub async fn set_width(&self, width: i64) -> Result<(), Box<CallError>> {
731 self
732 .neovim
733 .call(
734 "nvim_win_set_width",
735 call_args![self.code_data.clone(), width],
736 )
737 .await??
738 .try_unpack()
739 .map_err(|v| Box::new(CallError::WrongValueType(v)))
740 }
741 pub async fn get_var(&self, name: &str) -> Result<Value, Box<CallError>> {
743 self
744 .neovim
745 .call("nvim_win_get_var", call_args![self.code_data.clone(), name])
746 .await??
747 .try_unpack()
748 .map_err(|v| Box::new(CallError::WrongValueType(v)))
749 }
750 pub async fn set_var(
752 &self,
753 name: &str,
754 value: Value,
755 ) -> Result<(), Box<CallError>> {
756 self
757 .neovim
758 .call(
759 "nvim_win_set_var",
760 call_args![self.code_data.clone(), name, value],
761 )
762 .await??
763 .try_unpack()
764 .map_err(|v| Box::new(CallError::WrongValueType(v)))
765 }
766 pub async fn del_var(&self, name: &str) -> Result<(), Box<CallError>> {
768 self
769 .neovim
770 .call("nvim_win_del_var", call_args![self.code_data.clone(), name])
771 .await??
772 .try_unpack()
773 .map_err(|v| Box::new(CallError::WrongValueType(v)))
774 }
775 pub async fn get_position(&self) -> Result<(i64, i64), Box<CallError>> {
777 self
778 .neovim
779 .call("nvim_win_get_position", call_args![self.code_data.clone()])
780 .await??
781 .try_unpack()
782 .map_err(|v| Box::new(CallError::WrongValueType(v)))
783 }
784 pub async fn get_number(&self) -> Result<i64, Box<CallError>> {
786 self
787 .neovim
788 .call("nvim_win_get_number", call_args![self.code_data.clone()])
789 .await??
790 .try_unpack()
791 .map_err(|v| Box::new(CallError::WrongValueType(v)))
792 }
793 pub async fn is_valid(&self) -> Result<bool, Box<CallError>> {
795 self
796 .neovim
797 .call("nvim_win_is_valid", call_args![self.code_data.clone()])
798 .await??
799 .try_unpack()
800 .map_err(|v| Box::new(CallError::WrongValueType(v)))
801 }
802 pub async fn hide(&self) -> Result<(), Box<CallError>> {
804 self
805 .neovim
806 .call("nvim_win_hide", call_args![self.code_data.clone()])
807 .await??
808 .try_unpack()
809 .map_err(|v| Box::new(CallError::WrongValueType(v)))
810 }
811 pub async fn close(&self, force: bool) -> Result<(), Box<CallError>> {
813 self
814 .neovim
815 .call("nvim_win_close", call_args![self.code_data.clone(), force])
816 .await??
817 .try_unpack()
818 .map_err(|v| Box::new(CallError::WrongValueType(v)))
819 }
820 pub async fn set_hl_ns(&self, ns_id: i64) -> Result<(), Box<CallError>> {
822 self
823 .neovim
824 .call(
825 "nvim_win_set_hl_ns",
826 call_args![self.code_data.clone(), ns_id],
827 )
828 .await??
829 .try_unpack()
830 .map_err(|v| Box::new(CallError::WrongValueType(v)))
831 }
832 pub async fn text_height(
834 &self,
835 opts: Vec<(Value, Value)>,
836 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
837 self
838 .neovim
839 .call(
840 "nvim_win_text_height",
841 call_args![self.code_data.clone(), opts],
842 )
843 .await??
844 .try_unpack()
845 .map_err(|v| Box::new(CallError::WrongValueType(v)))
846 }
847}
848
849impl<W> Tabpage<W>
850where
851 W: AsyncWrite + Send + Unpin + 'static,
852{
853 #[must_use]
854 pub fn new(code_data: Value, neovim: Neovim<W>) -> Tabpage<W> {
855 Tabpage { code_data, neovim }
856 }
857
858 #[must_use]
860 pub fn get_value(&self) -> &Value {
861 &self.code_data
862 }
863
864 pub async fn get_var(&self, name: &str) -> Result<Value, Box<CallError>> {
866 self
867 .neovim
868 .call(
869 "nvim_tabpage_get_var",
870 call_args![self.code_data.clone(), name],
871 )
872 .await??
873 .try_unpack()
874 .map_err(|v| Box::new(CallError::WrongValueType(v)))
875 }
876 pub async fn set_var(
878 &self,
879 name: &str,
880 value: Value,
881 ) -> Result<(), Box<CallError>> {
882 self
883 .neovim
884 .call(
885 "nvim_tabpage_set_var",
886 call_args![self.code_data.clone(), name, value],
887 )
888 .await??
889 .try_unpack()
890 .map_err(|v| Box::new(CallError::WrongValueType(v)))
891 }
892 pub async fn del_var(&self, name: &str) -> Result<(), Box<CallError>> {
894 self
895 .neovim
896 .call(
897 "nvim_tabpage_del_var",
898 call_args![self.code_data.clone(), name],
899 )
900 .await??
901 .try_unpack()
902 .map_err(|v| Box::new(CallError::WrongValueType(v)))
903 }
904 pub async fn set_win(&self, win: &Window<W>) -> Result<(), Box<CallError>> {
906 self
907 .neovim
908 .call(
909 "nvim_tabpage_set_win",
910 call_args![self.code_data.clone(), win],
911 )
912 .await??
913 .try_unpack()
914 .map_err(|v| Box::new(CallError::WrongValueType(v)))
915 }
916 pub async fn get_number(&self) -> Result<i64, Box<CallError>> {
918 self
919 .neovim
920 .call(
921 "nvim_tabpage_get_number",
922 call_args![self.code_data.clone()],
923 )
924 .await??
925 .try_unpack()
926 .map_err(|v| Box::new(CallError::WrongValueType(v)))
927 }
928 pub async fn is_valid(&self) -> Result<bool, Box<CallError>> {
930 self
931 .neovim
932 .call("nvim_tabpage_is_valid", call_args![self.code_data.clone()])
933 .await??
934 .try_unpack()
935 .map_err(|v| Box::new(CallError::WrongValueType(v)))
936 }
937}
938
939impl<W> Neovim<W>
940where
941 W: AsyncWrite + Send + Unpin + 'static,
942{
943 pub async fn get_autocmds(
944 &self,
945 opts: Vec<(Value, Value)>,
946 ) -> Result<Vec<Value>, Box<CallError>> {
947 self
948 .call("nvim_get_autocmds", call_args![opts])
949 .await??
950 .try_unpack()
951 .map_err(|v| Box::new(CallError::WrongValueType(v)))
952 }
953
954 pub async fn create_autocmd(
955 &self,
956 event: Value,
957 opts: Vec<(Value, Value)>,
958 ) -> Result<i64, Box<CallError>> {
959 self
960 .call("nvim_create_autocmd", call_args![event, opts])
961 .await??
962 .try_unpack()
963 .map_err(|v| Box::new(CallError::WrongValueType(v)))
964 }
965
966 pub async fn del_autocmd(&self, id: i64) -> Result<(), Box<CallError>> {
967 self
968 .call("nvim_del_autocmd", call_args![id])
969 .await??
970 .try_unpack()
971 .map_err(|v| Box::new(CallError::WrongValueType(v)))
972 }
973
974 pub async fn clear_autocmds(
975 &self,
976 opts: Vec<(Value, Value)>,
977 ) -> Result<(), Box<CallError>> {
978 self
979 .call("nvim_clear_autocmds", call_args![opts])
980 .await??
981 .try_unpack()
982 .map_err(|v| Box::new(CallError::WrongValueType(v)))
983 }
984
985 pub async fn create_augroup(
986 &self,
987 name: &str,
988 opts: Vec<(Value, Value)>,
989 ) -> Result<i64, Box<CallError>> {
990 self
991 .call("nvim_create_augroup", call_args![name, opts])
992 .await??
993 .try_unpack()
994 .map_err(|v| Box::new(CallError::WrongValueType(v)))
995 }
996
997 pub async fn del_augroup_by_id(&self, id: i64) -> Result<(), Box<CallError>> {
998 self
999 .call("nvim_del_augroup_by_id", call_args![id])
1000 .await??
1001 .try_unpack()
1002 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1003 }
1004
1005 pub async fn del_augroup_by_name(
1006 &self,
1007 name: &str,
1008 ) -> Result<(), Box<CallError>> {
1009 self
1010 .call("nvim_del_augroup_by_name", call_args![name])
1011 .await??
1012 .try_unpack()
1013 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1014 }
1015
1016 pub async fn exec_autocmds(
1017 &self,
1018 event: Value,
1019 opts: Vec<(Value, Value)>,
1020 ) -> Result<(), Box<CallError>> {
1021 self
1022 .call("nvim_exec_autocmds", call_args![event, opts])
1023 .await??
1024 .try_unpack()
1025 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1026 }
1027
1028 pub async fn parse_cmd(
1029 &self,
1030 str: &str,
1031 opts: Vec<(Value, Value)>,
1032 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1033 self
1034 .call("nvim_parse_cmd", call_args![str, opts])
1035 .await??
1036 .try_unpack()
1037 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1038 }
1039
1040 pub async fn cmd(
1041 &self,
1042 cmd: Vec<(Value, Value)>,
1043 opts: Vec<(Value, Value)>,
1044 ) -> Result<String, Box<CallError>> {
1045 self
1046 .call("nvim_cmd", call_args![cmd, opts])
1047 .await??
1048 .try_unpack()
1049 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1050 }
1051
1052 pub async fn create_user_command(
1053 &self,
1054 name: &str,
1055 command: Value,
1056 opts: Vec<(Value, Value)>,
1057 ) -> Result<(), Box<CallError>> {
1058 self
1059 .call("nvim_create_user_command", call_args![name, command, opts])
1060 .await??
1061 .try_unpack()
1062 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1063 }
1064
1065 pub async fn del_user_command(
1066 &self,
1067 name: &str,
1068 ) -> Result<(), Box<CallError>> {
1069 self
1070 .call("nvim_del_user_command", call_args![name])
1071 .await??
1072 .try_unpack()
1073 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1074 }
1075
1076 pub async fn get_commands(
1077 &self,
1078 opts: Vec<(Value, Value)>,
1079 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1080 self
1081 .call("nvim_get_commands", call_args![opts])
1082 .await??
1083 .try_unpack()
1084 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1085 }
1086
1087 pub async fn exec(
1088 &self,
1089 src: &str,
1090 output: bool,
1091 ) -> Result<String, Box<CallError>> {
1092 self
1093 .call("nvim_exec", call_args![src, output])
1094 .await??
1095 .try_unpack()
1096 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1097 }
1098
1099 pub async fn command_output(
1100 &self,
1101 command: &str,
1102 ) -> Result<String, Box<CallError>> {
1103 self
1104 .call("nvim_command_output", call_args![command])
1105 .await??
1106 .try_unpack()
1107 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1108 }
1109
1110 pub async fn execute_lua(
1111 &self,
1112 code: &str,
1113 args: Vec<Value>,
1114 ) -> Result<Value, Box<CallError>> {
1115 self
1116 .call("nvim_execute_lua", call_args![code, args])
1117 .await??
1118 .try_unpack()
1119 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1120 }
1121
1122 pub async fn get_hl_by_id(
1123 &self,
1124 hl_id: i64,
1125 rgb: bool,
1126 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1127 self
1128 .call("nvim_get_hl_by_id", call_args![hl_id, rgb])
1129 .await??
1130 .try_unpack()
1131 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1132 }
1133
1134 pub async fn get_hl_by_name(
1135 &self,
1136 name: &str,
1137 rgb: bool,
1138 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1139 self
1140 .call("nvim_get_hl_by_name", call_args![name, rgb])
1141 .await??
1142 .try_unpack()
1143 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1144 }
1145
1146 pub async fn get_option_info(
1147 &self,
1148 name: &str,
1149 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1150 self
1151 .call("nvim_get_option_info", call_args![name])
1152 .await??
1153 .try_unpack()
1154 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1155 }
1156
1157 pub async fn set_option(
1158 &self,
1159 name: &str,
1160 value: Value,
1161 ) -> Result<(), Box<CallError>> {
1162 self
1163 .call("nvim_set_option", call_args![name, value])
1164 .await??
1165 .try_unpack()
1166 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1167 }
1168
1169 pub async fn get_option(&self, name: &str) -> Result<Value, Box<CallError>> {
1170 self
1171 .call("nvim_get_option", call_args![name])
1172 .await??
1173 .try_unpack()
1174 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1175 }
1176
1177 pub async fn call_atomic(
1178 &self,
1179 calls: Vec<Value>,
1180 ) -> Result<Vec<Value>, Box<CallError>> {
1181 self
1182 .call("nvim_call_atomic", call_args![calls])
1183 .await??
1184 .try_unpack()
1185 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1186 }
1187
1188 pub async fn subscribe(&self, event: &str) -> Result<(), Box<CallError>> {
1189 self
1190 .call("nvim_subscribe", call_args![event])
1191 .await??
1192 .try_unpack()
1193 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1194 }
1195
1196 pub async fn unsubscribe(&self, event: &str) -> Result<(), Box<CallError>> {
1197 self
1198 .call("nvim_unsubscribe", call_args![event])
1199 .await??
1200 .try_unpack()
1201 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1202 }
1203
1204 pub async fn out_write(&self, str: &str) -> Result<(), Box<CallError>> {
1205 self
1206 .call("nvim_out_write", call_args![str])
1207 .await??
1208 .try_unpack()
1209 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1210 }
1211
1212 pub async fn err_write(&self, str: &str) -> Result<(), Box<CallError>> {
1213 self
1214 .call("nvim_err_write", call_args![str])
1215 .await??
1216 .try_unpack()
1217 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1218 }
1219
1220 pub async fn err_writeln(&self, str: &str) -> Result<(), Box<CallError>> {
1221 self
1222 .call("nvim_err_writeln", call_args![str])
1223 .await??
1224 .try_unpack()
1225 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1226 }
1227
1228 pub async fn notify(
1229 &self,
1230 msg: &str,
1231 log_level: i64,
1232 opts: Vec<(Value, Value)>,
1233 ) -> Result<Value, Box<CallError>> {
1234 self
1235 .call("nvim_notify", call_args![msg, log_level, opts])
1236 .await??
1237 .try_unpack()
1238 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1239 }
1240
1241 pub async fn create_namespace(
1242 &self,
1243 name: &str,
1244 ) -> Result<i64, Box<CallError>> {
1245 self
1246 .call("nvim_create_namespace", call_args![name])
1247 .await??
1248 .try_unpack()
1249 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1250 }
1251
1252 pub async fn get_namespaces(
1253 &self,
1254 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1255 self
1256 .call("nvim_get_namespaces", call_args![])
1257 .await??
1258 .try_unpack()
1259 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1260 }
1261
1262 pub async fn set_decoration_provider(
1263 &self,
1264 ns_id: i64,
1265 opts: Vec<(Value, Value)>,
1266 ) -> Result<(), Box<CallError>> {
1267 self
1268 .call("nvim_set_decoration_provider", call_args![ns_id, opts])
1269 .await??
1270 .try_unpack()
1271 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1272 }
1273
1274 pub async fn get_option_value(
1275 &self,
1276 name: &str,
1277 opts: Vec<(Value, Value)>,
1278 ) -> Result<Value, Box<CallError>> {
1279 self
1280 .call("nvim_get_option_value", call_args![name, opts])
1281 .await??
1282 .try_unpack()
1283 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1284 }
1285
1286 pub async fn set_option_value(
1287 &self,
1288 name: &str,
1289 value: Value,
1290 opts: Vec<(Value, Value)>,
1291 ) -> Result<(), Box<CallError>> {
1292 self
1293 .call("nvim_set_option_value", call_args![name, value, opts])
1294 .await??
1295 .try_unpack()
1296 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1297 }
1298
1299 pub async fn get_all_options_info(
1300 &self,
1301 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1302 self
1303 .call("nvim_get_all_options_info", call_args![])
1304 .await??
1305 .try_unpack()
1306 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1307 }
1308
1309 pub async fn get_option_info2(
1310 &self,
1311 name: &str,
1312 opts: Vec<(Value, Value)>,
1313 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1314 self
1315 .call("nvim_get_option_info2", call_args![name, opts])
1316 .await??
1317 .try_unpack()
1318 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1319 }
1320
1321 pub async fn ui_set_focus(&self, gained: bool) -> Result<(), Box<CallError>> {
1322 self
1323 .call("nvim_ui_set_focus", call_args![gained])
1324 .await??
1325 .try_unpack()
1326 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1327 }
1328
1329 pub async fn ui_detach(&self) -> Result<(), Box<CallError>> {
1330 self
1331 .call("nvim_ui_detach", call_args![])
1332 .await??
1333 .try_unpack()
1334 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1335 }
1336
1337 pub async fn ui_try_resize(
1338 &self,
1339 width: i64,
1340 height: i64,
1341 ) -> Result<(), Box<CallError>> {
1342 self
1343 .call("nvim_ui_try_resize", call_args![width, height])
1344 .await??
1345 .try_unpack()
1346 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1347 }
1348
1349 pub async fn ui_set_option(
1350 &self,
1351 name: &str,
1352 value: Value,
1353 ) -> Result<(), Box<CallError>> {
1354 self
1355 .call("nvim_ui_set_option", call_args![name, value])
1356 .await??
1357 .try_unpack()
1358 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1359 }
1360
1361 pub async fn ui_try_resize_grid(
1362 &self,
1363 grid: i64,
1364 width: i64,
1365 height: i64,
1366 ) -> Result<(), Box<CallError>> {
1367 self
1368 .call("nvim_ui_try_resize_grid", call_args![grid, width, height])
1369 .await??
1370 .try_unpack()
1371 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1372 }
1373
1374 pub async fn ui_pum_set_height(
1375 &self,
1376 height: i64,
1377 ) -> Result<(), Box<CallError>> {
1378 self
1379 .call("nvim_ui_pum_set_height", call_args![height])
1380 .await??
1381 .try_unpack()
1382 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1383 }
1384
1385 pub async fn ui_pum_set_bounds(
1386 &self,
1387 width: f64,
1388 height: f64,
1389 row: f64,
1390 col: f64,
1391 ) -> Result<(), Box<CallError>> {
1392 self
1393 .call(
1394 "nvim_ui_pum_set_bounds",
1395 call_args![width, height, row, col],
1396 )
1397 .await??
1398 .try_unpack()
1399 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1400 }
1401
1402 pub async fn ui_term_event(
1403 &self,
1404 event: &str,
1405 value: Value,
1406 ) -> Result<(), Box<CallError>> {
1407 self
1408 .call("nvim_ui_term_event", call_args![event, value])
1409 .await??
1410 .try_unpack()
1411 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1412 }
1413
1414 pub async fn get_hl_id_by_name(
1415 &self,
1416 name: &str,
1417 ) -> Result<i64, Box<CallError>> {
1418 self
1419 .call("nvim_get_hl_id_by_name", call_args![name])
1420 .await??
1421 .try_unpack()
1422 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1423 }
1424
1425 pub async fn get_hl(
1426 &self,
1427 ns_id: i64,
1428 opts: Vec<(Value, Value)>,
1429 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1430 self
1431 .call("nvim_get_hl", call_args![ns_id, opts])
1432 .await??
1433 .try_unpack()
1434 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1435 }
1436
1437 pub async fn set_hl(
1438 &self,
1439 ns_id: i64,
1440 name: &str,
1441 val: Vec<(Value, Value)>,
1442 ) -> Result<(), Box<CallError>> {
1443 self
1444 .call("nvim_set_hl", call_args![ns_id, name, val])
1445 .await??
1446 .try_unpack()
1447 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1448 }
1449
1450 pub async fn get_hl_ns(
1451 &self,
1452 opts: Vec<(Value, Value)>,
1453 ) -> Result<i64, Box<CallError>> {
1454 self
1455 .call("nvim_get_hl_ns", call_args![opts])
1456 .await??
1457 .try_unpack()
1458 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1459 }
1460
1461 pub async fn set_hl_ns(&self, ns_id: i64) -> Result<(), Box<CallError>> {
1462 self
1463 .call("nvim_set_hl_ns", call_args![ns_id])
1464 .await??
1465 .try_unpack()
1466 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1467 }
1468
1469 pub async fn set_hl_ns_fast(&self, ns_id: i64) -> Result<(), Box<CallError>> {
1470 self
1471 .call("nvim_set_hl_ns_fast", call_args![ns_id])
1472 .await??
1473 .try_unpack()
1474 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1475 }
1476
1477 pub async fn feedkeys(
1478 &self,
1479 keys: &str,
1480 mode: &str,
1481 escape_ks: bool,
1482 ) -> Result<(), Box<CallError>> {
1483 self
1484 .call("nvim_feedkeys", call_args![keys, mode, escape_ks])
1485 .await??
1486 .try_unpack()
1487 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1488 }
1489
1490 pub async fn input(&self, keys: &str) -> Result<i64, Box<CallError>> {
1491 self
1492 .call("nvim_input", call_args![keys])
1493 .await??
1494 .try_unpack()
1495 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1496 }
1497
1498 pub async fn input_mouse(
1499 &self,
1500 button: &str,
1501 action: &str,
1502 modifier: &str,
1503 grid: i64,
1504 row: i64,
1505 col: i64,
1506 ) -> Result<(), Box<CallError>> {
1507 self
1508 .call(
1509 "nvim_input_mouse",
1510 call_args![button, action, modifier, grid, row, col],
1511 )
1512 .await??
1513 .try_unpack()
1514 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1515 }
1516
1517 pub async fn replace_termcodes(
1518 &self,
1519 str: &str,
1520 from_part: bool,
1521 do_lt: bool,
1522 special: bool,
1523 ) -> Result<String, Box<CallError>> {
1524 self
1525 .call(
1526 "nvim_replace_termcodes",
1527 call_args![str, from_part, do_lt, special],
1528 )
1529 .await??
1530 .try_unpack()
1531 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1532 }
1533
1534 pub async fn exec_lua(
1535 &self,
1536 code: &str,
1537 args: Vec<Value>,
1538 ) -> Result<Value, Box<CallError>> {
1539 self
1540 .call("nvim_exec_lua", call_args![code, args])
1541 .await??
1542 .try_unpack()
1543 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1544 }
1545
1546 pub async fn strwidth(&self, text: &str) -> Result<i64, Box<CallError>> {
1547 self
1548 .call("nvim_strwidth", call_args![text])
1549 .await??
1550 .try_unpack()
1551 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1552 }
1553
1554 pub async fn list_runtime_paths(
1555 &self,
1556 ) -> Result<Vec<String>, Box<CallError>> {
1557 self
1558 .call("nvim_list_runtime_paths", call_args![])
1559 .await??
1560 .try_unpack()
1561 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1562 }
1563
1564 pub async fn get_runtime_file(
1565 &self,
1566 name: &str,
1567 all: bool,
1568 ) -> Result<Vec<String>, Box<CallError>> {
1569 self
1570 .call("nvim_get_runtime_file", call_args![name, all])
1571 .await??
1572 .try_unpack()
1573 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1574 }
1575
1576 pub async fn set_current_dir(&self, dir: &str) -> Result<(), Box<CallError>> {
1577 self
1578 .call("nvim_set_current_dir", call_args![dir])
1579 .await??
1580 .try_unpack()
1581 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1582 }
1583
1584 pub async fn get_current_line(&self) -> Result<String, Box<CallError>> {
1585 self
1586 .call("nvim_get_current_line", call_args![])
1587 .await??
1588 .try_unpack()
1589 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1590 }
1591
1592 pub async fn set_current_line(
1593 &self,
1594 line: &str,
1595 ) -> Result<(), Box<CallError>> {
1596 self
1597 .call("nvim_set_current_line", call_args![line])
1598 .await??
1599 .try_unpack()
1600 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1601 }
1602
1603 pub async fn del_current_line(&self) -> Result<(), Box<CallError>> {
1604 self
1605 .call("nvim_del_current_line", call_args![])
1606 .await??
1607 .try_unpack()
1608 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1609 }
1610
1611 pub async fn get_var(&self, name: &str) -> Result<Value, Box<CallError>> {
1612 self
1613 .call("nvim_get_var", call_args![name])
1614 .await??
1615 .try_unpack()
1616 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1617 }
1618
1619 pub async fn set_var(
1620 &self,
1621 name: &str,
1622 value: Value,
1623 ) -> Result<(), Box<CallError>> {
1624 self
1625 .call("nvim_set_var", call_args![name, value])
1626 .await??
1627 .try_unpack()
1628 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1629 }
1630
1631 pub async fn del_var(&self, name: &str) -> Result<(), Box<CallError>> {
1632 self
1633 .call("nvim_del_var", call_args![name])
1634 .await??
1635 .try_unpack()
1636 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1637 }
1638
1639 pub async fn get_vvar(&self, name: &str) -> Result<Value, Box<CallError>> {
1640 self
1641 .call("nvim_get_vvar", call_args![name])
1642 .await??
1643 .try_unpack()
1644 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1645 }
1646
1647 pub async fn set_vvar(
1648 &self,
1649 name: &str,
1650 value: Value,
1651 ) -> Result<(), Box<CallError>> {
1652 self
1653 .call("nvim_set_vvar", call_args![name, value])
1654 .await??
1655 .try_unpack()
1656 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1657 }
1658
1659 pub async fn echo(
1660 &self,
1661 chunks: Vec<Value>,
1662 history: bool,
1663 opts: Vec<(Value, Value)>,
1664 ) -> Result<(), Box<CallError>> {
1665 self
1666 .call("nvim_echo", call_args![chunks, history, opts])
1667 .await??
1668 .try_unpack()
1669 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1670 }
1671
1672 pub async fn set_current_buf(
1673 &self,
1674 buffer: &Buffer<W>,
1675 ) -> Result<(), Box<CallError>> {
1676 self
1677 .call("nvim_set_current_buf", call_args![buffer])
1678 .await??
1679 .try_unpack()
1680 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1681 }
1682
1683 pub async fn set_current_win(
1684 &self,
1685 window: &Window<W>,
1686 ) -> Result<(), Box<CallError>> {
1687 self
1688 .call("nvim_set_current_win", call_args![window])
1689 .await??
1690 .try_unpack()
1691 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1692 }
1693
1694 pub async fn open_term(
1695 &self,
1696 buffer: &Buffer<W>,
1697 opts: Vec<(Value, Value)>,
1698 ) -> Result<i64, Box<CallError>> {
1699 self
1700 .call("nvim_open_term", call_args![buffer, opts])
1701 .await??
1702 .try_unpack()
1703 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1704 }
1705
1706 pub async fn chan_send(
1707 &self,
1708 chan: i64,
1709 data: &str,
1710 ) -> Result<(), Box<CallError>> {
1711 self
1712 .call("nvim_chan_send", call_args![chan, data])
1713 .await??
1714 .try_unpack()
1715 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1716 }
1717
1718 pub async fn set_current_tabpage(
1719 &self,
1720 tabpage: &Tabpage<W>,
1721 ) -> Result<(), Box<CallError>> {
1722 self
1723 .call("nvim_set_current_tabpage", call_args![tabpage])
1724 .await??
1725 .try_unpack()
1726 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1727 }
1728
1729 pub async fn paste(
1730 &self,
1731 data: &str,
1732 crlf: bool,
1733 phase: i64,
1734 ) -> Result<bool, Box<CallError>> {
1735 self
1736 .call("nvim_paste", call_args![data, crlf, phase])
1737 .await??
1738 .try_unpack()
1739 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1740 }
1741
1742 pub async fn put(
1743 &self,
1744 lines: Vec<String>,
1745 typ: &str,
1746 after: bool,
1747 follow: bool,
1748 ) -> Result<(), Box<CallError>> {
1749 self
1750 .call("nvim_put", call_args![lines, typ, after, follow])
1751 .await??
1752 .try_unpack()
1753 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1754 }
1755
1756 pub async fn get_color_by_name(
1757 &self,
1758 name: &str,
1759 ) -> Result<i64, Box<CallError>> {
1760 self
1761 .call("nvim_get_color_by_name", call_args![name])
1762 .await??
1763 .try_unpack()
1764 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1765 }
1766
1767 pub async fn get_color_map(
1768 &self,
1769 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1770 self
1771 .call("nvim_get_color_map", call_args![])
1772 .await??
1773 .try_unpack()
1774 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1775 }
1776
1777 pub async fn get_context(
1778 &self,
1779 opts: Vec<(Value, Value)>,
1780 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1781 self
1782 .call("nvim_get_context", call_args![opts])
1783 .await??
1784 .try_unpack()
1785 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1786 }
1787
1788 pub async fn load_context(
1789 &self,
1790 dict: Vec<(Value, Value)>,
1791 ) -> Result<Value, Box<CallError>> {
1792 self
1793 .call("nvim_load_context", call_args![dict])
1794 .await??
1795 .try_unpack()
1796 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1797 }
1798
1799 pub async fn get_mode(&self) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1800 self
1801 .call("nvim_get_mode", call_args![])
1802 .await??
1803 .try_unpack()
1804 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1805 }
1806
1807 pub async fn get_keymap(
1808 &self,
1809 mode: &str,
1810 ) -> Result<Vec<Vec<(Value, Value)>>, Box<CallError>> {
1811 self
1812 .call("nvim_get_keymap", call_args![mode])
1813 .await??
1814 .try_unpack()
1815 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1816 }
1817
1818 pub async fn set_keymap(
1819 &self,
1820 mode: &str,
1821 lhs: &str,
1822 rhs: &str,
1823 opts: Vec<(Value, Value)>,
1824 ) -> Result<(), Box<CallError>> {
1825 self
1826 .call("nvim_set_keymap", call_args![mode, lhs, rhs, opts])
1827 .await??
1828 .try_unpack()
1829 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1830 }
1831
1832 pub async fn del_keymap(
1833 &self,
1834 mode: &str,
1835 lhs: &str,
1836 ) -> Result<(), Box<CallError>> {
1837 self
1838 .call("nvim_del_keymap", call_args![mode, lhs])
1839 .await??
1840 .try_unpack()
1841 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1842 }
1843
1844 pub async fn get_api_info(&self) -> Result<Vec<Value>, Box<CallError>> {
1845 self
1846 .call("nvim_get_api_info", call_args![])
1847 .await??
1848 .try_unpack()
1849 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1850 }
1851
1852 pub async fn set_client_info(
1853 &self,
1854 name: &str,
1855 version: Vec<(Value, Value)>,
1856 typ: &str,
1857 methods: Vec<(Value, Value)>,
1858 attributes: Vec<(Value, Value)>,
1859 ) -> Result<(), Box<CallError>> {
1860 self
1861 .call(
1862 "nvim_set_client_info",
1863 call_args![name, version, typ, methods, attributes],
1864 )
1865 .await??
1866 .try_unpack()
1867 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1868 }
1869
1870 pub async fn get_chan_info(
1871 &self,
1872 chan: i64,
1873 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1874 self
1875 .call("nvim_get_chan_info", call_args![chan])
1876 .await??
1877 .try_unpack()
1878 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1879 }
1880
1881 pub async fn list_chans(&self) -> Result<Vec<Value>, Box<CallError>> {
1882 self
1883 .call("nvim_list_chans", call_args![])
1884 .await??
1885 .try_unpack()
1886 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1887 }
1888
1889 pub async fn list_uis(&self) -> Result<Vec<Value>, Box<CallError>> {
1890 self
1891 .call("nvim_list_uis", call_args![])
1892 .await??
1893 .try_unpack()
1894 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1895 }
1896
1897 pub async fn get_proc_children(
1898 &self,
1899 pid: i64,
1900 ) -> Result<Vec<Value>, Box<CallError>> {
1901 self
1902 .call("nvim_get_proc_children", call_args![pid])
1903 .await??
1904 .try_unpack()
1905 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1906 }
1907
1908 pub async fn get_proc(&self, pid: i64) -> Result<Value, Box<CallError>> {
1909 self
1910 .call("nvim_get_proc", call_args![pid])
1911 .await??
1912 .try_unpack()
1913 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1914 }
1915
1916 pub async fn select_popupmenu_item(
1917 &self,
1918 item: i64,
1919 insert: bool,
1920 finish: bool,
1921 opts: Vec<(Value, Value)>,
1922 ) -> Result<(), Box<CallError>> {
1923 self
1924 .call(
1925 "nvim_select_popupmenu_item",
1926 call_args![item, insert, finish, opts],
1927 )
1928 .await??
1929 .try_unpack()
1930 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1931 }
1932
1933 pub async fn del_mark(&self, name: &str) -> Result<bool, Box<CallError>> {
1934 self
1935 .call("nvim_del_mark", call_args![name])
1936 .await??
1937 .try_unpack()
1938 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1939 }
1940
1941 pub async fn get_mark(
1942 &self,
1943 name: &str,
1944 opts: Vec<(Value, Value)>,
1945 ) -> Result<Vec<Value>, Box<CallError>> {
1946 self
1947 .call("nvim_get_mark", call_args![name, opts])
1948 .await??
1949 .try_unpack()
1950 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1951 }
1952
1953 pub async fn eval_statusline(
1954 &self,
1955 str: &str,
1956 opts: Vec<(Value, Value)>,
1957 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1958 self
1959 .call("nvim_eval_statusline", call_args![str, opts])
1960 .await??
1961 .try_unpack()
1962 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1963 }
1964
1965 pub async fn exec2(
1966 &self,
1967 src: &str,
1968 opts: Vec<(Value, Value)>,
1969 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
1970 self
1971 .call("nvim_exec2", call_args![src, opts])
1972 .await??
1973 .try_unpack()
1974 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1975 }
1976
1977 pub async fn command(&self, command: &str) -> Result<(), Box<CallError>> {
1978 self
1979 .call("nvim_command", call_args![command])
1980 .await??
1981 .try_unpack()
1982 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1983 }
1984
1985 pub async fn eval(&self, expr: &str) -> Result<Value, Box<CallError>> {
1986 self
1987 .call("nvim_eval", call_args![expr])
1988 .await??
1989 .try_unpack()
1990 .map_err(|v| Box::new(CallError::WrongValueType(v)))
1991 }
1992
1993 pub async fn call_function(
1994 &self,
1995 fname: &str,
1996 args: Vec<Value>,
1997 ) -> Result<Value, Box<CallError>> {
1998 self
1999 .call("nvim_call_function", call_args![fname, args])
2000 .await??
2001 .try_unpack()
2002 .map_err(|v| Box::new(CallError::WrongValueType(v)))
2003 }
2004
2005 pub async fn call_dict_function(
2006 &self,
2007 dict: Value,
2008 fname: &str,
2009 args: Vec<Value>,
2010 ) -> Result<Value, Box<CallError>> {
2011 self
2012 .call("nvim_call_dict_function", call_args![dict, fname, args])
2013 .await??
2014 .try_unpack()
2015 .map_err(|v| Box::new(CallError::WrongValueType(v)))
2016 }
2017
2018 pub async fn parse_expression(
2019 &self,
2020 expr: &str,
2021 flags: &str,
2022 highlight: bool,
2023 ) -> Result<Vec<(Value, Value)>, Box<CallError>> {
2024 self
2025 .call("nvim_parse_expression", call_args![expr, flags, highlight])
2026 .await??
2027 .try_unpack()
2028 .map_err(|v| Box::new(CallError::WrongValueType(v)))
2029 }
2030}