nvim_rs/examples/mod.rs
1//! Examples on how to use [`nvim-rs`](crate).
2//!
3//! The code in question is in the `examples` directory of the project. The
4//! files in `src/examples/` contain the documentation.
5//!
6//! # Contents
7//!
8//! ### `handler_drop`
9//!
10//! An example showing how to implement cleanup-logic by implementing
11//! [`Drop`](std::ops::Drop) for the [`handler`](crate::rpc::handler::Handler).
12//!
13//! ### `quitting`
14//!
15//! An example showing how to handle quitting in a plugin by catching a [`closed
16//! channel`](crate::error::CallError::is_channel_closed).
17//!
18//!
19//! ## `scorched_earth`
20//!
21//! A port of a real existing plugin.
22//!
23//! ## `scorched_earth_as`
24//!
25//! A port of the `scorched_earth` example to `async-std`.
26//!
27//! ## `bench_*`
28//!
29//! Some crude benchmarks to measure performance. After running
30//!
31//! ```sh
32//! cargo build --examples --features use_tokio --release
33//! cargo build --examples --features use_async-std --release
34//! cargo build --examples --features use_neovim_lib --release
35//! ```
36//!
37//! (the features aren't all compatible, so you need to run those separately
38//! indeed) you can run `nvim -u bench_examples.vim`, and after so and so long
39//! get a table in a modified buffer that tells you some numbers.
40//!
41//! The benchmarks of `tokio` and `async-std` should be pretty comparable, but
42//! note that tokio's runtime takes parameters that influence performance.
43//! Tweaking those, I found the runtimes don't differ by much.
44//!
45//! The benchmark of `neovim_lib` (called `bench_sync`) can't be designed the
46//! way the others are, since they use nested requests. I tried to get around
47//! that somewhat sneakily, but it's not 100% clear those benchmarks are
48//! equivalent (but, if anything, they should favor neovim-lib a tad).
49pub mod handler_drop;
50pub mod quitting;
51pub mod scorched_earth;
52pub mod scorched_earth_as;