Use nvim.command_async where possible
This commit is contained in:
parent
6ed33aa786
commit
a145256182
@ -13,7 +13,7 @@ use gtk;
|
||||
use gtk::MenuExt;
|
||||
use gtk::prelude::*;
|
||||
|
||||
use neovim_lib::NeovimApi;
|
||||
use neovim_lib::{NeovimApi, NeovimApiAsync};
|
||||
|
||||
use nvim::{ErrorReport, NeovimClient, NeovimRef};
|
||||
use shell;
|
||||
@ -235,9 +235,9 @@ impl FileBrowserWidget {
|
||||
fn connect_events(&self) {
|
||||
// Open file / go to dir, when user clicks on an entry.
|
||||
let store = &self.store;
|
||||
let state_ref = &self.state;
|
||||
let nvim_ref = self.nvim.as_ref().unwrap();
|
||||
self.tree.connect_row_activated(clone!(store, nvim_ref => move |tree, path, _| {
|
||||
let mut nvim = nvim_ref.nvim().unwrap();
|
||||
self.tree.connect_row_activated(clone!(store, state_ref, nvim_ref => move |tree, path, _| {
|
||||
let iter = store.get_iter(path).unwrap();
|
||||
let file_type = store
|
||||
.get_value(&iter, Column::FileType as i32)
|
||||
@ -256,10 +256,10 @@ impl FileBrowserWidget {
|
||||
}
|
||||
} else {
|
||||
// FileType::File
|
||||
if let Some(dir) = get_current_dir(&mut nvim) {
|
||||
let dir = Path::new(&dir);
|
||||
let cwd = &state_ref.borrow().current_dir;
|
||||
let cwd = Path::new(cwd);
|
||||
let file_path = if let Some(rel_path) = Path::new(&file_path)
|
||||
.strip_prefix(&dir)
|
||||
.strip_prefix(&cwd)
|
||||
.ok()
|
||||
.and_then(|p| p.to_str())
|
||||
{
|
||||
@ -267,8 +267,9 @@ impl FileBrowserWidget {
|
||||
} else {
|
||||
&file_path
|
||||
};
|
||||
nvim.command(&format!(":e {}", file_path)).report_err();
|
||||
}
|
||||
nvim_ref.nvim().unwrap().command_async(&format!(":e {}", file_path))
|
||||
.cb(|r| r.report_err())
|
||||
.call();
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use neovim_lib::NeovimApi;
|
||||
use neovim_lib::{NeovimApi, NeovimApiAsync};
|
||||
|
||||
use nvim::{NeovimClient, ErrorReport, NeovimRef};
|
||||
use value::ValueMapExt;
|
||||
@ -84,7 +84,9 @@ impl Manager {
|
||||
|
||||
pub fn reload(&self, path: &str) {
|
||||
if let Some(mut nvim) = self.nvim() {
|
||||
nvim.command(&format!("source {}", path)).report_err();
|
||||
nvim.command_async(&format!("source {}", path))
|
||||
.cb(|r| r.report_err())
|
||||
.call()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
src/shell.rs
12
src/shell.rs
@ -184,13 +184,17 @@ impl State {
|
||||
|
||||
pub fn open_file(&self, path: &str) {
|
||||
if let Some(mut nvim) = self.nvim() {
|
||||
nvim.command(&format!("e {}", path)).report_err();
|
||||
nvim.command_async(&format!("e {}", path))
|
||||
.cb(|r| r.report_err())
|
||||
.call();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cd(&self, path: &str) {
|
||||
if let Some(mut nvim) = self.nvim() {
|
||||
nvim.command(&format!("cd {}", path)).report_err();
|
||||
nvim.command_async(&format!("cd {}", path))
|
||||
.cb(|r| r.report_err())
|
||||
.call();
|
||||
}
|
||||
}
|
||||
|
||||
@ -600,7 +604,7 @@ impl Shell {
|
||||
|
||||
let nvim = state.nvim();
|
||||
if let Some(mut nvim) = nvim {
|
||||
nvim.command(":wa").report_err();
|
||||
nvim.command_async(":wa").cb(|r| r.report_err()).call();
|
||||
}
|
||||
}
|
||||
|
||||
@ -609,7 +613,7 @@ impl Shell {
|
||||
|
||||
let nvim = state.nvim();
|
||||
if let Some(mut nvim) = nvim {
|
||||
nvim.command(":tabe").report_err();
|
||||
nvim.command_async(":tabe").cb(|r| r.report_err()).call();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use neovim_lib::{NeovimApi, Value};
|
||||
use neovim_lib::{NeovimApi, NeovimApiAsync, Value};
|
||||
|
||||
use nvim::NeovimRef;
|
||||
use nvim::{ErrorReport, NeovimRef};
|
||||
|
||||
/// A subscription to a Neovim autocmd event.
|
||||
struct Subscription {
|
||||
@ -93,12 +93,11 @@ impl Subscriptions {
|
||||
.args
|
||||
.iter()
|
||||
.fold("".to_owned(), |acc, arg| acc + ", " + &arg);
|
||||
nvim.command(&format!(
|
||||
nvim.command_async(&format!(
|
||||
"au {} * call rpcnotify(1, 'subscription', '{}', {} {})",
|
||||
event_name, event_name, i, args,
|
||||
)).unwrap_or_else(|err| {
|
||||
error!("Could not set autocmd: {}", err);
|
||||
});
|
||||
)).cb(|r| r.report_err())
|
||||
.call();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ use glib::signal;
|
||||
|
||||
use pango;
|
||||
|
||||
use neovim_lib::NeovimApi;
|
||||
use neovim_lib::{NeovimApi, NeovimApiAsync};
|
||||
use neovim_lib::neovim_api::Tabpage;
|
||||
|
||||
use nvim;
|
||||
@ -42,7 +42,9 @@ impl State {
|
||||
|
||||
fn close_tab(&self, idx: u32) {
|
||||
if let Some(mut nvim) = self.nvim.as_ref().unwrap().nvim() {
|
||||
nvim.command(&format!(":tabc {}", idx + 1)).report_err();
|
||||
nvim.command_async(&format!(":tabc {}", idx + 1))
|
||||
.cb(|r| r.report_err())
|
||||
.call();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user