Refactor nvim client

This commit is contained in:
daa84
2017-11-10 18:36:54 +03:00
parent 74514258eb
commit 2ee2fa31be
7 changed files with 202 additions and 125 deletions

View File

@@ -1,5 +1,4 @@
use std::rc::Rc;
use std::cell::RefCell;
use super::vim_plug;
use super::store::{Store, PlugInfo};
@@ -35,7 +34,7 @@ impl Manager {
}
}
pub fn init_nvim_client(&mut self, nvim: Rc<RefCell<NeovimClient>>) {
pub fn init_nvim_client(&mut self, nvim: Rc<NeovimClient>) {
self.vim_plug.initialize(nvim);
}

View File

@@ -1,13 +1,12 @@
use std::rc::Rc;
use std::cell::{RefCell, RefMut};
use neovim_lib::{Neovim, NeovimApi};
use neovim_lib::NeovimApi;
use nvim::{NeovimClient, ErrorReport};
use nvim::{NeovimClient, ErrorReport, NeovimRef};
use value::ValueMapExt;
pub struct Manager {
nvim: Option<Rc<RefCell<NeovimClient>>>,
nvim: Option<Rc<NeovimClient>>,
}
impl Manager {
@@ -15,17 +14,12 @@ impl Manager {
Manager { nvim: None }
}
pub fn initialize(&mut self, nvim: Rc<RefCell<NeovimClient>>) {
pub fn initialize(&mut self, nvim: Rc<NeovimClient>) {
self.nvim = Some(nvim);
}
fn nvim(&self) -> Option<RefMut<Neovim>> {
let nvim_client = self.nvim.as_ref().unwrap();
if nvim_client.borrow().is_initialized() {
Some(RefMut::map(nvim_client.borrow_mut(), |n| n.nvim_mut()))
} else {
None
}
fn nvim(&self) -> Option<NeovimRef> {
self.nvim.as_ref().unwrap().nvim()
}
pub fn get_plugs(&self) -> Result<Box<[VimPlugInfo]>, String> {