summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock6
-rw-r--r--Cargo.toml4
-rw-r--r--src/ui/popupmenu/popupmenu.rs26
-rw-r--r--src/ui/state.rs6
4 files changed, 35 insertions, 7 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 7510745..1fef357 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -489,7 +489,7 @@ dependencies = [
"gtk 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "nvim-rs 0.1.1-alpha.0 (git+https://github.com/vhakulinen/nvim-rs?branch=ext-multigrid)",
+ "nvim-rs 0.1.1-alpha.0 (git+https://github.com/KillTheMule/nvim-rs)",
"pango 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pangocairo 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pin-project 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -752,7 +752,7 @@ dependencies = [
[[package]]
name = "nvim-rs"
version = "0.1.1-alpha.0"
-source = "git+https://github.com/vhakulinen/nvim-rs?branch=ext-multigrid#29af4b9393f1c9038f82dd56e698a7a1ac64fa24"
+source = "git+https://github.com/KillTheMule/nvim-rs#ee77b3a9dfbaebfdda9d7e3bc5fd72acaf3de7c1"
dependencies = [
"async-trait 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1668,7 +1668,7 @@ dependencies = [
"checksum new_debug_unreachable 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
"checksum num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
"checksum num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
-"checksum nvim-rs 0.1.1-alpha.0 (git+https://github.com/vhakulinen/nvim-rs?branch=ext-multigrid)" = "<none>"
+"checksum nvim-rs 0.1.1-alpha.0 (git+https://github.com/KillTheMule/nvim-rs)" = "<none>"
"checksum once_cell 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d"
"checksum onig 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd91ccd8a02fce2f7e8a86655aec67bc6c171e6f8e704118a0e8c4b866a05a8a"
"checksum onig_sys 69.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3814583fad89f3c60ae0701d80e87e1fd3028741723deda72d0d4a0ecf0cb0db"
diff --git a/Cargo.toml b/Cargo.toml
index 16f4d8b..178e4f6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -53,6 +53,4 @@ features = ["v2_14"]
optional = true
[dependencies.nvim-rs]
-git = "https://github.com/vhakulinen/nvim-rs"
-branch = "ext-multigrid"
-default-features = false
+git = "https://github.com/KillTheMule/nvim-rs"
diff --git a/src/ui/popupmenu/popupmenu.rs b/src/ui/popupmenu/popupmenu.rs
index 037b12e..fddb2f5 100644
--- a/src/ui/popupmenu/popupmenu.rs
+++ b/src/ui/popupmenu/popupmenu.rs
@@ -2,6 +2,7 @@ use std::cell::RefCell;
use std::rc::Rc;
use gtk::prelude::*;
+use log::error;
use crate::nvim_bridge::CompletionItem;
use crate::nvim_gio::GioNeovim;
@@ -11,6 +12,7 @@ use crate::ui::common::{
get_preferred_vertical_position, spawn_local,
};
use crate::ui::font::{Font, FontUnit};
+use crate::ui::grid::GridMetrics;
use crate::ui::popupmenu::get_icon_pixbuf;
use crate::ui::popupmenu::LazyLoader;
@@ -33,6 +35,8 @@ struct State {
available_size: Option<gdk::Rectangle>,
/// Our anchor position where the popupmenu should be "pointing" to.
anchor: gdk::Rectangle,
+ /// Metrics of the base grid. Used when reporting pum bounds to nvim.
+ base_metrics: Option<GridMetrics>,
current_width: i32,
@@ -45,6 +49,7 @@ impl State {
State {
selected: -1,
available_size: None,
+ base_metrics: None,
anchor: gdk::Rectangle {
x: 0,
y: 0,
@@ -213,7 +218,7 @@ impl Popupmenu {
}));
let layout_weak = layout.downgrade();
- box_.connect_size_allocate(clone!(state, layout_weak, scrolled_info, scrolled_list => move |box_, alloc| {
+ box_.connect_size_allocate(clone!(state, nvim, layout_weak, scrolled_info, scrolled_list => move |box_, alloc| {
let layout = upgrade_weak!(layout_weak);
let state = state.borrow();
@@ -235,6 +240,20 @@ impl Popupmenu {
box_.set_size_request(width, height);
+ if let Some(ref base_metrics) = state.base_metrics {
+ let width = width as f64 / base_metrics.cell_width as f64;
+ let height = height as f64 / base_metrics.cell_height as f64;
+ let col = x as f64 / base_metrics.cell_width as f64;
+ let row = y as f64 / base_metrics.cell_height as f64;
+
+ let nvim = nvim.clone();
+ spawn_local(async move {
+ if let Err(err) = nvim.ui_pum_set_bounds(width, height, row, col).await {
+ error!("Failed to set pum bounds: {}", err);
+ }
+ });
+ }
+
// If we moved the popupmenu above the achor position, make
// sure our contents are aligned to the bottom so there is not
// cap between the achor and the content it self.
@@ -295,6 +314,11 @@ impl Popupmenu {
self.scrolled_list.get_child().unwrap().get_valign() == gtk::Align::End
}
+ pub fn set_base_metrics(&self, metrics: GridMetrics) {
+ let mut state = self.state.borrow_mut();
+ state.base_metrics = Some(metrics);
+ }
+
pub fn toggle_show_info(&mut self) {
{
let state = self.state.borrow();
diff --git a/src/ui/state.rs b/src/ui/state.rs
index ca9f316..34f6788 100644
--- a/src/ui/state.rs
+++ b/src/ui/state.rs
@@ -171,6 +171,12 @@ impl UIState {
grid_metrics.height.ceil() as i32,
));
}
+
+ // If the update is on the base grid, update the metrics to the
+ // popupmenu too.
+ if e.grid == 1 {
+ self.popupmenu.set_base_metrics(grid.get_grid_metrics());
+ }
} else {
let grid = Grid::new(
e.grid,