neovim-gtk/src/plug_manager/manager.rs

48 lines
1.1 KiB
Rust
Raw Normal View History

2017-10-15 19:50:59 +00:00
use std::rc::Rc;
2017-10-18 14:49:56 +00:00
use std::cell::RefCell;
2017-10-16 15:34:26 +00:00
2017-10-18 14:49:56 +00:00
use super::vim_plug;
2017-10-20 15:06:05 +00:00
use super::store::Store;
2017-10-18 14:49:56 +00:00
use nvim::NeovimClient;
2017-10-15 19:50:59 +00:00
pub struct Manager {
2017-10-24 15:03:34 +00:00
vim_plug: vim_plug::Manager,
pub plug_manage_state: PlugManageState,
2017-10-15 19:50:59 +00:00
}
impl Manager {
pub fn new() -> Self {
2017-10-18 14:49:56 +00:00
Manager {
vim_plug: vim_plug::Manager::new(),
2017-10-24 15:03:34 +00:00
plug_manage_state: PlugManageState::Unknown,
2017-10-16 15:34:26 +00:00
}
2017-10-15 19:50:59 +00:00
}
2017-10-16 15:34:26 +00:00
2017-10-24 15:03:34 +00:00
pub fn generate_plug_config(&mut self) -> Option<String> {
if Store::is_config_exists() {
self.plug_manage_state = PlugManageState::NvimGtk(Store::load());
Some("TODO".to_owned())
} else {
None
}
}
pub fn init_nvim_client(&mut self, nvim: Rc<RefCell<NeovimClient>>) {
2017-10-18 14:49:56 +00:00
self.vim_plug.initialize(nvim);
2017-10-16 15:34:26 +00:00
}
2017-10-20 15:06:05 +00:00
2017-10-24 15:03:34 +00:00
pub fn update_state(&mut self) {
if self.vim_plug.is_loaded() {
if let PlugManageState::Unknown = self.plug_manage_state {
self.plug_manage_state = PlugManageState::Configuration(Store::load_from_plug(&self.vim_plug));
2017-10-20 15:06:05 +00:00
}
}
}
2017-10-16 15:34:26 +00:00
}
2017-10-24 15:03:34 +00:00
pub enum PlugManageState {
NvimGtk(Store),
Configuration(Store),
Unknown,
}