From e01ba4e847ec7e20dc99ad6dbc3a3b022a55532f Mon Sep 17 00:00:00 2001 From: Riccardo Mazzarini Date: Thu, 24 Oct 2024 17:49:11 +0800 Subject: [PATCH] api: add a `mouse` field to `Window{Config,Opts}` on nightly Tracks https://github.com/neovim/neovim/commit/9b8907d90508d7b66f025bbd1f5a48a78c5ce035. --- CHANGELOG.md | 3 +++ crates/api/src/types/window_config.rs | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a619b77b..863efc72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ - a `String::to_str()` method which returns a `&str` if the string contains valid UTF-8 data; +- a `WindowConfig::mouse` field and a `WindowOptsBuilder::mouse()` method + on nightly ([#189](https://github.com/noib3/nvim-oxi/pull/189)); + ### Changed - `nvim_oxi::api::echo` is now generic over the highlight group type instead of diff --git a/crates/api/src/types/window_config.rs b/crates/api/src/types/window_config.rs index 90581640..ea77b5f2 100644 --- a/crates/api/src/types/window_config.rs +++ b/crates/api/src/types/window_config.rs @@ -75,6 +75,11 @@ pub struct WindowConfig { )] pub hide: Option, + #[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))] + #[cfg(feature = "neovim-nightly")] // On 0.10 and nightly. + #[serde(default)] + pub mouse: bool, + /// If `true` then no buffer-related autocommand events such as `BufEnter` /// or `BufLeave` are fired when calling [`open_win`](crate::open_win). pub noautocmd: Option, @@ -436,6 +441,9 @@ pub struct WindowOpts { bufpos: Array, external: Boolean, focusable: Boolean, + #[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))] + #[cfg(feature = "neovim-nightly")] + mouse: Boolean, vertical: Boolean, zindex: Integer, border: Object, @@ -501,6 +509,9 @@ impl From<&WindowConfig> for WindowOpts { builder.focusable(focusable); } + #[cfg(feature = "neovim-nightly")] + builder.mouse(config.mouse); + if let Some(vertical) = config.vertical { builder.vertical(vertical); } @@ -567,6 +578,8 @@ impl TryFrom for WindowConfig { footer_pos, height, hide, + #[cfg(feature = "neovim-nightly")] + mouse, noautocmd, relative, row, @@ -639,6 +652,8 @@ impl TryFrom for WindowConfig { ))?, height: deserialize(height)?, hide: deserialize(hide)?, + #[cfg(feature = "neovim-nightly")] + mouse, noautocmd: deserialize(noautocmd)?, relative, row: deserialize(row)?,