From c5ee1ab586f5b3c363a08890a9d4a75d0d8cbaea Mon Sep 17 00:00:00 2001 From: daa84 Date: Fri, 13 Oct 2017 18:27:10 +0300 Subject: [PATCH 01/30] Starting point for plug manager implementation --- src/main.rs | 1 + src/plug_manager/mod.rs | 3 +++ src/plug_manager/ui.rs | 46 ++++++++++++++++++++++++++++++++++++ src/ui.rs | 52 +++++++++++++++++++++++++++-------------- 4 files changed, 85 insertions(+), 17 deletions(-) create mode 100644 src/plug_manager/mod.rs create mode 100644 src/plug_manager/ui.rs diff --git a/src/main.rs b/src/main.rs index e2cf6c1..b120a03 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,7 @@ mod color; mod value; mod mode; mod ui_model; +mod plug_manager; #[macro_use] mod ui; mod nvim; diff --git a/src/plug_manager/mod.rs b/src/plug_manager/mod.rs new file mode 100644 index 0000000..8f153c6 --- /dev/null +++ b/src/plug_manager/mod.rs @@ -0,0 +1,3 @@ +mod ui; + +pub use self::ui::Ui; diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs new file mode 100644 index 0000000..9159fc9 --- /dev/null +++ b/src/plug_manager/ui.rs @@ -0,0 +1,46 @@ +use gtk; +use gtk::prelude::*; + +pub struct Ui {} + +impl Ui { + pub fn new() -> Self { + Ui {} + } + + pub fn show>(&self, parent: &T) { + const OK_ID: i32 = 0; + + let dlg = gtk::Dialog::new_with_buttons( + Some("Plug"), + Some(parent), + gtk::DialogFlags::empty(), + &[("Ok", OK_ID)], + ); + + let content = dlg.get_content_area(); + let tabs = gtk::Notebook::new(); + + let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); + let get_plugins_lbl = gtk::Label::new("Get Plugins"); + tabs.append_page(&get_plugins, Some(&get_plugins_lbl)); + + let plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); + let plugins_lbl = gtk::Label::new("Plugins"); + tabs.append_page(&plugins, Some(&plugins_lbl)); + + tabs.set_tab_pos(gtk::PositionType::Left); + content.add(&tabs); + content.show_all(); + + + match dlg.run() { + OK_ID => { + println!("TODO:"); + } + _ => (), + } + + dlg.destroy(); + } +} diff --git a/src/ui.rs b/src/ui.rs index 64c0906..e20a852 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -14,6 +14,7 @@ use settings::Settings; use shell::{Shell, ShellOptions}; use shell_dlg; use project::Projects; +use plug_manager; pub struct Ui { initialized: bool, @@ -30,8 +31,8 @@ pub struct Components { impl Components { fn new() -> Components { - let save_image = Image::new_from_icon_name("document-open", - gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32); + let save_image = + Image::new_from_icon_name("document-open", gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32); Components { open_btn: ToolButton::new(Some(&save_image), "Open"), @@ -96,24 +97,41 @@ impl Ui { let projects = self.projects.clone(); header_bar.pack_start(&comps.open_btn); - comps - .open_btn - .connect_clicked(move |_| projects.borrow_mut().show()); + comps.open_btn.connect_clicked( + move |_| projects.borrow_mut().show(), + ); - let save_image = Image::new_from_icon_name("document-save", - gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32); + let save_image = Image::new_from_icon_name( + "document-save", + gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32, + ); let save_btn = ToolButton::new(Some(&save_image), "Save"); let shell = self.shell.clone(); save_btn.connect_clicked(move |_| shell.borrow_mut().edit_save_all()); header_bar.pack_start(&save_btn); - let paste_image = Image::new_from_icon_name("edit-paste", - gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32); + let paste_image = Image::new_from_icon_name( + "edit-paste", + gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32, + ); let paste_btn = ToolButton::new(Some(&paste_image), "Paste"); let shell = self.shell.clone(); paste_btn.connect_clicked(move |_| shell.borrow_mut().edit_paste()); header_bar.pack_start(&paste_btn); + + let plug_image = Image::new_from_icon_name( + "system-software-install", + gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32, + ); + let plug_btn = ToolButton::new(Some(&plug_image), "Plug"); + + let comps_ref = self.comps.clone(); + plug_btn.connect_clicked(move |_| { + plug_manager::Ui::new().show(comps_ref.borrow().window.as_ref().unwrap()) + }); + header_bar.pack_start(&plug_btn); + header_bar.set_show_close_button(true); window.set_titlebar(Some(&header_bar)); @@ -134,7 +152,7 @@ impl Ui { shell.grab_focus(); let comps_ref = self.comps.clone(); - shell.set_detach_cb(Some(move || { + shell.set_detach_cb(Some(move || { let comps_ref = comps_ref.clone(); gtk::idle_add(move || { comps_ref.borrow().close_window(); @@ -178,13 +196,13 @@ fn gtk_delete(comps: &UiMutex, shell: &RefCell) -> Inhibit { } Inhibit(if shell_dlg::can_close_window(comps, shell) { - let comps = comps.borrow(); - comps.close_window(); - shell.borrow_mut().detach_ui(); - false - } else { - true - }) + let comps = comps.borrow(); + comps.close_window(); + shell.borrow_mut().detach_ui(); + false + } else { + true + }) } pub struct UiMutex { From cda55e0f7d7e0e0b35b058d63f2828768094a4e5 Mon Sep 17 00:00:00 2001 From: daa Date: Sat, 14 Oct 2017 14:50:13 +0300 Subject: [PATCH 02/30] Make ui attach really async --- src/shell.rs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/shell.rs b/src/shell.rs index b5a177c..8d2cce9 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -766,25 +766,19 @@ fn init_nvim_async( }); // attach ui - let mut nvim = Some(nvim); - glib::idle_add(move || { - let mut nvim = nvim.take().unwrap(); - if let Err(err) = nvim::post_start_init( - &mut nvim, - options.open_path.as_ref(), - cols as u64, - rows as u64, - ) - { - show_nvim_init_error(&err, state_arc.clone()); - } else { - let mut state = state_arc.borrow_mut(); - state.nvim.borrow_mut().set_initialized(nvim); - state.cursor.as_mut().unwrap().start(); - } - - Continue(false) - }); + if let Err(err) = nvim::post_start_init( + &mut nvim, + options.open_path.as_ref(), + cols as u64, + rows as u64, + ) + { + show_nvim_init_error(&err, state_arc.clone()); + } else { + let mut state = state_arc.borrow_mut(); + state.nvim.borrow_mut().set_initialized(nvim); + state.cursor.as_mut().unwrap().start(); + } } fn draw_initializing(state: &State, ctx: &cairo::Context) { From 86e18562b5f20819c5f05524d61f88e888d0208d Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 15 Oct 2017 22:50:59 +0300 Subject: [PATCH 03/30] Seleton for plug manager --- src/plug_manager/manager.rs | 17 +++++++++++ src/plug_manager/mod.rs | 2 ++ src/shell.rs | 58 ++++++++++++++++++++++++++++--------- src/ui.rs | 9 ++++++ 4 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 src/plug_manager/manager.rs diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs new file mode 100644 index 0000000..2f275ff --- /dev/null +++ b/src/plug_manager/manager.rs @@ -0,0 +1,17 @@ +use std::rc::Rc; +use std::cell::RefCell; + +use nvim::NeovimClient; + +pub struct Manager { + +} + +impl Manager { + pub fn new() -> Self { + Manager { } + } + + pub fn initialize(&mut self, nvim: Rc>) { + } +} diff --git a/src/plug_manager/mod.rs b/src/plug_manager/mod.rs index 8f153c6..d20f8e8 100644 --- a/src/plug_manager/mod.rs +++ b/src/plug_manager/mod.rs @@ -1,3 +1,5 @@ mod ui; +mod manager; pub use self::ui::Ui; +pub use self::manager::Manager; diff --git a/src/shell.rs b/src/shell.rs index 8d2cce9..10facfb 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -79,6 +79,7 @@ pub struct State { options: ShellOptions, detach_cb: Option>>, + nvim_started_cb: Option>>, } impl State { @@ -112,6 +113,7 @@ impl State { options, detach_cb: None, + nvim_started_cb: None, } } @@ -156,6 +158,17 @@ impl State { } } + pub fn set_nvim_started_cb(&mut self, cb: Option) + where + F: FnMut() + Send + 'static, + { + if cb.is_some() { + self.nvim_started_cb = Some(Box::new(RefCell::new(cb.unwrap()))); + } else { + self.nvim_started_cb = None; + } + } + pub fn get_font_desc(&self) -> &FontDescription { self.font_ctx.font_description() } @@ -581,6 +594,14 @@ impl Shell { let mut state = self.state.borrow_mut(); state.set_detach_cb(cb); } + + pub fn set_nvim_started_cb(&self, cb: Option) + where + F: FnMut() + Send + 'static, + { + let mut state = self.state.borrow_mut(); + state.set_nvim_started_cb(cb); + } } impl Deref for Shell { @@ -766,19 +787,30 @@ fn init_nvim_async( }); // attach ui - if let Err(err) = nvim::post_start_init( - &mut nvim, - options.open_path.as_ref(), - cols as u64, - rows as u64, - ) - { - show_nvim_init_error(&err, state_arc.clone()); - } else { - let mut state = state_arc.borrow_mut(); - state.nvim.borrow_mut().set_initialized(nvim); - state.cursor.as_mut().unwrap().start(); - } + let state_ref = state_arc.clone(); + let mut nvim = Some(nvim); + glib::idle_add(move || { + let mut nvim = nvim.take().unwrap(); + + if let Err(err) = nvim::post_start_init( + &mut nvim, + options.open_path.as_ref(), + cols as u64, + rows as u64, + ) + { + show_nvim_init_error(&err, state_ref.clone()); + } else { + let mut state = state_ref.borrow_mut(); + state.nvim.borrow_mut().set_initialized(nvim); + state.cursor.as_mut().unwrap().start(); + } + + Continue(false) + }); + + + idle_cb_call!(state_arc.nvim_started_cb()); } fn draw_initializing(state: &State, ctx: &cairo::Context) { diff --git a/src/ui.rs b/src/ui.rs index e20a852..f71fdf8 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -22,6 +22,7 @@ pub struct Ui { settings: Rc>, shell: Rc>, projects: Rc>, + plug_manager: Arc>, } pub struct Components { @@ -57,6 +58,7 @@ impl Ui { settings.borrow_mut().set_shell(Rc::downgrade(&shell)); let projects = Projects::new(&comps.borrow().open_btn, shell.clone()); + let plug_manager = Arc::new(UiMutex::new(plug_manager::Manager::new())); Ui { initialized: false, @@ -64,6 +66,7 @@ impl Ui { shell, settings, projects, + plug_manager, } } @@ -159,6 +162,12 @@ impl Ui { Continue(false) }); })); + + let state_ref = self.shell.borrow().state.clone(); + let plug_manager_ref = self.plug_manager.clone(); + shell.set_nvim_started_cb(Some(move || { + plug_manager_ref.borrow_mut().initialize(state_ref.borrow().nvim_clone()); + })); } fn create_main_menu(&self, app: >k::Application) { From a3eba12b24d9dff75e303651e9745320a1511f66 Mon Sep 17 00:00:00 2001 From: daa84 Date: Mon, 16 Oct 2017 18:34:26 +0300 Subject: [PATCH 04/30] Check loaded state --- src/plug_manager/manager.rs | 33 ++++++++++++++++++++++++++++++--- src/plug_manager/ui.rs | 14 ++++++++++---- src/ui.rs | 8 ++++++-- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index 2f275ff..fe9a93c 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -1,17 +1,44 @@ use std::rc::Rc; -use std::cell::RefCell; +use std::cell::{RefCell, RefMut}; + +use neovim_lib::{Neovim, NeovimApi, Value}; use nvim::NeovimClient; pub struct Manager { - + nvim: Option>>, } impl Manager { pub fn new() -> Self { - Manager { } + Manager { + nvim: None, + } } pub fn initialize(&mut self, nvim: Rc>) { + self.nvim = Some(nvim); + } + + fn nvim(&self) -> Option> { + 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 + } + } + + pub fn get_state(&self) -> State { + if let Some(mut nvim) = self.nvim() { + nvim.command("exists('g:loaded_plug')"); + } + + State::Unknown } } + +pub enum State { + Unknown, + AlreadyLoaded, +} diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index 9159fc9..c5903f7 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -1,11 +1,17 @@ use gtk; use gtk::prelude::*; -pub struct Ui {} +use super::manager; -impl Ui { - pub fn new() -> Self { - Ui {} +pub struct Ui <'a> { + manager: &'a manager::Manager, +} + +impl <'a> Ui <'a> { + pub fn new(manager: &'a manager::Manager) -> Ui<'a> { + Ui { + manager, + } } pub fn show>(&self, parent: &T) { diff --git a/src/ui.rs b/src/ui.rs index f71fdf8..6c18f8c 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -130,8 +130,10 @@ impl Ui { let plug_btn = ToolButton::new(Some(&plug_image), "Plug"); let comps_ref = self.comps.clone(); + let plug_manager_ref = self.plug_manager.clone(); plug_btn.connect_clicked(move |_| { - plug_manager::Ui::new().show(comps_ref.borrow().window.as_ref().unwrap()) + plug_manager::Ui::new(&mut *plug_manager_ref.borrow_mut()) + .show(comps_ref.borrow().window.as_ref().unwrap()) }); header_bar.pack_start(&plug_btn); @@ -166,7 +168,9 @@ impl Ui { let state_ref = self.shell.borrow().state.clone(); let plug_manager_ref = self.plug_manager.clone(); shell.set_nvim_started_cb(Some(move || { - plug_manager_ref.borrow_mut().initialize(state_ref.borrow().nvim_clone()); + plug_manager_ref.borrow_mut().initialize( + state_ref.borrow().nvim_clone(), + ); })); } From b0477c36f60e9843fd5042326d70081eefb07ba2 Mon Sep 17 00:00:00 2001 From: daa Date: Tue, 17 Oct 2017 21:34:49 +0300 Subject: [PATCH 05/30] Check vim-plug loaded --- src/nvim.rs | 11 +++++++++-- src/plug_manager/manager.rs | 24 +++++++++++++++--------- src/plug_manager/ui.rs | 33 +++++++++++++++++++++++++-------- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/nvim.rs b/src/nvim.rs index d9287bc..4290f69 100644 --- a/src/nvim.rs +++ b/src/nvim.rs @@ -505,17 +505,24 @@ fn call( Ok(repaint_mode) } -pub trait ErrorReport { +pub trait ErrorReport { fn report_err(&self, nvim: &mut NeovimApi); + + fn ok_and_report(&self, nvim: &mut NeovimApi) -> Option<&T>; } -impl ErrorReport for result::Result { +impl ErrorReport for result::Result { fn report_err(&self, _: &mut NeovimApi) { if let Err(ref err) = *self { println!("{}", err); //nvim.report_error(&err_msg).expect("Error report error :)"); } } + + fn ok_and_report(&self, nvim: &mut NeovimApi) -> Option<&T> { + self.report_err(nvim); + self.as_ref().ok() + } } #[derive(Clone, Debug)] diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index fe9a93c..24d295e 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -1,19 +1,17 @@ use std::rc::Rc; use std::cell::{RefCell, RefMut}; -use neovim_lib::{Neovim, NeovimApi, Value}; +use neovim_lib::{Neovim, NeovimApi}; -use nvim::NeovimClient; +use nvim::{NeovimClient, ErrorReport}; pub struct Manager { - nvim: Option>>, + nvim: Option>>, } impl Manager { pub fn new() -> Self { - Manager { - nvim: None, - } + Manager { nvim: None } } pub fn initialize(&mut self, nvim: Rc>) { @@ -31,10 +29,18 @@ impl Manager { pub fn get_state(&self) -> State { if let Some(mut nvim) = self.nvim() { - nvim.command("exists('g:loaded_plug')"); + let loaded_plug = nvim.eval("exists('g:loaded_plug')"); + loaded_plug + .ok_and_report(&mut *nvim) + .and_then(|loaded_plug| loaded_plug.as_i64()) + .map_or(State::Unknown, |loaded_plug| if loaded_plug > 0 { + State::AlreadyLoaded + } else { + State::Unknown + }) + } else { + State::Unknown } - - State::Unknown } } diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index c5903f7..e3d1dd0 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -3,15 +3,13 @@ use gtk::prelude::*; use super::manager; -pub struct Ui <'a> { +pub struct Ui<'a> { manager: &'a manager::Manager, } -impl <'a> Ui <'a> { +impl<'a> Ui<'a> { pub fn new(manager: &'a manager::Manager) -> Ui<'a> { - Ui { - manager, - } + Ui { manager } } pub fn show>(&self, parent: &T) { @@ -27,9 +25,24 @@ impl <'a> Ui <'a> { let content = dlg.get_content_area(); let tabs = gtk::Notebook::new(); - let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); - let get_plugins_lbl = gtk::Label::new("Get Plugins"); - tabs.append_page(&get_plugins, Some(&get_plugins_lbl)); + match self.get_state() { + manager::State::AlreadyLoaded => { + let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); + let warn_lbl = gtk::Label::new( + "Plug manager already loaded.\n\ + NeovimGtk manages plugins using vim-plug as backend.\n\ + To allow NeovimGtk manage plugins please disable vim-plug in your configuration", + ); + get_plugins.add(&warn_lbl); + let get_plugins_lbl = gtk::Label::new("Help"); + tabs.append_page(&get_plugins, Some(&get_plugins_lbl)); + } + manager::State::Unknown => { + let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); + let get_plugins_lbl = gtk::Label::new("Get Plugins"); + tabs.append_page(&get_plugins, Some(&get_plugins_lbl)); + } + } let plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); let plugins_lbl = gtk::Label::new("Plugins"); @@ -49,4 +62,8 @@ impl <'a> Ui <'a> { dlg.destroy(); } + + fn get_state(&self) -> manager::State { + self.manager.get_state() + } } From fbe25e1a1c3fdc6be790489a9fbc0b190516cc5d Mon Sep 17 00:00:00 2001 From: daa84 Date: Wed, 18 Oct 2017 17:49:56 +0300 Subject: [PATCH 06/30] Code reorganisation --- src/plug_manager/manager.rs | 45 ++++++----------------------- src/plug_manager/mod.rs | 2 ++ src/plug_manager/store.rs | 9 ++++++ src/plug_manager/ui.rs | 16 +++++++---- src/plug_manager/vim_plug.rs | 56 ++++++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 42 deletions(-) create mode 100644 src/plug_manager/store.rs create mode 100644 src/plug_manager/vim_plug.rs diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index 24d295e..13158ee 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -1,50 +1,21 @@ use std::rc::Rc; -use std::cell::{RefCell, RefMut}; +use std::cell::RefCell; -use neovim_lib::{Neovim, NeovimApi}; - -use nvim::{NeovimClient, ErrorReport}; +use super::vim_plug; +use nvim::NeovimClient; pub struct Manager { - nvim: Option>>, + pub vim_plug: vim_plug::Manager, } impl Manager { pub fn new() -> Self { - Manager { nvim: None } + Manager { + vim_plug: vim_plug::Manager::new(), + } } pub fn initialize(&mut self, nvim: Rc>) { - self.nvim = Some(nvim); - } - - fn nvim(&self) -> Option> { - 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 - } - } - - pub fn get_state(&self) -> State { - if let Some(mut nvim) = self.nvim() { - let loaded_plug = nvim.eval("exists('g:loaded_plug')"); - loaded_plug - .ok_and_report(&mut *nvim) - .and_then(|loaded_plug| loaded_plug.as_i64()) - .map_or(State::Unknown, |loaded_plug| if loaded_plug > 0 { - State::AlreadyLoaded - } else { - State::Unknown - }) - } else { - State::Unknown - } + self.vim_plug.initialize(nvim); } } - -pub enum State { - Unknown, - AlreadyLoaded, -} diff --git a/src/plug_manager/mod.rs b/src/plug_manager/mod.rs index d20f8e8..647f6f4 100644 --- a/src/plug_manager/mod.rs +++ b/src/plug_manager/mod.rs @@ -1,4 +1,6 @@ mod ui; +mod vim_plug; +mod store; mod manager; pub use self::ui::Ui; diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs new file mode 100644 index 0000000..56d7d81 --- /dev/null +++ b/src/plug_manager/store.rs @@ -0,0 +1,9 @@ +pub struct Store { + +} + +impl Store { + pub fn new() -> Self { + Store { } + } +} diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index e3d1dd0..c1d939e 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -2,6 +2,7 @@ use gtk; use gtk::prelude::*; use super::manager; +use super::vim_plug; pub struct Ui<'a> { manager: &'a manager::Manager, @@ -26,10 +27,10 @@ impl<'a> Ui<'a> { let tabs = gtk::Notebook::new(); match self.get_state() { - manager::State::AlreadyLoaded => { + vim_plug::State::AlreadyLoaded => { let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); let warn_lbl = gtk::Label::new( - "Plug manager already loaded.\n\ + "vim-plug manager already loaded.\n\ NeovimGtk manages plugins using vim-plug as backend.\n\ To allow NeovimGtk manage plugins please disable vim-plug in your configuration", ); @@ -37,13 +38,14 @@ impl<'a> Ui<'a> { let get_plugins_lbl = gtk::Label::new("Help"); tabs.append_page(&get_plugins, Some(&get_plugins_lbl)); } - manager::State::Unknown => { + vim_plug::State::Unknown => { let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); let get_plugins_lbl = gtk::Label::new("Get Plugins"); tabs.append_page(&get_plugins, Some(&get_plugins_lbl)); } } + self.get_plugs(); let plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); let plugins_lbl = gtk::Label::new("Plugins"); tabs.append_page(&plugins, Some(&plugins_lbl)); @@ -63,7 +65,11 @@ impl<'a> Ui<'a> { dlg.destroy(); } - fn get_state(&self) -> manager::State { - self.manager.get_state() + fn get_state(&self) -> vim_plug::State { + self.manager.vim_plug.get_state() + } + + fn get_plugs(&self) { + self.manager.vim_plug.get_plugs(); } } diff --git a/src/plug_manager/vim_plug.rs b/src/plug_manager/vim_plug.rs new file mode 100644 index 0000000..9113956 --- /dev/null +++ b/src/plug_manager/vim_plug.rs @@ -0,0 +1,56 @@ +use std::rc::Rc; +use std::cell::{RefCell, RefMut}; + +use neovim_lib::{Neovim, NeovimApi}; + +use nvim::{NeovimClient, ErrorReport}; + +pub struct Manager { + nvim: Option>>, +} + +impl Manager { + pub fn new() -> Self { + Manager { nvim: None } + } + + pub fn initialize(&mut self, nvim: Rc>) { + self.nvim = Some(nvim); + } + + fn nvim(&self) -> Option> { + 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 + } + } + + pub fn get_plugs(&self) { + if let Some(mut nvim) = self.nvim() { + let plugs = nvim.eval("g:plugs"); + } + } + + pub fn get_state(&self) -> State { + if let Some(mut nvim) = self.nvim() { + let loaded_plug = nvim.eval("exists('g:loaded_plug')"); + loaded_plug + .ok_and_report(&mut *nvim) + .and_then(|loaded_plug| loaded_plug.as_i64()) + .map_or(State::Unknown, |loaded_plug| if loaded_plug > 0 { + State::AlreadyLoaded + } else { + State::Unknown + }) + } else { + State::Unknown + } + } +} + +pub enum State { + Unknown, + AlreadyLoaded, +} From a286d39b488f3cbadd7b1ccb46b2c75fdfa1122a Mon Sep 17 00:00:00 2001 From: daa84 Date: Thu, 19 Oct 2017 17:04:58 +0300 Subject: [PATCH 07/30] General code for load/store settings --- src/dirs.rs | 30 +++++++++++++ src/main.rs | 2 + src/plug_manager/store.rs | 39 +++++++++++++++-- src/project.rs | 89 ++++----------------------------------- src/settings.rs | 66 +++++++++++++++++++++++++++++ 5 files changed, 142 insertions(+), 84 deletions(-) create mode 100644 src/dirs.rs diff --git a/src/dirs.rs b/src/dirs.rs new file mode 100644 index 0000000..10ef164 --- /dev/null +++ b/src/dirs.rs @@ -0,0 +1,30 @@ +use std; +use std::path::PathBuf; + +pub fn get_app_config_dir_create() -> Result { + let config_dir = get_app_config_dir()?; + + std::fs::create_dir_all(&config_dir) + .map_err(|e| format!("{}", e))?; + + Ok(config_dir) +} + +fn get_app_config_dir() -> Result { + let mut config_dir = get_xdg_config_dir()?; + + config_dir.push("nvim-gtk"); + + Ok(config_dir) +} + +fn get_xdg_config_dir() -> Result { + if let Ok(config_path) = std::env::var("XDG_CONFIG_HOME") { + return Ok(PathBuf::from(config_path)); + } + + let mut home_dir = std::env::home_dir() + .ok_or("Impossible to get your home dir!")?; + home_dir.push(".config"); + Ok(home_dir) +} diff --git a/src/main.rs b/src/main.rs index b120a03..c48713e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,12 +18,14 @@ extern crate log; extern crate env_logger; extern crate htmlescape; +extern crate serde; #[macro_use] extern crate serde_derive; extern crate toml; mod sys; +mod dirs; mod color; mod value; mod mode; diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index 56d7d81..8f56edc 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -1,9 +1,40 @@ -pub struct Store { - -} +use toml; + +use settings::SettingsLoader; + +pub struct Store {} impl Store { pub fn new() -> Self { - Store { } + Store {} + } +} + +#[derive(Serialize, Deserialize)] +struct Settings { + plugs: Vec, +} + +impl SettingsLoader for Settings { + const SETTINGS_FILE: &'static str = "plugs.toml"; + + fn empty() -> Self { + Settings { plugs: vec![] } + } + + fn from_str(s: &str) -> Result { + toml::from_str(&s).map_err(|e| format!("{}", e)) + } +} + +#[derive(Serialize, Deserialize)] +pub struct PlugInfo { + name: String, + url: String, +} + +impl PlugInfo { + pub fn new(name: String, url: String) -> Self { + PlugInfo { name, url } } } diff --git a/src/project.rs b/src/project.rs index 60fe38b..7bb838d 100644 --- a/src/project.rs +++ b/src/project.rs @@ -532,14 +532,9 @@ impl Entry { // ----- Store / Load settings // -use std::path::PathBuf; -use std::fs::File; -use std::io::prelude::*; -use std; +use settings::SettingsLoader; use toml; -const PROJECTS_SETTINGS_FILE: &str = "projects.toml"; - #[derive(Serialize, Deserialize)] struct ProjectSettings { projects: Vec, @@ -564,87 +559,21 @@ impl ProjectEntrySettings { } } -impl ProjectSettings { - fn new(projects: Vec) -> ProjectSettings { - ProjectSettings { projects } - } +impl SettingsLoader for ProjectSettings { + const SETTINGS_FILE: &'static str = "projects.toml"; fn empty() -> ProjectSettings { ProjectSettings { projects: vec![] } } - fn load_from_file(path: &Path) -> Result { - if path.exists() { - let mut file = File::open(path).map_err(|e| format!("{}", e))?; - let mut contents = String::new(); - file.read_to_string(&mut contents) - .map_err(|e| format!("{}", e))?; - toml::from_str(&contents).map_err(|e| format!("{}", e)) - } else { - Ok(ProjectSettings::empty()) - } - } - - fn load_err() -> Result { - let mut toml_path = get_app_config_dir_create()?; - toml_path.push(PROJECTS_SETTINGS_FILE); - ProjectSettings::load_from_file(&toml_path) - } - - fn load() -> ProjectSettings { - match ProjectSettings::load_err() { - Ok(settings) => settings, - Err(e) => { - println!("{}", e); - ProjectSettings::empty() - } - } - } - - fn save_err(&self) -> Result<(), String> { - let mut toml_path = get_app_config_dir_create()?; - toml_path.push(PROJECTS_SETTINGS_FILE); - let mut file = File::create(toml_path).map_err(|e| format!("{}", e))?; - - let contents = toml::to_vec(self).map_err(|e| format!("{}", e))?; - - file.write_all(&contents).map_err(|e| format!("{}", e))?; - - Ok(()) - } - - pub fn save(&self) { - match self.save_err() { - Ok(()) => (), - Err(e) => println!("{}", e), - } + fn from_str(s: &str) -> Result { + toml::from_str(&s).map_err(|e| format!("{}", e)) } } -fn get_app_config_dir_create() -> Result { - let config_dir = get_app_config_dir()?; - - std::fs::create_dir_all(&config_dir) - .map_err(|e| format!("{}", e))?; - - Ok(config_dir) -} - -fn get_app_config_dir() -> Result { - let mut config_dir = get_xdg_config_dir()?; - - config_dir.push("nvim-gtk"); - - Ok(config_dir) -} - -fn get_xdg_config_dir() -> Result { - if let Ok(config_path) = std::env::var("XDG_CONFIG_HOME") { - return Ok(PathBuf::from(config_path)); +impl ProjectSettings { + fn new(projects: Vec) -> ProjectSettings { + ProjectSettings { projects } } - - let mut home_dir = std::env::home_dir() - .ok_or("Impossible to get your home dir!")?; - home_dir.push(".config"); - Ok(home_dir) } + diff --git a/src/settings.rs b/src/settings.rs index 04d36df..edc0319 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -101,3 +101,69 @@ fn monospace_font_changed(mut shell: &mut Shell, state: &mut State) { state.update_font(&mut shell); } } + +use std::path::Path; +use std::fs::File; +use std::io::prelude::*; + +use toml; +use serde; + +use dirs; + +pub trait SettingsLoader: Sized + serde::Serialize { + const SETTINGS_FILE: &'static str; + + fn empty() -> Self; + + fn from_str(s: &str) -> Result; + + fn load() -> Self { + match load_err() { + Ok(settings) => settings, + Err(e) => { + println!("{}", e); + Self::empty() + } + } + } + + fn save(&self) { + match save_err(self) { + Ok(()) => (), + Err(e) => println!("{}", e), + } + } +} + +fn load_from_file(path: &Path) -> Result { + if path.exists() { + let mut file = File::open(path).map_err(|e| format!("{}", e))?; + let mut contents = String::new(); + file.read_to_string(&mut contents).map_err( + |e| format!("{}", e), + )?; + T::from_str(&contents) + } else { + Ok(T::empty()) + } +} + +fn load_err() -> Result { + let mut toml_path = dirs::get_app_config_dir_create()?; + toml_path.push(T::SETTINGS_FILE); + load_from_file(&toml_path) +} + + +fn save_err(sl: &T) -> Result<(), String> { + let mut toml_path = dirs::get_app_config_dir_create()?; + toml_path.push(T::SETTINGS_FILE); + let mut file = File::create(toml_path).map_err(|e| format!("{}", e))?; + + let contents = toml::to_vec::(sl).map_err(|e| format!("{}", e))?; + + file.write_all(&contents).map_err(|e| format!("{}", e))?; + + Ok(()) +} From c1b6bbca88620fc1b9c416f49588987967db18af Mon Sep 17 00:00:00 2001 From: daa84 Date: Fri, 20 Oct 2017 18:06:05 +0300 Subject: [PATCH 08/30] Load vim-plug configuration --- src/plug_manager/manager.rs | 13 +++++++++ src/plug_manager/store.rs | 33 ++++++++++++++++++++-- src/plug_manager/ui.rs | 37 +++++++++++++++++++----- src/plug_manager/vim_plug.rs | 55 ++++++++++++++++++++++++++++++++++-- 4 files changed, 126 insertions(+), 12 deletions(-) diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index 13158ee..05533f9 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -2,6 +2,7 @@ use std::rc::Rc; use std::cell::RefCell; use super::vim_plug; +use super::store::Store; use nvim::NeovimClient; pub struct Manager { @@ -18,4 +19,16 @@ impl Manager { pub fn initialize(&mut self, nvim: Rc>) { self.vim_plug.initialize(nvim); } + + pub fn load_store(&self, vim_plug_state: &vim_plug::State) -> Store { + match *vim_plug_state { + vim_plug::State::AlreadyLoaded => { + let store = Store::load_from_plug(&self.vim_plug); + store + } + vim_plug::State::Unknown => { + Store::load() + } + } + } } diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index 8f56edc..2f9c9ec 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -1,12 +1,33 @@ use toml; use settings::SettingsLoader; +use super::vim_plug; -pub struct Store {} +pub struct Store { + settings: Settings, +} impl Store { - pub fn new() -> Self { - Store {} + pub fn load() -> Self { + Store { settings: Settings::load() } + } + + pub fn load_from_plug(vim_plug: &vim_plug::Manager) -> Self { + let settings = match vim_plug.get_plugs() { + Err(msg) => { + error!("{}", msg); + Settings::empty() + } + Ok(plugs) => { + let plugs = plugs + .iter() + .map(|vpi| PlugInfo::new(vpi.name.to_owned(), vpi.uri.to_owned())) + .collect(); + Settings::new(plugs) + } + }; + + Store { settings } } } @@ -15,6 +36,12 @@ struct Settings { plugs: Vec, } +impl Settings { + fn new(plugs: Vec) -> Self { + Settings { plugs } + } +} + impl SettingsLoader for Settings { const SETTINGS_FILE: &'static str = "plugs.toml"; diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index c1d939e..56e0297 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -3,6 +3,7 @@ use gtk::prelude::*; use super::manager; use super::vim_plug; +use super::store::Store; pub struct Ui<'a> { manager: &'a manager::Manager, @@ -26,15 +27,22 @@ impl<'a> Ui<'a> { let content = dlg.get_content_area(); let tabs = gtk::Notebook::new(); - match self.get_state() { + let vim_plug_state = self.get_state(); + match vim_plug_state { vim_plug::State::AlreadyLoaded => { let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); let warn_lbl = gtk::Label::new( "vim-plug manager already loaded.\n\ NeovimGtk manages plugins using vim-plug as backend.\n\ - To allow NeovimGtk manage plugins please disable vim-plug in your configuration", + To allow NeovimGtk manage plugins please disable vim-plug in your configuration.\n\ + You can convert vim-plug configuration to NeovimGtk conviguration using button below.\n\ + List of current vim-plug plugins can be found in 'Plugins' tab.", ); get_plugins.add(&warn_lbl); + + let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); + get_plugins.add(©_btn); + let get_plugins_lbl = gtk::Label::new("Help"); tabs.append_page(&get_plugins, Some(&get_plugins_lbl)); } @@ -45,8 +53,11 @@ impl<'a> Ui<'a> { } } - self.get_plugs(); let plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); + let store = self.manager.load_store(&vim_plug_state); + + self.fill_plugin_list(&plugins, &store); + let plugins_lbl = gtk::Label::new("Plugins"); tabs.append_page(&plugins, Some(&plugins_lbl)); @@ -65,11 +76,23 @@ impl<'a> Ui<'a> { dlg.destroy(); } + fn fill_plugin_list(&self, panel: >k::Box, store: &Store) { + let tree = gtk::TreeView::new(); + let scroll = gtk::ScrolledWindow::new(None, None); + + tree.set_headers_visible(false); + tree.set_can_focus(false); + scroll.set_policy(gtk::PolicyType::Never, gtk::PolicyType::Automatic); + scroll.add(&tree); + + panel.add(&scroll); + + let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); + panel.add(©_btn); + } + fn get_state(&self) -> vim_plug::State { self.manager.vim_plug.get_state() } - - fn get_plugs(&self) { - self.manager.vim_plug.get_plugs(); - } } + diff --git a/src/plug_manager/vim_plug.rs b/src/plug_manager/vim_plug.rs index 9113956..9b74718 100644 --- a/src/plug_manager/vim_plug.rs +++ b/src/plug_manager/vim_plug.rs @@ -4,6 +4,7 @@ use std::cell::{RefCell, RefMut}; use neovim_lib::{Neovim, NeovimApi}; use nvim::{NeovimClient, ErrorReport}; +use value::ValueMapExt; pub struct Manager { nvim: Option>>, @@ -27,9 +28,47 @@ impl Manager { } } - pub fn get_plugs(&self) { + pub fn get_plugs(&self) -> Result, String> { if let Some(mut nvim) = self.nvim() { - let plugs = nvim.eval("g:plugs"); + let g_plugs = nvim.eval("g:plugs").map_err(|e| { + format!("Can't retrive g:plugs map: {}", e) + })?; + + let plugs_map = g_plugs + .as_map() + .ok_or("Can't retrive g:plugs map".to_owned())? + .to_attrs_map()?; + + let g_plugs_order = nvim.eval("g:plugs_order").map_err(|e| format!("{}", e))?; + + let order_arr = g_plugs_order.as_array().ok_or( + "Can't find g:plugs_order array" + .to_owned(), + )?; + + let plugs_info: Vec = order_arr + .iter() + .map(|n| n.as_str()) + .filter_map(|name| if let Some(name) = name { + plugs_map + .get(name) + .and_then(|desc| desc.as_map()) + .and_then(|desc| desc.to_attrs_map().ok()) + .and_then(|desc| { + let uri = desc.get("uri").and_then(|uri| uri.as_str()); + if let Some(uri) = uri { + Some(VimPlugInfo::new(name.to_owned(), uri.to_owned())) + } else { + None + } + }) + } else { + None + }) + .collect(); + Ok(plugs_info.into_boxed_slice()) + } else { + Err("Nvim not initialized".to_owned()) } } @@ -50,6 +89,18 @@ impl Manager { } } +#[derive(Debug)] +pub struct VimPlugInfo { + pub name: String, + pub uri: String, +} + +impl VimPlugInfo { + pub fn new(name: String, uri: String) -> Self { + VimPlugInfo { name, uri } + } +} + pub enum State { Unknown, AlreadyLoaded, From 15bcb1f25da1f067b9cf633b17a8e51bd7d92d1d Mon Sep 17 00:00:00 2001 From: daa Date: Sat, 21 Oct 2017 20:20:55 +0300 Subject: [PATCH 09/30] List plugins --- src/plug_manager/store.rs | 8 ++++++-- src/plug_manager/ui.rs | 37 ++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index 2f9c9ec..df8de13 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -29,6 +29,10 @@ impl Store { Store { settings } } + + pub fn get_plugs(&self) -> &[PlugInfo] { + &self.settings.plugs + } } #[derive(Serialize, Deserialize)] @@ -56,8 +60,8 @@ impl SettingsLoader for Settings { #[derive(Serialize, Deserialize)] pub struct PlugInfo { - name: String, - url: String, + pub name: String, + pub url: String, } impl PlugInfo { diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index 56e0297..29ab093 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -24,24 +24,25 @@ impl<'a> Ui<'a> { &[("Ok", OK_ID)], ); + dlg.set_default_size(800, 600); let content = dlg.get_content_area(); let tabs = gtk::Notebook::new(); let vim_plug_state = self.get_state(); match vim_plug_state { vim_plug::State::AlreadyLoaded => { - let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); - let warn_lbl = gtk::Label::new( - "vim-plug manager already loaded.\n\ + let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); + let warn_lbl = gtk::Label::new(None); + warn_lbl.set_markup("Note: vim-plug manager already loaded.\n\ NeovimGtk manages plugins using vim-plug as backend.\n\ To allow NeovimGtk manage plugins please disable vim-plug in your configuration.\n\ You can convert vim-plug configuration to NeovimGtk conviguration using button below.\n\ List of current vim-plug plugins can be found in 'Plugins' tab.", ); - get_plugins.add(&warn_lbl); + get_plugins.pack_start(&warn_lbl, true, false, 0); let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); - get_plugins.add(©_btn); + get_plugins.pack_start(©_btn, false, false, 0); let get_plugins_lbl = gtk::Label::new("Help"); tabs.append_page(&get_plugins, Some(&get_plugins_lbl)); @@ -53,7 +54,7 @@ impl<'a> Ui<'a> { } } - let plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); + let plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); let store = self.manager.load_store(&vim_plug_state); self.fill_plugin_list(&plugins, &store); @@ -62,7 +63,7 @@ impl<'a> Ui<'a> { tabs.append_page(&plugins, Some(&plugins_lbl)); tabs.set_tab_pos(gtk::PositionType::Left); - content.add(&tabs); + content.pack_start(&tabs, true, true, 0); content.show_all(); @@ -77,15 +78,25 @@ impl<'a> Ui<'a> { } fn fill_plugin_list(&self, panel: >k::Box, store: &Store) { - let tree = gtk::TreeView::new(); let scroll = gtk::ScrolledWindow::new(None, None); + let plugs_panel = gtk::ListBox::new(); - tree.set_headers_visible(false); - tree.set_can_focus(false); - scroll.set_policy(gtk::PolicyType::Never, gtk::PolicyType::Automatic); - scroll.add(&tree); + for plug_info in store.get_plugs() { + let grid = gtk::Grid::new(); - panel.add(&scroll); + let name_lbl = gtk::Label::new(None); + name_lbl.set_markup(&format!("{}", plug_info.name.as_str())); + name_lbl.set_halign(gtk::Align::Start); + let url_lbl = gtk::Label::new(Some(plug_info.url.as_str())); + + grid.attach(&name_lbl, 0, 0, 1, 1); + grid.attach(&url_lbl, 0, 1, 1, 1); + + plugs_panel.insert(&grid, -1); + } + + scroll.add(&plugs_panel); + panel.pack_start(&scroll, true, true, 0); let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); panel.add(©_btn); From 46c3061a139828d475b75b9202afc985c2ae5731 Mon Sep 17 00:00:00 2001 From: daa Date: Sat, 21 Oct 2017 20:40:55 +0300 Subject: [PATCH 10/30] Small ui improvements --- src/plug_manager/ui.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index 29ab093..b908305 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -33,15 +33,16 @@ impl<'a> Ui<'a> { vim_plug::State::AlreadyLoaded => { let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); let warn_lbl = gtk::Label::new(None); - warn_lbl.set_markup("Note: vim-plug manager already loaded.\n\ - NeovimGtk manages plugins using vim-plug as backend.\n\ - To allow NeovimGtk manage plugins please disable vim-plug in your configuration.\n\ - You can convert vim-plug configuration to NeovimGtk conviguration using button below.\n\ - List of current vim-plug plugins can be found in 'Plugins' tab.", - ); + warn_lbl.set_markup("Note: vim-plug manager already loaded!\n\ + NeovimGtk plugins manager will be disabled.\n\ + To enable it please disable vim-plug in your configuration.\n\ + NeovimGtk manages plugins use vim-plug as backend.\n\ + You can convert vim-plug configuration to NeovimGtk configuration using button below.\n\ + List of current vim-plug plugins can be found in 'Plugins' tab."); get_plugins.pack_start(&warn_lbl, true, false, 0); - let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); + let copy_btn = + gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); get_plugins.pack_start(©_btn, false, false, 0); let get_plugins_lbl = gtk::Label::new("Help"); @@ -83,6 +84,7 @@ impl<'a> Ui<'a> { for plug_info in store.get_plugs() { let grid = gtk::Grid::new(); + grid.set_row_spacing(5); let name_lbl = gtk::Label::new(None); name_lbl.set_markup(&format!("{}", plug_info.name.as_str())); @@ -92,13 +94,17 @@ impl<'a> Ui<'a> { grid.attach(&name_lbl, 0, 0, 1, 1); grid.attach(&url_lbl, 0, 1, 1, 1); + let line = gtk::Separator::new(gtk::Orientation::Horizontal); + grid.attach(&line, 0, 2, 1, 1); + plugs_panel.insert(&grid, -1); } scroll.add(&plugs_panel); panel.pack_start(&scroll, true, true, 0); - let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); + let copy_btn = + gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); panel.add(©_btn); } @@ -106,4 +112,3 @@ impl<'a> Ui<'a> { self.manager.vim_plug.get_state() } } - From ea85f783502a57538e55fcd796e5df946b33371b Mon Sep 17 00:00:00 2001 From: daa84 Date: Mon, 23 Oct 2017 18:07:04 +0300 Subject: [PATCH 11/30] Add remove button --- src/plug_manager/ui.rs | 48 ++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index b908305..b31c026 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -1,3 +1,6 @@ +use std::rc::Rc; +use std::cell::RefCell; + use gtk; use gtk::prelude::*; @@ -31,7 +34,7 @@ impl<'a> Ui<'a> { let vim_plug_state = self.get_state(); match vim_plug_state { vim_plug::State::AlreadyLoaded => { - let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); + let help = gtk::Box::new(gtk::Orientation::Vertical, 3); let warn_lbl = gtk::Label::new(None); warn_lbl.set_markup("Note: vim-plug manager already loaded!\n\ NeovimGtk plugins manager will be disabled.\n\ @@ -39,14 +42,14 @@ impl<'a> Ui<'a> { NeovimGtk manages plugins use vim-plug as backend.\n\ You can convert vim-plug configuration to NeovimGtk configuration using button below.\n\ List of current vim-plug plugins can be found in 'Plugins' tab."); - get_plugins.pack_start(&warn_lbl, true, false, 0); + help.pack_start(&warn_lbl, true, false, 0); let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); - get_plugins.pack_start(©_btn, false, false, 0); + help.pack_start(©_btn, false, false, 0); let get_plugins_lbl = gtk::Label::new("Help"); - tabs.append_page(&get_plugins, Some(&get_plugins_lbl)); + tabs.append_page(&help, Some(&get_plugins_lbl)); } vim_plug::State::Unknown => { let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); @@ -58,7 +61,8 @@ impl<'a> Ui<'a> { let plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); let store = self.manager.load_store(&vim_plug_state); - self.fill_plugin_list(&plugins, &store); + let store = Rc::new(RefCell::new(store)); + Ui::fill_plugin_list(&plugins, &store); let plugins_lbl = gtk::Label::new("Plugins"); tabs.append_page(&plugins, Some(&plugins_lbl)); @@ -78,26 +82,42 @@ impl<'a> Ui<'a> { dlg.destroy(); } - fn fill_plugin_list(&self, panel: >k::Box, store: &Store) { + fn fill_plugin_list(panel: >k::Box, store: &Rc>) { let scroll = gtk::ScrolledWindow::new(None, None); let plugs_panel = gtk::ListBox::new(); + plugs_panel.set_selection_mode(gtk::SelectionMode::None); - for plug_info in store.get_plugs() { - let grid = gtk::Grid::new(); - grid.set_row_spacing(5); + for (idx, plug_info) in store.borrow().get_plugs().iter().enumerate() { + let row = gtk::ListBoxRow::new(); + let row_container = gtk::Box::new(gtk::Orientation::Vertical, 5); + let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 5); + let vbox = gtk::Box::new(gtk::Orientation::Vertical, 5); let name_lbl = gtk::Label::new(None); name_lbl.set_markup(&format!("{}", plug_info.name.as_str())); name_lbl.set_halign(gtk::Align::Start); let url_lbl = gtk::Label::new(Some(plug_info.url.as_str())); + url_lbl.set_halign(gtk::Align::Start); + let remove_btn = gtk::Button::new_with_label("Remove"); + remove_btn.set_halign(gtk::Align::End); - grid.attach(&name_lbl, 0, 0, 1, 1); - grid.attach(&url_lbl, 0, 1, 1, 1); + let store_ref = store.clone(); + let panel_ref = panel.clone(); + let row_ref = row.clone(); + remove_btn.connect_clicked(move |_| { + // store_ref.borrow_mut().remove(idx); + panel_ref.remove(&row_ref); + }); - let line = gtk::Separator::new(gtk::Orientation::Horizontal); - grid.attach(&line, 0, 2, 1, 1); + row_container.pack_start(&hbox, true, true, 0); + row_container.pack_start(>k::Separator::new(gtk::Orientation::Horizontal), true, true, 0); + vbox.pack_start(&name_lbl, true, true, 0); + vbox.pack_start(&url_lbl, true, true, 0); + hbox.pack_start(&vbox, true, true, 0); + hbox.pack_start(&remove_btn, false, true, 0); - plugs_panel.insert(&grid, -1); + row.add(&row_container); + plugs_panel.add(&row); } scroll.add(&plugs_panel); From 2cefb06063ac044524f630dd4f81b386de8319f8 Mon Sep 17 00:00:00 2001 From: daa84 Date: Tue, 24 Oct 2017 18:03:34 +0300 Subject: [PATCH 12/30] Change state management --- src/dirs.rs | 12 +++-- src/plug_manager/manager.rs | 33 +++++++++---- src/plug_manager/store.rs | 4 ++ src/plug_manager/ui.rs | 94 ++++++++++++++++++++++++------------ src/plug_manager/vim_plug.rs | 14 ++---- src/settings.rs | 11 ++++- src/ui.rs | 11 +++-- 7 files changed, 120 insertions(+), 59 deletions(-) diff --git a/src/dirs.rs b/src/dirs.rs index 10ef164..dceccc2 100644 --- a/src/dirs.rs +++ b/src/dirs.rs @@ -4,13 +4,14 @@ use std::path::PathBuf; pub fn get_app_config_dir_create() -> Result { let config_dir = get_app_config_dir()?; - std::fs::create_dir_all(&config_dir) - .map_err(|e| format!("{}", e))?; + std::fs::create_dir_all(&config_dir).map_err( + |e| format!("{}", e), + )?; Ok(config_dir) } -fn get_app_config_dir() -> Result { +pub fn get_app_config_dir() -> Result { let mut config_dir = get_xdg_config_dir()?; config_dir.push("nvim-gtk"); @@ -23,8 +24,9 @@ fn get_xdg_config_dir() -> Result { return Ok(PathBuf::from(config_path)); } - let mut home_dir = std::env::home_dir() - .ok_or("Impossible to get your home dir!")?; + let mut home_dir = std::env::home_dir().ok_or( + "Impossible to get your home dir!", + )?; home_dir.push(".config"); Ok(home_dir) } diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index 05533f9..dda4fc2 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -6,29 +6,42 @@ use super::store::Store; use nvim::NeovimClient; pub struct Manager { - pub vim_plug: vim_plug::Manager, + vim_plug: vim_plug::Manager, + pub plug_manage_state: PlugManageState, } impl Manager { pub fn new() -> Self { Manager { vim_plug: vim_plug::Manager::new(), + plug_manage_state: PlugManageState::Unknown, } } - pub fn initialize(&mut self, nvim: Rc>) { + pub fn generate_plug_config(&mut self) -> Option { + 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>) { self.vim_plug.initialize(nvim); } - pub fn load_store(&self, vim_plug_state: &vim_plug::State) -> Store { - match *vim_plug_state { - vim_plug::State::AlreadyLoaded => { - let store = Store::load_from_plug(&self.vim_plug); - store - } - vim_plug::State::Unknown => { - Store::load() + 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)); } } } } + +pub enum PlugManageState { + NvimGtk(Store), + Configuration(Store), + Unknown, +} diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index df8de13..ab1705c 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -8,6 +8,10 @@ pub struct Store { } impl Store { + pub fn is_config_exists() -> bool { + Settings::is_file_exists() + } + pub fn load() -> Self { Store { settings: Settings::load() } } diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index b31c026..e28ad60 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -1,23 +1,25 @@ -use std::rc::Rc; -use std::cell::RefCell; +use std::sync::Arc; + +use ui::UiMutex; use gtk; use gtk::prelude::*; use super::manager; -use super::vim_plug; use super::store::Store; pub struct Ui<'a> { - manager: &'a manager::Manager, + manager: &'a Arc>, } impl<'a> Ui<'a> { - pub fn new(manager: &'a manager::Manager) -> Ui<'a> { + pub fn new(manager: &'a Arc>) -> Ui<'a> { + manager.borrow_mut().update_state(); + Ui { manager } } - pub fn show>(&self, parent: &T) { + pub fn show>(&mut self, parent: &T) { const OK_ID: i32 = 0; let dlg = gtk::Dialog::new_with_buttons( @@ -31,41 +33,52 @@ impl<'a> Ui<'a> { let content = dlg.get_content_area(); let tabs = gtk::Notebook::new(); - let vim_plug_state = self.get_state(); - match vim_plug_state { - vim_plug::State::AlreadyLoaded => { + match self.manager.borrow_mut().plug_manage_state { + manager::PlugManageState::Unknown => { let help = gtk::Box::new(gtk::Orientation::Vertical, 3); let warn_lbl = gtk::Label::new(None); - warn_lbl.set_markup("Note: vim-plug manager already loaded!\n\ - NeovimGtk plugins manager will be disabled.\n\ - To enable it please disable vim-plug in your configuration.\n\ - NeovimGtk manages plugins use vim-plug as backend.\n\ - You can convert vim-plug configuration to NeovimGtk configuration using button below.\n\ + warn_lbl.set_markup("Note: NeovimGtk plugin manager disabled!"); + help.pack_start(&warn_lbl, true, false, 0); + + let enable_btn = gtk::Button::new_with_label("Enable NeovimGtk plugin manager"); + help.pack_start(&enable_btn, false, false, 0); + + let get_plugins_lbl = gtk::Label::new("Help"); + tabs.append_page(&help, Some(&get_plugins_lbl)); + } + manager::PlugManageState::Configuration(ref store) => { + let help = gtk::Box::new(gtk::Orientation::Vertical, 3); + let warn_lbl = gtk::Label::new(None); + warn_lbl.set_markup("Note: NeovimGtk plugin manager disabled!\n\ + NeovimGtk manages plugins use vim-plug as backend, so enable it disables vim-plug configuration.\n\ + You can convert current vim-plug configuration to NeovimGtk configuration using button below.\n\ List of current vim-plug plugins can be found in 'Plugins' tab."); help.pack_start(&warn_lbl, true, false, 0); + let enable_btn = gtk::Button::new_with_label( + "Enable NeovimGtk plugin manager, empty configuration", + ); + help.pack_start(&enable_btn, false, false, 0); + let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); help.pack_start(©_btn, false, false, 0); let get_plugins_lbl = gtk::Label::new("Help"); tabs.append_page(&help, Some(&get_plugins_lbl)); + + + self.add_plugin_list_tab(&tabs, store); } - vim_plug::State::Unknown => { + manager::PlugManageState::NvimGtk(ref store) => { let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); let get_plugins_lbl = gtk::Label::new("Get Plugins"); tabs.append_page(&get_plugins, Some(&get_plugins_lbl)); + + self.add_plugin_list_tab(&tabs, store); } } - let plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); - let store = self.manager.load_store(&vim_plug_state); - - let store = Rc::new(RefCell::new(store)); - Ui::fill_plugin_list(&plugins, &store); - - let plugins_lbl = gtk::Label::new("Plugins"); - tabs.append_page(&plugins, Some(&plugins_lbl)); tabs.set_tab_pos(gtk::PositionType::Left); content.pack_start(&tabs, true, true, 0); @@ -82,12 +95,21 @@ impl<'a> Ui<'a> { dlg.destroy(); } - fn fill_plugin_list(panel: >k::Box, store: &Rc>) { + fn add_plugin_list_tab(&self, tabs: >k::Notebook, store: &Store) { + // Plugins + let plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); + self.fill_plugin_list(&plugins, store); + + let plugins_lbl = gtk::Label::new("Plugins"); + tabs.append_page(&plugins, Some(&plugins_lbl)); + } + + fn fill_plugin_list(&self, panel: >k::Box, store: &Store) { let scroll = gtk::ScrolledWindow::new(None, None); let plugs_panel = gtk::ListBox::new(); plugs_panel.set_selection_mode(gtk::SelectionMode::None); - for (idx, plug_info) in store.borrow().get_plugs().iter().enumerate() { + for (idx, plug_info) in store.get_plugs().iter().enumerate() { let row = gtk::ListBoxRow::new(); let row_container = gtk::Box::new(gtk::Orientation::Vertical, 5); let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 5); @@ -106,11 +128,21 @@ impl<'a> Ui<'a> { let row_ref = row.clone(); remove_btn.connect_clicked(move |_| { // store_ref.borrow_mut().remove(idx); - panel_ref.remove(&row_ref); + row_ref.remove(row_ref.get_child().as_ref().unwrap()); + let undo_btn = gtk::Button::new_with_label("Undo"); + let row_container = gtk::Box::new(gtk::Orientation::Horizontal, 5); + row_container.pack_end(&undo_btn, false, true, 0); + row_ref.add(&row_container); + row_container.show_all(); }); row_container.pack_start(&hbox, true, true, 0); - row_container.pack_start(>k::Separator::new(gtk::Orientation::Horizontal), true, true, 0); + row_container.pack_start( + >k::Separator::new(gtk::Orientation::Horizontal), + true, + true, + 0, + ); vbox.pack_start(&name_lbl, true, true, 0); vbox.pack_start(&url_lbl, true, true, 0); hbox.pack_start(&vbox, true, true, 0); @@ -123,12 +155,12 @@ impl<'a> Ui<'a> { scroll.add(&plugs_panel); panel.pack_start(&scroll, true, true, 0); + let enable_btn = + gtk::Button::new_with_label("Enable NeovimGtk plugin manager, empty configuration"); + panel.add(&enable_btn); + let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); panel.add(©_btn); } - - fn get_state(&self) -> vim_plug::State { - self.manager.vim_plug.get_state() - } } diff --git a/src/plug_manager/vim_plug.rs b/src/plug_manager/vim_plug.rs index 9b74718..d878d65 100644 --- a/src/plug_manager/vim_plug.rs +++ b/src/plug_manager/vim_plug.rs @@ -72,19 +72,19 @@ impl Manager { } } - pub fn get_state(&self) -> State { + pub fn is_loaded(&self) -> bool { if let Some(mut nvim) = self.nvim() { let loaded_plug = nvim.eval("exists('g:loaded_plug')"); loaded_plug .ok_and_report(&mut *nvim) .and_then(|loaded_plug| loaded_plug.as_i64()) - .map_or(State::Unknown, |loaded_plug| if loaded_plug > 0 { - State::AlreadyLoaded + .map_or(false, |loaded_plug| if loaded_plug > 0 { + true } else { - State::Unknown + false }) } else { - State::Unknown + false } } } @@ -101,7 +101,3 @@ impl VimPlugInfo { } } -pub enum State { - Unknown, - AlreadyLoaded, -} diff --git a/src/settings.rs b/src/settings.rs index edc0319..6799e5a 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -128,10 +128,19 @@ pub trait SettingsLoader: Sized + serde::Serialize { } } + fn is_file_exists() -> bool { + if let Ok(mut toml_path) = dirs::get_app_config_dir() { + toml_path.push(Self::SETTINGS_FILE); + toml_path.is_file() + } else { + false + } + } + fn save(&self) { match save_err(self) { Ok(()) => (), - Err(e) => println!("{}", e), + Err(e) => error!("{}", e), } } } diff --git a/src/ui.rs b/src/ui.rs index 6c18f8c..d2b8ae8 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -132,8 +132,13 @@ impl Ui { let comps_ref = self.comps.clone(); let plug_manager_ref = self.plug_manager.clone(); plug_btn.connect_clicked(move |_| { - plug_manager::Ui::new(&mut *plug_manager_ref.borrow_mut()) - .show(comps_ref.borrow().window.as_ref().unwrap()) + plug_manager::Ui::new(&plug_manager_ref).show( + comps_ref + .borrow() + .window + .as_ref() + .unwrap(), + ) }); header_bar.pack_start(&plug_btn); @@ -168,7 +173,7 @@ impl Ui { let state_ref = self.shell.borrow().state.clone(); let plug_manager_ref = self.plug_manager.clone(); shell.set_nvim_started_cb(Some(move || { - plug_manager_ref.borrow_mut().initialize( + plug_manager_ref.borrow_mut().init_nvim_client( state_ref.borrow().nvim_clone(), ); })); From ba179f715d0a1dd46035cad48fa90101dd820456 Mon Sep 17 00:00:00 2001 From: daa84 Date: Thu, 26 Oct 2017 17:56:53 +0300 Subject: [PATCH 13/30] Generate and use plug-vim config on nvim startup --- Cargo.lock | 36 +++++++++++++++++++++++++++++ Cargo.toml | 2 ++ src/dirs.rs | 1 + src/main.rs | 3 +++ src/nvim.rs | 8 +++++++ src/nvim_config.rs | 45 +++++++++++++++++++++++++++++++++++++ src/plug_manager/manager.rs | 29 +++++++++++++++++++++--- src/plug_manager/mod.rs | 2 +- src/plug_manager/store.rs | 35 ++++++++++++++++++++++++++++- src/shell.rs | 15 ++++++++----- src/ui.rs | 9 ++++++-- 11 files changed, 173 insertions(+), 12 deletions(-) create mode 100644 src/nvim_config.rs diff --git a/Cargo.lock b/Cargo.lock index 5cefe3b..e2b71bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,6 +22,7 @@ dependencies = [ "phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -277,6 +278,15 @@ name = "htmlescape" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "lazy_static" version = "0.2.8" @@ -437,6 +447,11 @@ dependencies = [ "magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "redox_syscall" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "regex" version = "0.2.2" @@ -519,6 +534,18 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tempfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "thread_local" version = "0.3.4" @@ -573,6 +600,11 @@ name = "winapi" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [metadata] "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699" "checksum atk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c69658a4e18d5c9575f716e24559645d08a4044d6946c30c2e0025952c84d842" @@ -598,6 +630,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gtk 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce17f98e7dcdc9d06b3a5f7621d796a24937c04953481205b1be267c5a02697a" "checksum gtk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "854b56ce6d6b05945f7735651482835c5ac1f8582142ce67306726259a3dafb0" "checksum htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" "checksum libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "8a014d9226c2cc402676fbe9ea2e15dd5222cd1dd57f576b5b283178c944a264" "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" @@ -617,6 +650,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "eb250fd207a4729c976794d03db689c9be1d634ab5a1c9da9492a13d8fecbcdf" +"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" "checksum rmp 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7ce560a5728f4eec697f07f8d7fa20608893d44b4f5b8f9f5f51a2987f3cffe2" @@ -627,6 +661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" +"checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0" "checksum thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" @@ -635,3 +670,4 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/Cargo.toml b/Cargo.toml index bef06e6..1a49913 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,8 @@ serde = "1.0" serde_derive = "1.0" toml = "0.4" +tempfile = "2.2.0" + #[dependencies.neovim-lib] #git = "https://github.com/daa84/neovim-lib" diff --git a/src/dirs.rs b/src/dirs.rs index dceccc2..3380a65 100644 --- a/src/dirs.rs +++ b/src/dirs.rs @@ -30,3 +30,4 @@ fn get_xdg_config_dir() -> Result { home_dir.push(".config"); Ok(home_dir) } + diff --git a/src/main.rs b/src/main.rs index c48713e..f0bd6f1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,8 +23,11 @@ extern crate serde; extern crate serde_derive; extern crate toml; +extern crate tempfile; + mod sys; +mod nvim_config; mod dirs; mod color; mod value; diff --git a/src/nvim.rs b/src/nvim.rs index 4290f69..ba33392 100644 --- a/src/nvim.rs +++ b/src/nvim.rs @@ -13,6 +13,7 @@ use ui::UiMutex; use ui_model::{ModelRect, ModelRectVec}; use shell; use glib; +use nvim_config::NvimConfig; use value::ValueMapExt; @@ -227,6 +228,7 @@ impl error::Error for NvimInitError { pub fn start( shell: Arc>, nvim_bin_path: Option<&String>, + nvim_config: NvimConfig, ) -> result::Result { let mut cmd = if let Some(path) = nvim_bin_path { Command::new(path) @@ -257,6 +259,12 @@ pub fn start( cmd.arg("--cmd").arg("let &rtp.=',runtime'"); } + if let Some(nvim_config) = nvim_config.generate_config() { + if let Some(path) = nvim_config.path().to_str() { + cmd.arg("--cmd").arg(format!("source '{}'", path)); + } + } + let session = Session::new_child_cmd(&mut cmd); let session = match session { diff --git a/src/nvim_config.rs b/src/nvim_config.rs new file mode 100644 index 0000000..4a0a579 --- /dev/null +++ b/src/nvim_config.rs @@ -0,0 +1,45 @@ +use std; +use std::fs::File; +use std::io::Write; + +use tempfile; +use plug_manager; + +#[derive(Clone)] +pub struct NvimConfig { + plug_config: Option, +} + +impl NvimConfig { + pub fn new(plug_config: Option) -> Self { + NvimConfig { plug_config } + } + + pub fn generate_config(&self) -> Option { + if self.plug_config.is_some() { + match self.write_file() { + Err(err) => { + error!("{}", err); + None + } + Ok(file) => Some(file), + } + } else { + None + } + } + + fn write_file(&self) -> std::io::Result { + let temp_file = tempfile::NamedTempFile::new()?; + { + let mut file: &File = &temp_file; + let content = &self.plug_config.as_ref().unwrap().source; + if !content.is_empty() { + file.write_all(content.as_bytes())?; + } + + file.sync_data()?; + } + Ok(temp_file) + } +} diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index dda4fc2..20b9346 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -3,6 +3,7 @@ use std::cell::RefCell; use super::vim_plug; use super::store::Store; + use nvim::NeovimClient; pub struct Manager { @@ -18,10 +19,12 @@ impl Manager { } } - pub fn generate_plug_config(&mut self) -> Option { + pub fn load_config(&mut self) -> Option { if Store::is_config_exists() { - self.plug_manage_state = PlugManageState::NvimGtk(Store::load()); - Some("TODO".to_owned()) + let store = Store::load(); + let config = PlugManagerConfigSource::new(&store); + self.plug_manage_state = PlugManageState::NvimGtk(store); + Some(config) } else { None } @@ -45,3 +48,23 @@ pub enum PlugManageState { Configuration(Store), Unknown, } + +#[derive(Clone)] +pub struct PlugManagerConfigSource { + pub source: String, +} + +impl PlugManagerConfigSource { + pub fn new(store: &Store) -> Self { + let mut builder = "call plug#begin()".to_owned(); + + for plug in store.get_plugs() { + builder += &format!("Plug '{}'", plug.get_plug_path()); + } + + builder += "call plug#end()"; + + PlugManagerConfigSource { source: builder } + } +} + diff --git a/src/plug_manager/mod.rs b/src/plug_manager/mod.rs index 647f6f4..7ed9f71 100644 --- a/src/plug_manager/mod.rs +++ b/src/plug_manager/mod.rs @@ -4,4 +4,4 @@ mod store; mod manager; pub use self::ui::Ui; -pub use self::manager::Manager; +pub use self::manager::{Manager, PlugManagerConfigSource}; diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index ab1705c..bc0accf 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -66,10 +66,43 @@ impl SettingsLoader for Settings { pub struct PlugInfo { pub name: String, pub url: String, + pub removed: bool, } impl PlugInfo { pub fn new(name: String, url: String) -> Self { - PlugInfo { name, url } + PlugInfo { + name, + url, + removed: false, + } + } + + pub fn get_plug_path(&self) -> String { + if self.url.contains("github.com") { + let mut path_comps: Vec<&str> = self.url + .trim_right_matches(".git") + .rsplit('/') + .take(2) + .collect(); + path_comps.reverse(); + path_comps.join("/") + } else { + self.url.clone() + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_get_plug_path() { + let plug = PlugInfo::new( + "rust.vim".to_owned(), + "https://git::@github.com/rust-lang/rust.vim.git".to_owned(), + ); + assert_eq!("rust-lang/rust.vim".to_owned(), plug.get_plug_path()); } } diff --git a/src/shell.rs b/src/shell.rs index 10facfb..70af8d1 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -22,6 +22,7 @@ use ui_model::{UiModel, Attrs, ModelRect}; use color::{ColorModel, Color, COLOR_BLACK, COLOR_WHITE, COLOR_RED}; use nvim; use nvim::{RedrawEvents, GuiApi, RepaintMode, ErrorReport, NeovimClient}; +use nvim_config::NvimConfig; use input; use input::keyval_to_input_string; use cursor::Cursor; @@ -77,13 +78,14 @@ pub struct State { resize_state: Rc>, options: ShellOptions, + nvim_config: NvimConfig, detach_cb: Option>>, nvim_started_cb: Option>>, } impl State { - pub fn new(settings: Rc>, options: ShellOptions) -> State { + pub fn new(settings: Rc>, options: ShellOptions, nvim_config: NvimConfig) -> State { let drawing_area = gtk::DrawingArea::new(); let popup_menu = RefCell::new(PopupMenu::new(&drawing_area)); let font_ctx = render::Context::new(FontDescription::from_string(DEFAULT_FONT_NAME)); @@ -111,6 +113,7 @@ impl State { resize_state: Rc::new(Cell::new(ResizeState::Wait)), options, + nvim_config, detach_cb: None, nvim_started_cb: None, @@ -390,9 +393,9 @@ pub struct Shell { } impl Shell { - pub fn new(settings: Rc>, options: ShellOptions) -> Shell { + pub fn new(settings: Rc>, options: ShellOptions, nvim_config: NvimConfig) -> Shell { let shell = Shell { - state: Arc::new(UiMutex::new(State::new(settings, options))), + state: Arc::new(UiMutex::new(State::new(settings, options, nvim_config))), ui_state: Rc::new(RefCell::new(UiState::new())), widget: gtk::Box::new(gtk::Orientation::Vertical, 0), @@ -765,11 +768,12 @@ fn show_nvim_init_error(err: &nvim::NvimInitError, state_arc: Arc fn init_nvim_async( state_arc: Arc>, options: ShellOptions, + nvim_config: NvimConfig, cols: usize, rows: usize, ) { // execute nvim - let mut nvim = match nvim::start(state_arc.clone(), options.nvim_bin_path.as_ref()) { + let mut nvim = match nvim::start(state_arc.clone(), options.nvim_bin_path.as_ref(), nvim_config) { Ok(nvim) => nvim, Err(err) => { show_nvim_start_error(&err, state_arc); @@ -864,7 +868,8 @@ fn init_nvim(state_ref: &Arc>) { let state_arc = state_ref.clone(); let options = state.options.clone(); - thread::spawn(move || init_nvim_async(state_arc, options, cols, rows)); + let nvim_config = state.nvim_config.clone(); + thread::spawn(move || init_nvim_async(state_arc, options, nvim_config, cols, rows)); } } diff --git a/src/ui.rs b/src/ui.rs index d2b8ae8..1f2ce02 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -10,6 +10,7 @@ use gtk::{ApplicationWindow, HeaderBar, ToolButton, Image, AboutDialog}; use gio::prelude::*; use gio::{Menu, MenuExt, MenuItem, MenuItemExt, SimpleAction}; +use nvim_config::NvimConfig; use settings::Settings; use shell::{Shell, ShellOptions}; use shell_dlg; @@ -52,13 +53,17 @@ impl Components { impl Ui { pub fn new(options: ShellOptions) -> Ui { + let mut plug_manager = plug_manager::Manager::new(); + let plug_config = plug_manager.load_config(); + + let nvim_config = NvimConfig::new(plug_config); + let plug_manager = Arc::new(UiMutex::new(plug_manager)); let comps = Arc::new(UiMutex::new(Components::new())); let settings = Rc::new(RefCell::new(Settings::new())); - let shell = Rc::new(RefCell::new(Shell::new(settings.clone(), options))); + let shell = Rc::new(RefCell::new(Shell::new(settings.clone(), options, nvim_config))); settings.borrow_mut().set_shell(Rc::downgrade(&shell)); let projects = Projects::new(&comps.borrow().open_btn, shell.clone()); - let plug_manager = Arc::new(UiMutex::new(plug_manager::Manager::new())); Ui { initialized: false, From ae5d46eb6a813136ffee9eae51012e9de9eace9e Mon Sep 17 00:00:00 2001 From: daa84 Date: Fri, 27 Oct 2017 18:06:18 +0300 Subject: [PATCH 14/30] Add enable button, remove unneeded buttons --- src/plug_manager/store.rs | 5 +++-- src/plug_manager/ui.rs | 33 +++++++++------------------------ 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index bc0accf..e201212 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -42,11 +42,12 @@ impl Store { #[derive(Serialize, Deserialize)] struct Settings { plugs: Vec, + enabled: bool, } impl Settings { fn new(plugs: Vec) -> Self { - Settings { plugs } + Settings { plugs, enabled: false } } } @@ -54,7 +55,7 @@ impl SettingsLoader for Settings { const SETTINGS_FILE: &'static str = "plugs.toml"; fn empty() -> Self { - Settings { plugs: vec![] } + Settings { plugs: vec![], enabled: false } } fn from_str(s: &str) -> Result { diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index e28ad60..d171018 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -31,7 +31,12 @@ impl<'a> Ui<'a> { dlg.set_default_size(800, 600); let content = dlg.get_content_area(); + let top_panel = gtk::Box::new(gtk::Orientation::Horizontal, 3); + let tabs = gtk::Notebook::new(); + tabs.set_tab_pos(gtk::PositionType::Left); + + let enable_swc = gtk::Switch::new(); match self.manager.borrow_mut().plug_manage_state { manager::PlugManageState::Unknown => { @@ -40,9 +45,6 @@ impl<'a> Ui<'a> { warn_lbl.set_markup("Note: NeovimGtk plugin manager disabled!"); help.pack_start(&warn_lbl, true, false, 0); - let enable_btn = gtk::Button::new_with_label("Enable NeovimGtk plugin manager"); - help.pack_start(&enable_btn, false, false, 0); - let get_plugins_lbl = gtk::Label::new("Help"); tabs.append_page(&help, Some(&get_plugins_lbl)); } @@ -50,20 +52,9 @@ impl<'a> Ui<'a> { let help = gtk::Box::new(gtk::Orientation::Vertical, 3); let warn_lbl = gtk::Label::new(None); warn_lbl.set_markup("Note: NeovimGtk plugin manager disabled!\n\ - NeovimGtk manages plugins use vim-plug as backend, so enable it disables vim-plug configuration.\n\ - You can convert current vim-plug configuration to NeovimGtk configuration using button below.\n\ - List of current vim-plug plugins can be found in 'Plugins' tab."); + NeovimGtk manages plugins use vim-plug as backend, so enable it disables vim-plug configuration."); help.pack_start(&warn_lbl, true, false, 0); - let enable_btn = gtk::Button::new_with_label( - "Enable NeovimGtk plugin manager, empty configuration", - ); - help.pack_start(&enable_btn, false, false, 0); - - let copy_btn = - gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); - help.pack_start(©_btn, false, false, 0); - let get_plugins_lbl = gtk::Label::new("Help"); tabs.append_page(&help, Some(&get_plugins_lbl)); @@ -80,7 +71,9 @@ impl<'a> Ui<'a> { } - tabs.set_tab_pos(gtk::PositionType::Left); + top_panel.pack_end(&enable_swc, false, false, 0); + + content.pack_start(&top_panel, false, true, 3); content.pack_start(&tabs, true, true, 0); content.show_all(); @@ -154,13 +147,5 @@ impl<'a> Ui<'a> { scroll.add(&plugs_panel); panel.pack_start(&scroll, true, true, 0); - - let enable_btn = - gtk::Button::new_with_label("Enable NeovimGtk plugin manager, empty configuration"); - panel.add(&enable_btn); - - let copy_btn = - gtk::Button::new_with_label("Copy plugins from current vim-plug configuration"); - panel.add(©_btn); } } From b07196f980d7af4fe814defaa4ec5c8b34c763e1 Mon Sep 17 00:00:00 2001 From: daa Date: Sat, 28 Oct 2017 23:18:42 +0300 Subject: [PATCH 15/30] Ui refactoring --- src/plug_manager/ui.rs | 107 ++++++++++++++++++++++++++++++++++------- 1 file changed, 90 insertions(+), 17 deletions(-) diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index d171018..9d92ef5 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -1,4 +1,7 @@ use std::sync::Arc; +use std::rc::Rc; +use std::cell::RefCell; +use std::ops::Deref; use ui::UiMutex; @@ -31,12 +34,20 @@ impl<'a> Ui<'a> { dlg.set_default_size(800, 600); let content = dlg.get_content_area(); - let top_panel = gtk::Box::new(gtk::Orientation::Horizontal, 3); - let tabs = gtk::Notebook::new(); - tabs.set_tab_pos(gtk::PositionType::Left); + let header_bar = gtk::HeaderBar::new(); let enable_swc = gtk::Switch::new(); + enable_swc.set_valign(gtk::Align::Center); + header_bar.pack_end(&enable_swc); + + header_bar.set_title("Plug"); + header_bar.set_show_close_button(true); + header_bar.show_all(); + + dlg.set_titlebar(&header_bar); + + let pages = SettingsPages::new(); match self.manager.borrow_mut().plug_manage_state { manager::PlugManageState::Unknown => { @@ -45,8 +56,8 @@ impl<'a> Ui<'a> { warn_lbl.set_markup("Note: NeovimGtk plugin manager disabled!"); help.pack_start(&warn_lbl, true, false, 0); - let get_plugins_lbl = gtk::Label::new("Help"); - tabs.append_page(&help, Some(&get_plugins_lbl)); + let help_lbl = gtk::Label::new("Help"); + pages.add_page(&help_lbl, &help, "help"); } manager::PlugManageState::Configuration(ref store) => { let help = gtk::Box::new(gtk::Orientation::Vertical, 3); @@ -55,26 +66,23 @@ impl<'a> Ui<'a> { NeovimGtk manages plugins use vim-plug as backend, so enable it disables vim-plug configuration."); help.pack_start(&warn_lbl, true, false, 0); - let get_plugins_lbl = gtk::Label::new("Help"); - tabs.append_page(&help, Some(&get_plugins_lbl)); + let help_lbl = gtk::Label::new("Help"); + pages.add_page(&help_lbl, &help, "help"); - - self.add_plugin_list_tab(&tabs, store); + self.add_plugin_list_tab(&pages, store); } manager::PlugManageState::NvimGtk(ref store) => { let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); + // TODO: let get_plugins_lbl = gtk::Label::new("Get Plugins"); - tabs.append_page(&get_plugins, Some(&get_plugins_lbl)); + pages.add_page(&get_plugins_lbl, &get_plugins, "get_plugins"); - self.add_plugin_list_tab(&tabs, store); + self.add_plugin_list_tab(&pages, store); } } - top_panel.pack_end(&enable_swc, false, false, 0); - - content.pack_start(&top_panel, false, true, 3); - content.pack_start(&tabs, true, true, 0); + content.pack_start(&*pages, true, true, 0); content.show_all(); @@ -88,13 +96,13 @@ impl<'a> Ui<'a> { dlg.destroy(); } - fn add_plugin_list_tab(&self, tabs: >k::Notebook, store: &Store) { + fn add_plugin_list_tab(&self, pages: &SettingsPages, store: &Store) { // Plugins let plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); self.fill_plugin_list(&plugins, store); let plugins_lbl = gtk::Label::new("Plugins"); - tabs.append_page(&plugins, Some(&plugins_lbl)); + pages.add_page(&plugins_lbl, &plugins, "plugins"); } fn fill_plugin_list(&self, panel: >k::Box, store: &Store) { @@ -149,3 +157,68 @@ impl<'a> Ui<'a> { panel.pack_start(&scroll, true, true, 0); } } + +struct SettingsPages { + categories: gtk::ListBox, + stack: gtk::Stack, + content: gtk::Box, + rows: Rc>>, +} + +impl SettingsPages { + pub fn new() -> Self { + let content = gtk::Box::new(gtk::Orientation::Horizontal, 3); + let categories = gtk::ListBox::new(); + let stack = gtk::Stack::new(); + stack.set_transition_type(gtk::StackTransitionType::Crossfade); + let rows: Rc>> = + Rc::new(RefCell::new(Vec::new())); + + content.pack_start(&categories, false, true, 0); + content.pack_start(&stack, true, true, 0); + + let rows_ref = rows.clone(); + let stack_ref = stack.clone(); + categories.connect_row_selected(move |_, row| if let &Some(ref row) = row { + if let Some(ref r) = rows_ref.borrow().iter().find(|r| r.0 == *row) { + if let Some(child) = stack_ref.get_child_by_name(&r.1) { + stack_ref.set_visible_child(&child); + } + + } + }); + + SettingsPages { + categories, + stack, + content, + rows, + } + } + + fn add_page>( + &self, + label: >k::Label, + widget: &W, + name: &'static str, + ) { + let row = gtk::ListBoxRow::new(); + + let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 0); + hbox.set_border_width(12); + hbox.pack_start(label, false, true, 0); + row.add(&hbox); + + self.categories.add(&row); + self.stack.add_named(widget, name); + self.rows.borrow_mut().push((row, name)); + } +} + +impl Deref for SettingsPages { + type Target = gtk::Box; + + fn deref(&self) -> >k::Box { + &self.content + } +} From db9bbc03f3701d4e239dfe45d28c07930e1aa146 Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 29 Oct 2017 00:28:32 +0300 Subject: [PATCH 16/30] Small ui update --- src/plug_manager/ui.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index 9d92ef5..8a2f905 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -107,12 +107,14 @@ impl<'a> Ui<'a> { fn fill_plugin_list(&self, panel: >k::Box, store: &Store) { let scroll = gtk::ScrolledWindow::new(None, None); + scroll.get_style_context().map(|c| c.add_class("view")); let plugs_panel = gtk::ListBox::new(); plugs_panel.set_selection_mode(gtk::SelectionMode::None); for (idx, plug_info) in store.get_plugs().iter().enumerate() { let row = gtk::ListBoxRow::new(); let row_container = gtk::Box::new(gtk::Orientation::Vertical, 5); + row_container.set_border_width(5); let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 5); let vbox = gtk::Box::new(gtk::Orientation::Vertical, 5); @@ -138,12 +140,6 @@ impl<'a> Ui<'a> { }); row_container.pack_start(&hbox, true, true, 0); - row_container.pack_start( - >k::Separator::new(gtk::Orientation::Horizontal), - true, - true, - 0, - ); vbox.pack_start(&name_lbl, true, true, 0); vbox.pack_start(&url_lbl, true, true, 0); hbox.pack_start(&vbox, true, true, 0); @@ -167,8 +163,9 @@ struct SettingsPages { impl SettingsPages { pub fn new() -> Self { - let content = gtk::Box::new(gtk::Orientation::Horizontal, 3); + let content = gtk::Box::new(gtk::Orientation::Horizontal, 5); let categories = gtk::ListBox::new(); + categories.get_style_context().map(|c| c.add_class("view")); let stack = gtk::Stack::new(); stack.set_transition_type(gtk::StackTransitionType::Crossfade); let rows: Rc>> = From 512b63a37af42dd763c0a29205de6f5667f61d87 Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 29 Oct 2017 13:55:36 +0300 Subject: [PATCH 17/30] Load configuration on nvim startup/ small ui updates --- Cargo.lock | 36 ------------------------- Cargo.toml | 2 -- src/main.rs | 2 -- src/nvim.rs | 4 +-- src/nvim_config.rs | 37 +++++++++++++++---------- src/plug_manager/manager.rs | 45 ++++++++++++++++++++++++------- src/plug_manager/store.rs | 14 +++++++++- src/plug_manager/ui.rs | 54 +++++++++++++++++++++++-------------- 8 files changed, 107 insertions(+), 87 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2b71bc..5cefe3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,6 @@ dependencies = [ "phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -278,15 +277,6 @@ name = "htmlescape" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "lazy_static" version = "0.2.8" @@ -447,11 +437,6 @@ dependencies = [ "magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "redox_syscall" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "regex" version = "0.2.2" @@ -534,18 +519,6 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tempfile" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "thread_local" version = "0.3.4" @@ -600,11 +573,6 @@ name = "winapi" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [metadata] "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699" "checksum atk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c69658a4e18d5c9575f716e24559645d08a4044d6946c30c2e0025952c84d842" @@ -630,7 +598,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gtk 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce17f98e7dcdc9d06b3a5f7621d796a24937c04953481205b1be267c5a02697a" "checksum gtk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "854b56ce6d6b05945f7735651482835c5ac1f8582142ce67306726259a3dafb0" "checksum htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" "checksum libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "8a014d9226c2cc402676fbe9ea2e15dd5222cd1dd57f576b5b283178c944a264" "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" @@ -650,7 +617,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "eb250fd207a4729c976794d03db689c9be1d634ab5a1c9da9492a13d8fecbcdf" -"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" "checksum rmp 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7ce560a5728f4eec697f07f8d7fa20608893d44b4f5b8f9f5f51a2987f3cffe2" @@ -661,7 +627,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -"checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0" "checksum thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" @@ -670,4 +635,3 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/Cargo.toml b/Cargo.toml index 1a49913..bef06e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,8 +35,6 @@ serde = "1.0" serde_derive = "1.0" toml = "0.4" -tempfile = "2.2.0" - #[dependencies.neovim-lib] #git = "https://github.com/daa84/neovim-lib" diff --git a/src/main.rs b/src/main.rs index f0bd6f1..7cc148f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,8 +23,6 @@ extern crate serde; extern crate serde_derive; extern crate toml; -extern crate tempfile; - mod sys; mod nvim_config; diff --git a/src/nvim.rs b/src/nvim.rs index ba33392..aef6c11 100644 --- a/src/nvim.rs +++ b/src/nvim.rs @@ -260,8 +260,8 @@ pub fn start( } if let Some(nvim_config) = nvim_config.generate_config() { - if let Some(path) = nvim_config.path().to_str() { - cmd.arg("--cmd").arg(format!("source '{}'", path)); + if let Some(path) = nvim_config.to_str() { + cmd.arg("--cmd").arg(format!("source {}", path)); } } diff --git a/src/nvim_config.rs b/src/nvim_config.rs index 4a0a579..c0d328a 100644 --- a/src/nvim_config.rs +++ b/src/nvim_config.rs @@ -1,8 +1,8 @@ -use std; -use std::fs::File; +use std::path::PathBuf; +use std::fs::OpenOptions; use std::io::Write; -use tempfile; +use dirs; use plug_manager; #[derive(Clone)] @@ -15,7 +15,7 @@ impl NvimConfig { NvimConfig { plug_config } } - pub fn generate_config(&self) -> Option { + pub fn generate_config(&self) -> Option { if self.plug_config.is_some() { match self.write_file() { Err(err) => { @@ -29,17 +29,26 @@ impl NvimConfig { } } - fn write_file(&self) -> std::io::Result { - let temp_file = tempfile::NamedTempFile::new()?; - { - let mut file: &File = &temp_file; - let content = &self.plug_config.as_ref().unwrap().source; - if !content.is_empty() { - file.write_all(content.as_bytes())?; - } + fn write_file(&self) -> Result { + let mut config_dir = dirs::get_app_config_dir_create()?; + config_dir.push("plugins.vim"); - file.sync_data()?; + let mut file = OpenOptions::new() + .create(true) + .write(true) + .truncate(true) + .open(&config_dir) + .map_err(|e| format!("{}", e))?; + + let content = &self.plug_config.as_ref().unwrap().source; + if !content.is_empty() { + debug!("{}", content); + file.write_all(content.as_bytes()).map_err( + |e| format!("{}", e), + )?; } - Ok(temp_file) + + file.sync_all().map_err(|e| format!("{}", e))?; + Ok(config_dir) } } diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index 20b9346..7a54462 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -13,7 +13,7 @@ pub struct Manager { impl Manager { pub fn new() -> Self { - Manager { + Manager { vim_plug: vim_plug::Manager::new(), plug_manage_state: PlugManageState::Unknown, } @@ -22,9 +22,14 @@ impl Manager { pub fn load_config(&mut self) -> Option { if Store::is_config_exists() { let store = Store::load(); - let config = PlugManagerConfigSource::new(&store); - self.plug_manage_state = PlugManageState::NvimGtk(store); - Some(config) + if store.is_enabled() { + let config = PlugManagerConfigSource::new(&store); + self.plug_manage_state = PlugManageState::NvimGtk(store); + Some(config) + } else { + self.plug_manage_state = PlugManageState::NvimGtk(store); + None + } } else { None } @@ -37,15 +42,36 @@ impl Manager { 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)); + self.plug_manage_state = + PlugManageState::VimPlug(Store::load_from_plug(&self.vim_plug)); } } } + + pub fn store_mut(&mut self) -> Option<&mut Store> { + match self.plug_manage_state { + PlugManageState::NvimGtk(ref mut store) => Some(store), + PlugManageState::VimPlug(ref mut store) => Some(store), + PlugManageState::Unknown => None, + } + } + + pub fn store(&self) -> Option<&Store> { + match self.plug_manage_state { + PlugManageState::NvimGtk(ref store) => Some(store), + PlugManageState::VimPlug(ref store) => Some(store), + PlugManageState::Unknown => None, + } + } + + pub fn save(&self) { + self.store().map(|s| s.save()); + } } pub enum PlugManageState { NvimGtk(Store), - Configuration(Store), + VimPlug(Store), Unknown, } @@ -56,15 +82,14 @@ pub struct PlugManagerConfigSource { impl PlugManagerConfigSource { pub fn new(store: &Store) -> Self { - let mut builder = "call plug#begin()".to_owned(); + let mut builder = "call plug#begin()\n".to_owned(); for plug in store.get_plugs() { - builder += &format!("Plug '{}'", plug.get_plug_path()); + builder += &format!("Plug '{}'\n", plug.get_plug_path()); } - builder += "call plug#end()"; + builder += "call plug#end()\n"; PlugManagerConfigSource { source: builder } } } - diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index e201212..bd9e8b5 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -12,6 +12,10 @@ impl Store { Settings::is_file_exists() } + pub fn is_enabled(&self) -> bool { + self.settings.enabled + } + pub fn load() -> Self { Store { settings: Settings::load() } } @@ -37,12 +41,20 @@ impl Store { pub fn get_plugs(&self) -> &[PlugInfo] { &self.settings.plugs } + + pub fn set_enabled(&mut self, enabled: bool) { + self.settings.enabled = enabled; + } + + pub fn save(&self) { + self.settings.save(); + } } #[derive(Serialize, Deserialize)] struct Settings { - plugs: Vec, enabled: bool, + plugs: Vec, } impl Settings { diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index 8a2f905..c7bf79c 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -39,6 +39,8 @@ impl<'a> Ui<'a> { let enable_swc = gtk::Switch::new(); enable_swc.set_valign(gtk::Align::Center); + + let manager_ref = self.manager.clone(); header_bar.pack_end(&enable_swc); header_bar.set_title("Plug"); @@ -51,27 +53,23 @@ impl<'a> Ui<'a> { match self.manager.borrow_mut().plug_manage_state { manager::PlugManageState::Unknown => { - let help = gtk::Box::new(gtk::Orientation::Vertical, 3); - let warn_lbl = gtk::Label::new(None); - warn_lbl.set_markup("Note: NeovimGtk plugin manager disabled!"); - help.pack_start(&warn_lbl, true, false, 0); - - let help_lbl = gtk::Label::new("Help"); - pages.add_page(&help_lbl, &help, "help"); + add_help_tab( + &pages, + "Note: NeovimGtk plugin manager disabled!", + ); } - manager::PlugManageState::Configuration(ref store) => { - let help = gtk::Box::new(gtk::Orientation::Vertical, 3); - let warn_lbl = gtk::Label::new(None); - warn_lbl.set_markup("Note: NeovimGtk plugin manager disabled!\n\ - NeovimGtk manages plugins use vim-plug as backend, so enable it disables vim-plug configuration."); - help.pack_start(&warn_lbl, true, false, 0); - - let help_lbl = gtk::Label::new("Help"); - pages.add_page(&help_lbl, &help, "help"); - + manager::PlugManageState::VimPlug(ref store) => { + enable_swc.set_state(store.is_enabled()); + add_help_tab( + &pages, + "Note: NeovimGtk plugin manager disabled!\n\ + NeovimGtk manages plugins use vim-plug as backend, so enable it disables vim-plug configuration.\n\ + Current configuration taken from your vim-plug", + ); self.add_plugin_list_tab(&pages, store); } manager::PlugManageState::NvimGtk(ref store) => { + enable_swc.set_state(store.is_enabled()); let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); // TODO: let get_plugins_lbl = gtk::Label::new("Get Plugins"); @@ -82,13 +80,20 @@ impl<'a> Ui<'a> { } + enable_swc.connect_state_set(move |_, state| { + manager_ref.borrow_mut().store_mut().map(|s| { + s.set_enabled(state) + }); + Inhibit(false) + }); + content.pack_start(&*pages, true, true, 0); content.show_all(); match dlg.run() { OK_ID => { - println!("TODO:"); + self.manager.borrow().save(); } _ => (), } @@ -97,7 +102,6 @@ impl<'a> Ui<'a> { } fn add_plugin_list_tab(&self, pages: &SettingsPages, store: &Store) { - // Plugins let plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); self.fill_plugin_list(&plugins, store); @@ -126,7 +130,7 @@ impl<'a> Ui<'a> { let remove_btn = gtk::Button::new_with_label("Remove"); remove_btn.set_halign(gtk::Align::End); - let store_ref = store.clone(); + //let store_ref = store.clone(); let panel_ref = panel.clone(); let row_ref = row.clone(); remove_btn.connect_clicked(move |_| { @@ -154,6 +158,16 @@ impl<'a> Ui<'a> { } } +fn add_help_tab(pages: &SettingsPages, markup: &str) { + let help = gtk::Box::new(gtk::Orientation::Vertical, 3); + let label = gtk::Label::new(None); + label.set_markup(markup); + help.pack_start(&label, true, false, 0); + + let help_lbl = gtk::Label::new("Help"); + pages.add_page(&help_lbl, &help, "help"); +} + struct SettingsPages { categories: gtk::ListBox, stack: gtk::Stack, From 4aec520746691098d17bac4586d4c1003bfbda28 Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 29 Oct 2017 22:16:55 +0300 Subject: [PATCH 18/30] Implement remove button --- src/main.rs | 2 +- src/plug_manager/manager.rs | 8 ++- src/plug_manager/store.rs | 12 +++++ src/plug_manager/ui.rs | 101 +++++++++++++++++++++++------------- src/ui.rs | 21 +++++++- 5 files changed, 105 insertions(+), 39 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7cc148f..99db371 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,9 +31,9 @@ mod color; mod value; mod mode; mod ui_model; -mod plug_manager; #[macro_use] mod ui; +mod plug_manager; mod nvim; mod render; mod shell; diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index 7a54462..143900e 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -67,6 +67,10 @@ impl Manager { pub fn save(&self) { self.store().map(|s| s.save()); } + + pub fn clear_removed(&mut self) { + self.store_mut().map(|s| s.clear_removed()); + } } pub enum PlugManageState { @@ -85,7 +89,9 @@ impl PlugManagerConfigSource { let mut builder = "call plug#begin()\n".to_owned(); for plug in store.get_plugs() { - builder += &format!("Plug '{}'\n", plug.get_plug_path()); + if !plug.removed { + builder += &format!("Plug '{}'\n", plug.get_plug_path()); + } } builder += "call plug#end()\n"; diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index bd9e8b5..df4a19c 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -46,9 +46,21 @@ impl Store { self.settings.enabled = enabled; } + pub fn clear_removed(&mut self) { + self.settings.plugs.retain(|p| !p.removed); + } + pub fn save(&self) { self.settings.save(); } + + pub fn remove_plug(&mut self, idx: usize) { + self.settings.plugs[idx].removed = true; + } + + pub fn restore_plug(&mut self, idx: usize) { + self.settings.plugs[idx].removed = false; + } } #[derive(Serialize, Deserialize)] diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index c7bf79c..deba02e 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -9,7 +9,7 @@ use gtk; use gtk::prelude::*; use super::manager; -use super::store::Store; +use super::store::{Store, PlugInfo}; pub struct Ui<'a> { manager: &'a Arc>, @@ -81,9 +81,9 @@ impl<'a> Ui<'a> { enable_swc.connect_state_set(move |_, state| { - manager_ref.borrow_mut().store_mut().map(|s| { - s.set_enabled(state) - }); + manager_ref.borrow_mut().store_mut().map( + |s| s.set_enabled(state), + ); Inhibit(false) }); @@ -93,7 +93,9 @@ impl<'a> Ui<'a> { match dlg.run() { OK_ID => { - self.manager.borrow().save(); + let mut manager = self.manager.borrow_mut(); + manager.clear_removed(); + manager.save(); } _ => (), } @@ -113,44 +115,56 @@ impl<'a> Ui<'a> { let scroll = gtk::ScrolledWindow::new(None, None); scroll.get_style_context().map(|c| c.add_class("view")); let plugs_panel = gtk::ListBox::new(); - plugs_panel.set_selection_mode(gtk::SelectionMode::None); for (idx, plug_info) in store.get_plugs().iter().enumerate() { let row = gtk::ListBoxRow::new(); let row_container = gtk::Box::new(gtk::Orientation::Vertical, 5); row_container.set_border_width(5); let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 5); - let vbox = gtk::Box::new(gtk::Orientation::Vertical, 5); + let label_box = create_plug_label(plug_info); + + + let button_box = gtk::Box::new(gtk::Orientation::Horizontal, 0); + button_box.set_halign(gtk::Align::End); + + let exists_button_box = gtk::Box::new(gtk::Orientation::Horizontal, 5); - let name_lbl = gtk::Label::new(None); - name_lbl.set_markup(&format!("{}", plug_info.name.as_str())); - name_lbl.set_halign(gtk::Align::Start); - let url_lbl = gtk::Label::new(Some(plug_info.url.as_str())); - url_lbl.set_halign(gtk::Align::Start); let remove_btn = gtk::Button::new_with_label("Remove"); - remove_btn.set_halign(gtk::Align::End); + exists_button_box.pack_start(&remove_btn, false, true, 0); + + let undo_btn = gtk::Button::new_with_label("Undo"); - //let store_ref = store.clone(); - let panel_ref = panel.clone(); - let row_ref = row.clone(); - remove_btn.connect_clicked(move |_| { - // store_ref.borrow_mut().remove(idx); - row_ref.remove(row_ref.get_child().as_ref().unwrap()); - let undo_btn = gtk::Button::new_with_label("Undo"); - let row_container = gtk::Box::new(gtk::Orientation::Horizontal, 5); - row_container.pack_end(&undo_btn, false, true, 0); - row_ref.add(&row_container); - row_container.show_all(); - }); row_container.pack_start(&hbox, true, true, 0); - vbox.pack_start(&name_lbl, true, true, 0); - vbox.pack_start(&url_lbl, true, true, 0); - hbox.pack_start(&vbox, true, true, 0); - hbox.pack_start(&remove_btn, false, true, 0); + hbox.pack_start(&label_box, true, true, 0); + button_box.pack_start(&exists_button_box, false, true, 0); + hbox.pack_start(&button_box, false, true, 0); row.add(&row_container); plugs_panel.add(&row); + + + let manager_ref = self.manager.clone(); + remove_btn.connect_clicked( + clone!(label_box, button_box, exists_button_box, undo_btn => move |_| { + label_box.set_sensitive(false); + button_box.remove(&exists_button_box); + button_box.pack_start(&undo_btn, false, true, 0); + button_box.show_all(); + manager_ref.borrow_mut().store_mut().map(|s| s.remove_plug(idx)); + }), + ); + + let manager_ref = self.manager.clone(); + undo_btn.connect_clicked( + clone!(label_box, button_box, exists_button_box, undo_btn => move |_| { + label_box.set_sensitive(true); + button_box.remove(&undo_btn); + button_box.pack_start(&exists_button_box, false, true, 0); + button_box.show_all(); + manager_ref.borrow_mut().store_mut().map(|s| s.restore_plug(idx)); + }), + ); } scroll.add(&plugs_panel); @@ -158,6 +172,21 @@ impl<'a> Ui<'a> { } } +fn create_plug_label(plug_info: &PlugInfo) -> gtk::Box { + let label_box = gtk::Box::new(gtk::Orientation::Vertical, 5); + + let name_lbl = gtk::Label::new(None); + name_lbl.set_markup(&format!("{}", plug_info.name)); + name_lbl.set_halign(gtk::Align::Start); + let url_lbl = gtk::Label::new(Some(plug_info.get_plug_path().as_str())); + url_lbl.set_halign(gtk::Align::Start); + + + label_box.pack_start(&name_lbl, true, true, 0); + label_box.pack_start(&url_lbl, true, true, 0); + label_box +} + fn add_help_tab(pages: &SettingsPages, markup: &str) { let help = gtk::Box::new(gtk::Orientation::Vertical, 3); let label = gtk::Label::new(None); @@ -188,16 +217,16 @@ impl SettingsPages { content.pack_start(&categories, false, true, 0); content.pack_start(&stack, true, true, 0); - let rows_ref = rows.clone(); - let stack_ref = stack.clone(); - categories.connect_row_selected(move |_, row| if let &Some(ref row) = row { - if let Some(ref r) = rows_ref.borrow().iter().find(|r| r.0 == *row) { - if let Some(child) = stack_ref.get_child_by_name(&r.1) { - stack_ref.set_visible_child(&child); + categories.connect_row_selected( + clone!(stack, rows => move |_, row| if let &Some(ref row) = row { + if let Some(ref r) = rows.borrow().iter().find(|r| r.0 == *row) { + if let Some(child) = stack.get_child_by_name(&r.1) { + stack.set_visible_child(&child); } } - }); + }), + ); SettingsPages { categories, diff --git a/src/ui.rs b/src/ui.rs index 1f2ce02..4c46f9e 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -60,7 +60,9 @@ impl Ui { let plug_manager = Arc::new(UiMutex::new(plug_manager)); let comps = Arc::new(UiMutex::new(Components::new())); let settings = Rc::new(RefCell::new(Settings::new())); - let shell = Rc::new(RefCell::new(Shell::new(settings.clone(), options, nvim_config))); + let shell = Rc::new(RefCell::new( + Shell::new(settings.clone(), options, nvim_config), + )); settings.borrow_mut().set_shell(Rc::downgrade(&shell)); let projects = Projects::new(&comps.borrow().open_btn, shell.clone()); @@ -263,3 +265,20 @@ impl UiMutex { } } } + +macro_rules! clone { + (@param _) => ( _ ); + (@param $x:ident) => ( $x ); + ($($n:ident),+ => move || $body:expr) => ( + { + $( let $n = $n.clone(); )+ + move || $body + } + ); + ($($n:ident),+ => move |$($p:tt),+| $body:expr) => ( + { + $( let $n = $n.clone(); )+ + move |$(clone!(@param $p),)+| $body + } + ); +} From 0a7edbc602e3484307cb4912a50be553f6e4a461 Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 29 Oct 2017 23:45:05 +0300 Subject: [PATCH 19/30] Add base code for add plugin dialog --- src/plug_manager/mod.rs | 1 + src/plug_manager/plugin_settings_dlg.rs | 44 +++++++++++++++++++++++++ src/plug_manager/ui.rs | 40 ++++++++++++++-------- 3 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 src/plug_manager/plugin_settings_dlg.rs diff --git a/src/plug_manager/mod.rs b/src/plug_manager/mod.rs index 7ed9f71..9419ddd 100644 --- a/src/plug_manager/mod.rs +++ b/src/plug_manager/mod.rs @@ -2,6 +2,7 @@ mod ui; mod vim_plug; mod store; mod manager; +mod plugin_settings_dlg; pub use self::ui::Ui; pub use self::manager::{Manager, PlugManagerConfigSource}; diff --git a/src/plug_manager/plugin_settings_dlg.rs b/src/plug_manager/plugin_settings_dlg.rs new file mode 100644 index 0000000..fe85332 --- /dev/null +++ b/src/plug_manager/plugin_settings_dlg.rs @@ -0,0 +1,44 @@ +use gtk; +use gtk::prelude::*; + +use super::store; + +pub struct Builder<'a> { + title: &'a str +} + +impl <'a> Builder <'a> { + pub fn new(title: &'a str) -> Self { + Builder { title } + } + + pub fn show>(&self, parent: &F) -> Option { + let dlg = gtk::Dialog::new_with_buttons( + Some(self.title), + Some(parent), + gtk::DIALOG_USE_HEADER_BAR | gtk::DIALOG_DESTROY_WITH_PARENT, + &[("Cancel", gtk::ResponseType::Cancel.into()), + ("Ok", gtk::ResponseType::Accept.into())], + ); + + let content = dlg.get_content_area(); + let grid = gtk::Grid::new(); + + let label = gtk::Label::new("Path:"); + let entry = gtk::Entry::new(); + + grid.attach(&label, 0, 0, 1, 1); + grid.attach(&entry, 1, 0, 1, 1); + + content.add(&grid); + content.show_all(); + + if dlg.run() == gtk::ResponseType::Ok.into() { + } + + dlg.destroy(); + + None + } +} + diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index deba02e..c60045e 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -10,6 +10,7 @@ use gtk::prelude::*; use super::manager; use super::store::{Store, PlugInfo}; +use super::plugin_settings_dlg; pub struct Ui<'a> { manager: &'a Arc>, @@ -23,13 +24,11 @@ impl<'a> Ui<'a> { } pub fn show>(&mut self, parent: &T) { - const OK_ID: i32 = 0; - let dlg = gtk::Dialog::new_with_buttons( Some("Plug"), Some(parent), - gtk::DialogFlags::empty(), - &[("Ok", OK_ID)], + gtk::DIALOG_DESTROY_WITH_PARENT, + &[("Ok", gtk::ResponseType::Ok.into())], ); dlg.set_default_size(800, 600); @@ -37,6 +36,14 @@ impl<'a> Ui<'a> { let header_bar = gtk::HeaderBar::new(); + let add_plug_btn = gtk::Button::new_with_label("Add.."); + header_bar.pack_end(&add_plug_btn); + + let manager_ref = self.manager.clone(); + add_plug_btn.connect_clicked(clone!(dlg => move |_| { + add_plugin(&dlg, &manager_ref); + })); + let enable_swc = gtk::Switch::new(); enable_swc.set_valign(gtk::Align::Center); @@ -49,7 +56,11 @@ impl<'a> Ui<'a> { dlg.set_titlebar(&header_bar); - let pages = SettingsPages::new(); + let pages = SettingsPages::new(move |row_name| if row_name == "plugins" { + add_plug_btn.show(); + } else { + add_plug_btn.hide(); + }); match self.manager.borrow_mut().plug_manage_state { manager::PlugManageState::Unknown => { @@ -91,13 +102,10 @@ impl<'a> Ui<'a> { content.show_all(); - match dlg.run() { - OK_ID => { - let mut manager = self.manager.borrow_mut(); - manager.clear_removed(); - manager.save(); - } - _ => (), + if dlg.run() == gtk::ResponseType::Ok.into() { + let mut manager = self.manager.borrow_mut(); + manager.clear_removed(); + manager.save(); } dlg.destroy(); @@ -172,6 +180,10 @@ impl<'a> Ui<'a> { } } +fn add_plugin>(parent: &F, manager: &Arc>) { + plugin_settings_dlg::Builder::new("Add plugin").show(parent); +} + fn create_plug_label(plug_info: &PlugInfo) -> gtk::Box { let label_box = gtk::Box::new(gtk::Orientation::Vertical, 5); @@ -202,10 +214,11 @@ struct SettingsPages { stack: gtk::Stack, content: gtk::Box, rows: Rc>>, + row_selected: Box, } impl SettingsPages { - pub fn new() -> Self { + pub fn new(row_selected: F) -> Self { let content = gtk::Box::new(gtk::Orientation::Horizontal, 5); let categories = gtk::ListBox::new(); categories.get_style_context().map(|c| c.add_class("view")); @@ -233,6 +246,7 @@ impl SettingsPages { stack, content, rows, + row_selected: Box::new(row_selected), } } From d9852a421d6924a52782b07a84ca2916a0ea0a00 Mon Sep 17 00:00:00 2001 From: daa84 Date: Mon, 30 Oct 2017 18:25:23 +0300 Subject: [PATCH 20/30] Implement "add plugin", base code for vimawesome support --- Cargo.lock | 548 ++++++++++++++++++++++++ Cargo.toml | 7 + src/main.rs | 7 + src/plug_manager/manager.rs | 63 ++- src/plug_manager/mod.rs | 1 + src/plug_manager/plugin_settings_dlg.rs | 40 +- src/plug_manager/store.rs | 12 + src/plug_manager/ui.rs | 174 ++++---- src/plug_manager/vimawesome.rs | 56 +++ src/ui.rs | 2 +- 10 files changed, 784 insertions(+), 126 deletions(-) create mode 100644 src/plug_manager/vimawesome.rs diff --git a/Cargo.lock b/Cargo.lock index 5cefe3b..029ddf2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,6 +4,7 @@ version = "0.2.0" dependencies = [ "cairo-rs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "gdk 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "gio 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -13,6 +14,8 @@ dependencies = [ "gtk 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "gtk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.11.6 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "neovim-lib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "pango 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -22,9 +25,20 @@ dependencies = [ "phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "advapi32-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "aho-corasick" version = "0.6.3" @@ -45,6 +59,15 @@ dependencies = [ "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "base64" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bitflags" version = "0.7.0" @@ -60,6 +83,15 @@ name = "byteorder" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bytes" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "c_vec" version = "1.2.1" @@ -88,6 +120,11 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cc" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "cfg-if" version = "0.1.2" @@ -101,11 +138,42 @@ dependencies = [ "custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "core-foundation" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "core-foundation-sys" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crypt32-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "custom_derive" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "dtoa" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "env_logger" version = "0.4.3" @@ -115,6 +183,41 @@ dependencies = [ "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "foreign-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "fuchsia-zircon" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-cpupool" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "gdk" version = "0.6.0" @@ -277,11 +380,86 @@ name = "htmlescape" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "httparse" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "hyper" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-cpupool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "relay 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hyper-tls" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.11.6 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tls 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "iovec" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "itoa" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "language-tags" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "lazy_static" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "lazycell" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "libc" version = "0.2.29" @@ -317,6 +495,55 @@ dependencies = [ "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "mime" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "mio" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "native-tls" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "openssl 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)", + "schannel 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "neovim-lib" version = "0.4.2" @@ -328,11 +555,54 @@ dependencies = [ "unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "net2" +version = "0.2.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num-traits" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "num_cpus" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "openssl" +version = "0.9.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "openssl-sys" +version = "0.9.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "pango" version = "0.2.0" @@ -384,6 +654,11 @@ dependencies = [ "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "percent-encoding" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "phf" version = "0.7.21" @@ -437,6 +712,11 @@ dependencies = [ "magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "redox_syscall" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "regex" version = "0.2.2" @@ -454,6 +734,14 @@ name = "regex-syntax" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "relay" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rmp" version = "0.8.6" @@ -472,6 +760,72 @@ dependencies = [ "rmp 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc_version" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "safemem" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "schannel" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crypt32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "secur32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scoped-tls" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "secur32-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "security-framework" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "security-framework-sys" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "serde" version = "1.0.11" @@ -496,11 +850,37 @@ dependencies = [ "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "serde_json" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "siphasher" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "slab" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "slab" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "smallvec" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "syn" version = "0.11.11" @@ -519,6 +899,19 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "take" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "tempdir" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "thread_local" version = "0.3.4" @@ -528,6 +921,78 @@ dependencies = [ "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "time" +version = "0.1.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-io" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-proto" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-service" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-tls" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "toml" version = "0.4.5" @@ -536,6 +1001,14 @@ dependencies = [ "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "unicase" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "unicode-xid" version = "0.0.4" @@ -563,6 +1036,11 @@ name = "utf8-ranges" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "vcpkg" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "void" version = "1.0.2" @@ -573,19 +1051,46 @@ name = "winapi" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] +"checksum advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e06588080cb19d0acb6739808aafa5f26bfb2ca015b2b6370028b44cf7cb8a9a" "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699" "checksum atk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c69658a4e18d5c9575f716e24559645d08a4044d6946c30c2e0025952c84d842" +"checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff81738b726f5d099632ceaffe7fb65b90212e8dce59d518729e7e8634032d3d" +"checksum bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d828f97b58cc5de3e40c421d0cf2132d6b2da4ee0e11b8632fa838f0f9333ad6" "checksum c_vec 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6237ac5a4b1e81c213c24c6437964c61e646df910a914b4ab1487b46df20bd13" "checksum cairo-rs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9d336f1b2ff46c17475a14360de7f456707008da475c54824887e52e453ab00" "checksum cairo-sys-rs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9e8a1e2a76ac09b959788c2c30a355d693ce6f7f7d7268f6d1dd5d8c3359c521" +"checksum cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b13a57efd6b30ecd6598ebdb302cca617930b5470647570468a65d12ef9719" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "78ff10625fd0ac447827aa30ea8b861fead473bb60aeb73af6c1c58caf0d1299" +"checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67" +"checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d" +"checksum crypt32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e34988f7e069e0b2f3bfc064295161e489b2d4e04a2e4248fb94360cdf00b4ec" "checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" +"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" +"checksum foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e4056b9bd47f8ac5ba12be771f77a0dae796d1bbaaf5fd0b9c2d38b69b8a29d" +"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159" +"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82" +"checksum futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "05a23db7bd162d4e8265968602930c476f688f0c180b44bdaf55e0cb2c687558" +"checksum futures-cpupool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e86f49cc0d92fe1b97a5980ec32d56208272cbb00f15044ea9e2799dde766fdf" "checksum gdk 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f30018ecbbb1e6f1d59c4024ec08675850744b799abc5420be0629ac9ba0abd2" "checksum gdk-pixbuf 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "caf05dab73febcc6e90abaff8f24cfe1cf1bd2222cd648ddfe337bf3b994489f" "checksum gdk-pixbuf-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85eb441420653b33e5a29d13227ea34995383e65bf4f33b16492ec95e44a8996" @@ -598,18 +1103,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gtk 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce17f98e7dcdc9d06b3a5f7621d796a24937c04953481205b1be267c5a02697a" "checksum gtk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "854b56ce6d6b05945f7735651482835c5ac1f8582142ce67306726259a3dafb0" "checksum htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163" +"checksum httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af2f2dd97457e8fb1ae7c5a420db346af389926e36f43768b96f101546b04a07" +"checksum hyper 0.11.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1b45eac8b696d59491b079bd04fcb0f3488c0f6ed62dcb36bcfea8a543e9cdc3" +"checksum hyper-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c81fa95203e2a6087242c38691a0210f23e9f3f8f944350bd676522132e2985" +"checksum iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6e8b9c2247fcf6c6a1151f1156932be5606c9fd6f55a2d7f9fc1cb29386b2f7" +"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" +"checksum lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b585b7a6811fb03aa10e74b278a0f00f8dd9b45dc681f148bb29fa5cb61859b" "checksum libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "8a014d9226c2cc402676fbe9ea2e15dd5222cd1dd57f576b5b283178c944a264" "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" "checksum magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf0336886480e671965f794bc9b6fce88503563013d1bfb7a502c81fe3ac527" "checksum magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40d014c7011ac470ae28e2f76a02bfea4a8480f73e701353b49ad7a8d75f4699" "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" +"checksum mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e00e17be181010a91dbfefb01660b17311059dc8c7f48b9017677721e732bd" +"checksum mio 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0e8411968194c7b139e9105bc4ae7db0bae232af087147e72f0616ebf5fdb9cb" +"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +"checksum native-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04b781c9134a954c84f0594b9ab3f5606abc516030388e8511887ef4c204a1e5" "checksum neovim-lib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cd81cd2140309fcbe61775ebe5901b0730e5fdae2558a6cd27539e6e730fa76a" +"checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" "checksum num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "99843c856d68d8b4313b03a17e33c4bb42ae8f6610ea81b28abe076ac721b9b0" +"checksum num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d" +"checksum openssl 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf434ff6117485dc16478d77a4f5c84eccc9c3645c4da8323b287ad6a15a638" +"checksum openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)" = "0ad395f1cee51b64a8d07cc8063498dc7554db62d5f3ca87a67f4eed2791d0c8" "checksum pango 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5afa4b4c5380315b12075e7767d9bdd62d53beeb6087d9287ef6990e57a6b643" "checksum pango-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e6ec8d90306b5ff43f5836f4363267ea95be02b3df71d2b31ba8fbb1680bdee1" "checksum pangocairo 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8edeb86f36f8f10a252a888fa3d9aff4d0681373da918c207eac2208aa091e6" "checksum pangocairo-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c26c200ef32a682bf8b693b47996c3c33e0b2de32b30f7251cc60673ad513bef" +"checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356" "checksum phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "cb325642290f28ee14d8c6201159949a872f220c62af6e110a56ea914fbe42fc" "checksum phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d62594c0bb54c464f633175d502038177e90309daf2e0158be42ed5f023ce88f" "checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03" @@ -617,21 +1139,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "eb250fd207a4729c976794d03db689c9be1d634ab5a1c9da9492a13d8fecbcdf" +"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" +"checksum relay 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f301bafeb60867c85170031bdb2fcf24c8041f33aee09e7b116a58d4e9f781c5" "checksum rmp 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7ce560a5728f4eec697f07f8d7fa20608893d44b4f5b8f9f5f51a2987f3cffe2" "checksum rmpv 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "45368daa6c60116376d8813ec6a2556df640229709becb8f80df1651f882e7af" +"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" +"checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" +"checksum schannel 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7554288337c1110e34d7a2433518d889374c1de1a45f856b7bcddb03702131fc" +"checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" +"checksum secur32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f412dfa83308d893101dd59c10d6fda8283465976c28c287c5c855bf8d216bc" +"checksum security-framework 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "dfa44ee9c54ce5eecc9de7d5acbad112ee58755239381f687e564004ba4a2332" +"checksum security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "5421621e836278a0b139268f36eee0dc7e389b784dc3f79d8f11aabadf41bead" +"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" "checksum serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f7726f29ddf9731b17ff113c461e362c381d9d69433f79de4f3dd572488823e9" "checksum serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cf823e706be268e73e7747b147aa31c8f633ab4ba31f115efb57e5047c3a76dd" "checksum serde_derive_internals 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37aee4e0da52d801acfbc0cc219eb1eda7142112339726e427926a6f6ee65d3a" +"checksum serde_json 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ae1e67ce320daa7e494c578e34d4b00689f23bb94512fe0ca0dfaf02ea53fb67" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" +"checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" +"checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" +"checksum smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" +"checksum take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b157868d8ac1f56b64604539990685fa7611d8fa9e5476cf0c02cf34d32917c5" +"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" "checksum thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14" +"checksum time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d788d3aa77bc0ef3e9621256885555368b47bd495c13dd2e7413c89f845520" +"checksum tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "c843a027f7c1df5f81e7734a0df3f67bf329411781ebf36393ce67beef6071e3" +"checksum tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ab83e7adb5677e42e405fa4ceff75659d93c4d7d7dd22f52fcec59ee9f02af" +"checksum tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fbb47ae81353c63c487030659494b295f6cb6576242f907f203473b191b0389" +"checksum tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" +"checksum tokio-tls 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d88e411cac1c87e405e4090be004493c5d8072a370661033b1a64ea205ec2e13" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" +"checksum unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e01da42520092d0cd2d6ac3ae69eb21a22ad43ff195676b86f8c37f487d6b80" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6aa2700417c405c38f5e6902d699345241c28c0b7ade4abaad71e35a87eb1564" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" +"checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/Cargo.toml b/Cargo.toml index bef06e6..265ed92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,13 @@ serde = "1.0" serde_derive = "1.0" toml = "0.4" +# http request library +futures = "0.1" +hyper = "0.11" +hyper-tls = "0.1" +tokio-core = "0.1" +serde_json = "1.0" + #[dependencies.neovim-lib] #git = "https://github.com/daa84/neovim-lib" diff --git a/src/main.rs b/src/main.rs index 99db371..9266918 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,13 @@ extern crate serde; extern crate serde_derive; extern crate toml; +// http request library +extern crate futures; +extern crate hyper; +extern crate tokio_core; +extern crate serde_json; +extern crate hyper_tls; + mod sys; mod nvim_config; diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index 143900e..727cf1a 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -2,34 +2,35 @@ use std::rc::Rc; use std::cell::RefCell; use super::vim_plug; -use super::store::Store; +use super::store::{Store, PlugInfo}; use nvim::NeovimClient; pub struct Manager { vim_plug: vim_plug::Manager, + pub store: Store, pub plug_manage_state: PlugManageState, } impl Manager { pub fn new() -> Self { + + let (plug_manage_state, store) = if Store::is_config_exists() { + (PlugManageState::NvimGtk, Store::load()) + } else { + (PlugManageState::Unknown, Store::empty()) + }; + Manager { vim_plug: vim_plug::Manager::new(), - plug_manage_state: PlugManageState::Unknown, + plug_manage_state, + store, } } - pub fn load_config(&mut self) -> Option { - if Store::is_config_exists() { - let store = Store::load(); - if store.is_enabled() { - let config = PlugManagerConfigSource::new(&store); - self.plug_manage_state = PlugManageState::NvimGtk(store); - Some(config) - } else { - self.plug_manage_state = PlugManageState::NvimGtk(store); - None - } + pub fn load_config(&self) -> Option { + if self.store.is_enabled() { + Some(PlugManagerConfigSource::new(&self.store)) } else { None } @@ -40,42 +41,30 @@ impl Manager { } 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::VimPlug(Store::load_from_plug(&self.vim_plug)); + if let PlugManageState::Unknown = self.plug_manage_state { + if self.vim_plug.is_loaded() { + self.store = Store::load_from_plug(&self.vim_plug); + self.plug_manage_state = PlugManageState::VimPlug; } } } - pub fn store_mut(&mut self) -> Option<&mut Store> { - match self.plug_manage_state { - PlugManageState::NvimGtk(ref mut store) => Some(store), - PlugManageState::VimPlug(ref mut store) => Some(store), - PlugManageState::Unknown => None, - } - } - - pub fn store(&self) -> Option<&Store> { - match self.plug_manage_state { - PlugManageState::NvimGtk(ref store) => Some(store), - PlugManageState::VimPlug(ref store) => Some(store), - PlugManageState::Unknown => None, - } - } - pub fn save(&self) { - self.store().map(|s| s.save()); + self.store.save(); } pub fn clear_removed(&mut self) { - self.store_mut().map(|s| s.clear_removed()); + self.store.clear_removed(); + } + + pub fn add_plug(&mut self, plug: PlugInfo) { + self.store.add_plug(plug); } } pub enum PlugManageState { - NvimGtk(Store), - VimPlug(Store), + NvimGtk, + VimPlug, Unknown, } diff --git a/src/plug_manager/mod.rs b/src/plug_manager/mod.rs index 9419ddd..f318017 100644 --- a/src/plug_manager/mod.rs +++ b/src/plug_manager/mod.rs @@ -3,6 +3,7 @@ mod vim_plug; mod store; mod manager; mod plugin_settings_dlg; +mod vimawesome; pub use self::ui::Ui; pub use self::manager::{Manager, PlugManagerConfigSource}; diff --git a/src/plug_manager/plugin_settings_dlg.rs b/src/plug_manager/plugin_settings_dlg.rs index fe85332..26c680d 100644 --- a/src/plug_manager/plugin_settings_dlg.rs +++ b/src/plug_manager/plugin_settings_dlg.rs @@ -4,10 +4,10 @@ use gtk::prelude::*; use super::store; pub struct Builder<'a> { - title: &'a str + title: &'a str, } -impl <'a> Builder <'a> { +impl<'a> Builder<'a> { pub fn new(title: &'a str) -> Self { Builder { title } } @@ -17,28 +17,40 @@ impl <'a> Builder <'a> { Some(self.title), Some(parent), gtk::DIALOG_USE_HEADER_BAR | gtk::DIALOG_DESTROY_WITH_PARENT, - &[("Cancel", gtk::ResponseType::Cancel.into()), - ("Ok", gtk::ResponseType::Accept.into())], + &[ + ("Cancel", gtk::ResponseType::Cancel.into()), + ("Ok", gtk::ResponseType::Ok.into()), + ], ); let content = dlg.get_content_area(); - let grid = gtk::Grid::new(); + let list = gtk::ListBox::new(); + list.set_selection_mode(gtk::SelectionMode::None); - let label = gtk::Label::new("Path:"); + let path = gtk::Box::new(gtk::Orientation::Horizontal, 0); + let label = gtk::Label::new("Repo"); let entry = gtk::Entry::new(); - - grid.attach(&label, 0, 0, 1, 1); - grid.attach(&entry, 1, 0, 1, 1); - content.add(&grid); + path.pack_start(&label, true, true, 0); + path.pack_end(&entry, false, true, 0); + + list.add(&path); + + + content.add(&list); content.show_all(); - if dlg.run() == gtk::ResponseType::Ok.into() { - } + let ok: i32 = gtk::ResponseType::Ok.into(); + let res = if dlg.run() == ok { + entry.get_text().map(|name| { + store::PlugInfo::new(name.to_owned(), name.to_owned()) + }) + } else { + None + }; dlg.destroy(); - None + res } } - diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index df4a19c..a9cf6eb 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -20,6 +20,10 @@ impl Store { Store { settings: Settings::load() } } + pub fn empty() -> Self { + Store { settings: Settings::empty() } + } + pub fn load_from_plug(vim_plug: &vim_plug::Manager) -> Self { let settings = match vim_plug.get_plugs() { Err(msg) => { @@ -61,6 +65,14 @@ impl Store { pub fn restore_plug(&mut self, idx: usize) { self.settings.plugs[idx].removed = false; } + + pub fn add_plug(&mut self, plug: PlugInfo) { + self.settings.plugs.push(plug); + } + + pub fn plugs_count(&self) -> usize { + self.settings.plugs.len() + } } #[derive(Serialize, Deserialize)] diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index c60045e..17d7c79 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -11,6 +11,7 @@ use gtk::prelude::*; use super::manager; use super::store::{Store, PlugInfo}; use super::plugin_settings_dlg; +use super::vimawesome::Vimawesome; pub struct Ui<'a> { manager: &'a Arc>, @@ -39,70 +40,74 @@ impl<'a> Ui<'a> { let add_plug_btn = gtk::Button::new_with_label("Add.."); header_bar.pack_end(&add_plug_btn); - let manager_ref = self.manager.clone(); - add_plug_btn.connect_clicked(clone!(dlg => move |_| { - add_plugin(&dlg, &manager_ref); - })); let enable_swc = gtk::Switch::new(); enable_swc.set_valign(gtk::Align::Center); + enable_swc.show(); - let manager_ref = self.manager.clone(); header_bar.pack_end(&enable_swc); header_bar.set_title("Plug"); header_bar.set_show_close_button(true); - header_bar.show_all(); + header_bar.show(); dlg.set_titlebar(&header_bar); - let pages = SettingsPages::new(move |row_name| if row_name == "plugins" { + let pages = SettingsPages::new( + clone!(add_plug_btn => move |row_name| if row_name == "plugins" { add_plug_btn.show(); } else { add_plug_btn.hide(); - }); + }), + ); - match self.manager.borrow_mut().plug_manage_state { + enable_swc.set_state(self.manager.borrow().store.is_enabled()); + + match self.manager.borrow().plug_manage_state { manager::PlugManageState::Unknown => { add_help_tab( &pages, "Note: NeovimGtk plugin manager disabled!", ); } - manager::PlugManageState::VimPlug(ref store) => { - enable_swc.set_state(store.is_enabled()); + manager::PlugManageState::VimPlug => { add_help_tab( &pages, "Note: NeovimGtk plugin manager disabled!\n\ NeovimGtk manages plugins use vim-plug as backend, so enable it disables vim-plug configuration.\n\ Current configuration taken from your vim-plug", ); - self.add_plugin_list_tab(&pages, store); } - manager::PlugManageState::NvimGtk(ref store) => { - enable_swc.set_state(store.is_enabled()); + manager::PlugManageState::NvimGtk => { let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); - // TODO: + + Vimawesome::new().log(); + let get_plugins_lbl = gtk::Label::new("Get Plugins"); pages.add_page(&get_plugins_lbl, &get_plugins, "get_plugins"); - self.add_plugin_list_tab(&pages, store); } } + let plugs_panel = self.add_plugin_list_tab(&pages, &self.manager.borrow().store); + let manager_ref = self.manager.clone(); enable_swc.connect_state_set(move |_, state| { - manager_ref.borrow_mut().store_mut().map( - |s| s.set_enabled(state), - ); + manager_ref.borrow_mut().store.set_enabled(state); Inhibit(false) }); + let manager_ref = self.manager.clone(); + add_plug_btn.connect_clicked(clone!(dlg => move |_| { + add_plugin(&dlg, &manager_ref, &plugs_panel); + })); + content.pack_start(&*pages, true, true, 0); content.show_all(); - if dlg.run() == gtk::ResponseType::Ok.into() { + let ok: i32 = gtk::ResponseType::Ok.into(); + if dlg.run() == ok { let mut manager = self.manager.borrow_mut(); manager.clear_removed(); manager.save(); @@ -111,77 +116,99 @@ impl<'a> Ui<'a> { dlg.destroy(); } - fn add_plugin_list_tab(&self, pages: &SettingsPages, store: &Store) { + fn add_plugin_list_tab(&self, pages: &SettingsPages, store: &Store) -> gtk::ListBox { let plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); - self.fill_plugin_list(&plugins, store); + let plugs_panel = self.fill_plugin_list(&plugins, store); let plugins_lbl = gtk::Label::new("Plugins"); pages.add_page(&plugins_lbl, &plugins, "plugins"); + plugs_panel } - fn fill_plugin_list(&self, panel: >k::Box, store: &Store) { + fn fill_plugin_list(&self, panel: >k::Box, store: &Store) -> gtk::ListBox { let scroll = gtk::ScrolledWindow::new(None, None); scroll.get_style_context().map(|c| c.add_class("view")); let plugs_panel = gtk::ListBox::new(); for (idx, plug_info) in store.get_plugs().iter().enumerate() { - let row = gtk::ListBoxRow::new(); - let row_container = gtk::Box::new(gtk::Orientation::Vertical, 5); - row_container.set_border_width(5); - let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 5); - let label_box = create_plug_label(plug_info); + let row = create_plug_row(idx, plug_info, &self.manager); - - let button_box = gtk::Box::new(gtk::Orientation::Horizontal, 0); - button_box.set_halign(gtk::Align::End); - - let exists_button_box = gtk::Box::new(gtk::Orientation::Horizontal, 5); - - let remove_btn = gtk::Button::new_with_label("Remove"); - exists_button_box.pack_start(&remove_btn, false, true, 0); - - let undo_btn = gtk::Button::new_with_label("Undo"); - - - row_container.pack_start(&hbox, true, true, 0); - hbox.pack_start(&label_box, true, true, 0); - button_box.pack_start(&exists_button_box, false, true, 0); - hbox.pack_start(&button_box, false, true, 0); - - row.add(&row_container); plugs_panel.add(&row); - - - let manager_ref = self.manager.clone(); - remove_btn.connect_clicked( - clone!(label_box, button_box, exists_button_box, undo_btn => move |_| { - label_box.set_sensitive(false); - button_box.remove(&exists_button_box); - button_box.pack_start(&undo_btn, false, true, 0); - button_box.show_all(); - manager_ref.borrow_mut().store_mut().map(|s| s.remove_plug(idx)); - }), - ); - - let manager_ref = self.manager.clone(); - undo_btn.connect_clicked( - clone!(label_box, button_box, exists_button_box, undo_btn => move |_| { - label_box.set_sensitive(true); - button_box.remove(&undo_btn); - button_box.pack_start(&exists_button_box, false, true, 0); - button_box.show_all(); - manager_ref.borrow_mut().store_mut().map(|s| s.restore_plug(idx)); - }), - ); } scroll.add(&plugs_panel); panel.pack_start(&scroll, true, true, 0); + + plugs_panel } } -fn add_plugin>(parent: &F, manager: &Arc>) { - plugin_settings_dlg::Builder::new("Add plugin").show(parent); +fn create_plug_row( + plug_idx: usize, + plug_info: &PlugInfo, + manager: &Arc>, +) -> gtk::ListBoxRow { + let row = gtk::ListBoxRow::new(); + let row_container = gtk::Box::new(gtk::Orientation::Vertical, 5); + row_container.set_border_width(5); + let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 5); + let label_box = create_plug_label(plug_info); + + + let button_box = gtk::Box::new(gtk::Orientation::Horizontal, 0); + button_box.set_halign(gtk::Align::End); + + let exists_button_box = gtk::Box::new(gtk::Orientation::Horizontal, 5); + + let remove_btn = gtk::Button::new_with_label("Remove"); + exists_button_box.pack_start(&remove_btn, false, true, 0); + + let undo_btn = gtk::Button::new_with_label("Undo"); + + + row_container.pack_start(&hbox, true, true, 0); + hbox.pack_start(&label_box, true, true, 0); + button_box.pack_start(&exists_button_box, false, true, 0); + hbox.pack_start(&button_box, false, true, 0); + + row.add(&row_container); + + + remove_btn.connect_clicked( + clone!(manager, label_box, button_box, exists_button_box, undo_btn => move |_| { + label_box.set_sensitive(false); + button_box.remove(&exists_button_box); + button_box.pack_start(&undo_btn, false, true, 0); + button_box.show_all(); + manager.borrow_mut().store.remove_plug(plug_idx); + }), + ); + + undo_btn.connect_clicked( + clone!(manager, label_box, button_box, exists_button_box, undo_btn => move |_| { + label_box.set_sensitive(true); + button_box.remove(&undo_btn); + button_box.pack_start(&exists_button_box, false, true, 0); + button_box.show_all(); + manager.borrow_mut().store.restore_plug(plug_idx); + }), + ); + + row +} + +fn add_plugin>( + parent: &F, + manager: &Arc>, + plugs_panel: >k::ListBox, +) { + if let Some(new_plugin) = plugin_settings_dlg::Builder::new("Add plugin").show(parent) { + let row = create_plug_row(manager.borrow().store.plugs_count(), &new_plugin, manager); + row.show_all(); + plugs_panel.add(&row); + + manager.borrow_mut().add_plug(new_plugin); + } } fn create_plug_label(plug_info: &PlugInfo) -> gtk::Box { @@ -214,11 +241,10 @@ struct SettingsPages { stack: gtk::Stack, content: gtk::Box, rows: Rc>>, - row_selected: Box, } impl SettingsPages { - pub fn new(row_selected: F) -> Self { + pub fn new(row_selected: F) -> Self { let content = gtk::Box::new(gtk::Orientation::Horizontal, 5); let categories = gtk::ListBox::new(); categories.get_style_context().map(|c| c.add_class("view")); @@ -235,6 +261,7 @@ impl SettingsPages { if let Some(ref r) = rows.borrow().iter().find(|r| r.0 == *row) { if let Some(child) = stack.get_child_by_name(&r.1) { stack.set_visible_child(&child); + row_selected(&r.1); } } @@ -246,7 +273,6 @@ impl SettingsPages { stack, content, rows, - row_selected: Box::new(row_selected), } } diff --git a/src/plug_manager/vimawesome.rs b/src/plug_manager/vimawesome.rs new file mode 100644 index 0000000..e72d1c6 --- /dev/null +++ b/src/plug_manager/vimawesome.rs @@ -0,0 +1,56 @@ +use std::io; +use futures::{Future, Stream}; +use hyper::{self, Client}; +use tokio_core::reactor::Core; +use serde_json; +use hyper_tls::HttpsConnector; + +pub struct Vimawesome {} + +impl Vimawesome { + pub fn new() -> Self { + Vimawesome {} + } + + pub fn log(&self) { + match self.request() { + Ok(list) => println!("list: {:?}", list), + Err(e) => error!("{}", e), + } + } + + fn request(&self) -> Result { + let mut core = Core::new()?; + let handle = core.handle(); + let client = Client::configure() + .connector(HttpsConnector::new(4, &handle).map_err(|e| { + io::Error::new(io::ErrorKind::Other, e) + })?) + .build(&handle); + let uri = "https://vimawesome.com/api/plugins?query=&page=1".parse()?; + + let work = client.get(uri).and_then(|res| { + res.body().concat2().and_then(move |body| { + let description_list: DescriptionList = + serde_json::from_slice(&body).map_err(|e| { + io::Error::new(io::ErrorKind::Other, e) + })?; + Ok(description_list) + }) + }); + core.run(work) + } +} + +#[derive(Serialize, Deserialize, Debug)] +struct DescriptionList { + plugins: Box<[Description]>, +} + +#[derive(Serialize, Deserialize, Debug)] +struct Description { + name: String, + github_url: String, + author: String, + github_stars: i64, +} diff --git a/src/ui.rs b/src/ui.rs index 4c46f9e..48b87c8 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -53,7 +53,7 @@ impl Components { impl Ui { pub fn new(options: ShellOptions) -> Ui { - let mut plug_manager = plug_manager::Manager::new(); + let plug_manager = plug_manager::Manager::new(); let plug_config = plug_manager.load_config(); let nvim_config = NvimConfig::new(plug_config); From 20be6c5089abd2a915f2827637cf900e5e25c19d Mon Sep 17 00:00:00 2001 From: daa84 Date: Tue, 31 Oct 2017 17:21:44 +0300 Subject: [PATCH 21/30] Load vimawesome plugins using curl to reduce application dependencies Dispaly vimawesome plugin information --- Cargo.lock | 523 --------------------------------- Cargo.toml | 6 - src/main.rs | 6 - src/plug_manager/ui.rs | 50 +++- src/plug_manager/vimawesome.rs | 154 +++++++--- 5 files changed, 153 insertions(+), 586 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 029ddf2..6d3c7e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,6 @@ version = "0.2.0" dependencies = [ "cairo-rs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "gdk 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "gio 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -14,8 +13,6 @@ dependencies = [ "gtk 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "gtk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.11.6 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "neovim-lib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "pango 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -26,19 +23,9 @@ dependencies = [ "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "advapi32-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "aho-corasick" version = "0.6.3" @@ -59,15 +46,6 @@ dependencies = [ "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base64" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bitflags" version = "0.7.0" @@ -83,15 +61,6 @@ name = "byteorder" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "bytes" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "c_vec" version = "1.2.1" @@ -120,11 +89,6 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "cc" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "cfg-if" version = "0.1.2" @@ -138,32 +102,6 @@ dependencies = [ "custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "core-foundation" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "core-foundation-sys" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crypt32-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "custom_derive" version = "0.1.7" @@ -183,41 +121,6 @@ dependencies = [ "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "foreign-types" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fuchsia-zircon" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-cpupool" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "gdk" version = "0.6.0" @@ -380,86 +283,16 @@ name = "htmlescape" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "httparse" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "hyper" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "relay 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "hyper-tls" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.11.6 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tls 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "iovec" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "itoa" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "language-tags" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "lazy_static" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "lazycell" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "libc" version = "0.2.29" @@ -495,55 +328,6 @@ dependencies = [ "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "mime" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "mio" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "native-tls" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "openssl 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)", - "schannel 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "neovim-lib" version = "0.4.2" @@ -555,54 +339,11 @@ dependencies = [ "unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "net2" -version = "0.2.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "num-traits" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "num_cpus" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "openssl" -version = "0.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "openssl-sys" -version = "0.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "pango" version = "0.2.0" @@ -654,11 +395,6 @@ dependencies = [ "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "percent-encoding" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "phf" version = "0.7.21" @@ -712,11 +448,6 @@ dependencies = [ "magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "redox_syscall" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "regex" version = "0.2.2" @@ -734,14 +465,6 @@ name = "regex-syntax" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "relay" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rmp" version = "0.8.6" @@ -760,72 +483,6 @@ dependencies = [ "rmp 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rustc_version" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "safemem" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "schannel" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crypt32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "secur32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "scoped-tls" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "secur32-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "security-framework" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "security-framework-sys" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "serde" version = "1.0.11" @@ -866,21 +523,6 @@ name = "siphasher" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "slab" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "slab" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "smallvec" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "syn" version = "0.11.11" @@ -899,19 +541,6 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "take" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "tempdir" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "thread_local" version = "0.3.4" @@ -921,78 +550,6 @@ dependencies = [ "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "time" -version = "0.1.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-core" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-io" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-proto" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-service" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-tls" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "toml" version = "0.4.5" @@ -1001,14 +558,6 @@ dependencies = [ "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "unicase" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "unicode-xid" version = "0.0.4" @@ -1036,11 +585,6 @@ name = "utf8-ranges" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "vcpkg" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "void" version = "1.0.2" @@ -1051,46 +595,20 @@ name = "winapi" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [metadata] -"checksum advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e06588080cb19d0acb6739808aafa5f26bfb2ca015b2b6370028b44cf7cb8a9a" "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699" "checksum atk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c69658a4e18d5c9575f716e24559645d08a4044d6946c30c2e0025952c84d842" -"checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff81738b726f5d099632ceaffe7fb65b90212e8dce59d518729e7e8634032d3d" -"checksum bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d828f97b58cc5de3e40c421d0cf2132d6b2da4ee0e11b8632fa838f0f9333ad6" "checksum c_vec 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6237ac5a4b1e81c213c24c6437964c61e646df910a914b4ab1487b46df20bd13" "checksum cairo-rs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9d336f1b2ff46c17475a14360de7f456707008da475c54824887e52e453ab00" "checksum cairo-sys-rs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9e8a1e2a76ac09b959788c2c30a355d693ce6f7f7d7268f6d1dd5d8c3359c521" -"checksum cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b13a57efd6b30ecd6598ebdb302cca617930b5470647570468a65d12ef9719" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "78ff10625fd0ac447827aa30ea8b861fead473bb60aeb73af6c1c58caf0d1299" -"checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67" -"checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d" -"checksum crypt32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e34988f7e069e0b2f3bfc064295161e489b2d4e04a2e4248fb94360cdf00b4ec" "checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" -"checksum foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e4056b9bd47f8ac5ba12be771f77a0dae796d1bbaaf5fd0b9c2d38b69b8a29d" -"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159" -"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82" -"checksum futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "05a23db7bd162d4e8265968602930c476f688f0c180b44bdaf55e0cb2c687558" -"checksum futures-cpupool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e86f49cc0d92fe1b97a5980ec32d56208272cbb00f15044ea9e2799dde766fdf" "checksum gdk 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f30018ecbbb1e6f1d59c4024ec08675850744b799abc5420be0629ac9ba0abd2" "checksum gdk-pixbuf 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "caf05dab73febcc6e90abaff8f24cfe1cf1bd2222cd648ddfe337bf3b994489f" "checksum gdk-pixbuf-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85eb441420653b33e5a29d13227ea34995383e65bf4f33b16492ec95e44a8996" @@ -1103,35 +621,19 @@ dependencies = [ "checksum gtk 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce17f98e7dcdc9d06b3a5f7621d796a24937c04953481205b1be267c5a02697a" "checksum gtk-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "854b56ce6d6b05945f7735651482835c5ac1f8582142ce67306726259a3dafb0" "checksum htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163" -"checksum httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af2f2dd97457e8fb1ae7c5a420db346af389926e36f43768b96f101546b04a07" -"checksum hyper 0.11.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1b45eac8b696d59491b079bd04fcb0f3488c0f6ed62dcb36bcfea8a543e9cdc3" -"checksum hyper-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c81fa95203e2a6087242c38691a0210f23e9f3f8f944350bd676522132e2985" -"checksum iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6e8b9c2247fcf6c6a1151f1156932be5606c9fd6f55a2d7f9fc1cb29386b2f7" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" -"checksum lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b585b7a6811fb03aa10e74b278a0f00f8dd9b45dc681f148bb29fa5cb61859b" "checksum libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "8a014d9226c2cc402676fbe9ea2e15dd5222cd1dd57f576b5b283178c944a264" "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" "checksum magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf0336886480e671965f794bc9b6fce88503563013d1bfb7a502c81fe3ac527" "checksum magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40d014c7011ac470ae28e2f76a02bfea4a8480f73e701353b49ad7a8d75f4699" "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" -"checksum mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e00e17be181010a91dbfefb01660b17311059dc8c7f48b9017677721e732bd" -"checksum mio 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0e8411968194c7b139e9105bc4ae7db0bae232af087147e72f0616ebf5fdb9cb" -"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum native-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04b781c9134a954c84f0594b9ab3f5606abc516030388e8511887ef4c204a1e5" "checksum neovim-lib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cd81cd2140309fcbe61775ebe5901b0730e5fdae2558a6cd27539e6e730fa76a" -"checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" "checksum num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "99843c856d68d8b4313b03a17e33c4bb42ae8f6610ea81b28abe076ac721b9b0" -"checksum num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d" -"checksum openssl 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf434ff6117485dc16478d77a4f5c84eccc9c3645c4da8323b287ad6a15a638" -"checksum openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)" = "0ad395f1cee51b64a8d07cc8063498dc7554db62d5f3ca87a67f4eed2791d0c8" "checksum pango 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5afa4b4c5380315b12075e7767d9bdd62d53beeb6087d9287ef6990e57a6b643" "checksum pango-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e6ec8d90306b5ff43f5836f4363267ea95be02b3df71d2b31ba8fbb1680bdee1" "checksum pangocairo 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8edeb86f36f8f10a252a888fa3d9aff4d0681373da918c207eac2208aa091e6" "checksum pangocairo-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c26c200ef32a682bf8b693b47996c3c33e0b2de32b30f7251cc60673ad513bef" -"checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356" "checksum phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "cb325642290f28ee14d8c6201159949a872f220c62af6e110a56ea914fbe42fc" "checksum phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d62594c0bb54c464f633175d502038177e90309daf2e0158be42ed5f023ce88f" "checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03" @@ -1139,47 +641,22 @@ dependencies = [ "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "eb250fd207a4729c976794d03db689c9be1d634ab5a1c9da9492a13d8fecbcdf" -"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" -"checksum relay 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f301bafeb60867c85170031bdb2fcf24c8041f33aee09e7b116a58d4e9f781c5" "checksum rmp 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7ce560a5728f4eec697f07f8d7fa20608893d44b4f5b8f9f5f51a2987f3cffe2" "checksum rmpv 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "45368daa6c60116376d8813ec6a2556df640229709becb8f80df1651f882e7af" -"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" -"checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" -"checksum schannel 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7554288337c1110e34d7a2433518d889374c1de1a45f856b7bcddb03702131fc" -"checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" -"checksum secur32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f412dfa83308d893101dd59c10d6fda8283465976c28c287c5c855bf8d216bc" -"checksum security-framework 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "dfa44ee9c54ce5eecc9de7d5acbad112ee58755239381f687e564004ba4a2332" -"checksum security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "5421621e836278a0b139268f36eee0dc7e389b784dc3f79d8f11aabadf41bead" -"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" "checksum serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f7726f29ddf9731b17ff113c461e362c381d9d69433f79de4f3dd572488823e9" "checksum serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cf823e706be268e73e7747b147aa31c8f633ab4ba31f115efb57e5047c3a76dd" "checksum serde_derive_internals 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37aee4e0da52d801acfbc0cc219eb1eda7142112339726e427926a6f6ee65d3a" "checksum serde_json 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ae1e67ce320daa7e494c578e34d4b00689f23bb94512fe0ca0dfaf02ea53fb67" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" -"checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" -"checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" -"checksum smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -"checksum take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b157868d8ac1f56b64604539990685fa7611d8fa9e5476cf0c02cf34d32917c5" -"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" "checksum thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14" -"checksum time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d788d3aa77bc0ef3e9621256885555368b47bd495c13dd2e7413c89f845520" -"checksum tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "c843a027f7c1df5f81e7734a0df3f67bf329411781ebf36393ce67beef6071e3" -"checksum tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ab83e7adb5677e42e405fa4ceff75659d93c4d7d7dd22f52fcec59ee9f02af" -"checksum tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fbb47ae81353c63c487030659494b295f6cb6576242f907f203473b191b0389" -"checksum tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" -"checksum tokio-tls 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d88e411cac1c87e405e4090be004493c5d8072a370661033b1a64ea205ec2e13" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" -"checksum unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e01da42520092d0cd2d6ac3ae69eb21a22ad43ff195676b86f8c37f487d6b80" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6aa2700417c405c38f5e6902d699345241c28c0b7ade4abaad71e35a87eb1564" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" -"checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/Cargo.toml b/Cargo.toml index 265ed92..80af648 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,12 +34,6 @@ htmlescape = "0.3" serde = "1.0" serde_derive = "1.0" toml = "0.4" - -# http request library -futures = "0.1" -hyper = "0.11" -hyper-tls = "0.1" -tokio-core = "0.1" serde_json = "1.0" #[dependencies.neovim-lib] diff --git a/src/main.rs b/src/main.rs index 9266918..8e1202e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,13 +22,7 @@ extern crate serde; #[macro_use] extern crate serde_derive; extern crate toml; - -// http request library -extern crate futures; -extern crate hyper; -extern crate tokio_core; extern crate serde_json; -extern crate hyper_tls; mod sys; diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index 17d7c79..5b88918 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -11,7 +11,7 @@ use gtk::prelude::*; use super::manager; use super::store::{Store, PlugInfo}; use super::plugin_settings_dlg; -use super::vimawesome::Vimawesome; +use super::vimawesome; pub struct Ui<'a> { manager: &'a Arc>, @@ -63,6 +63,8 @@ impl<'a> Ui<'a> { enable_swc.set_state(self.manager.borrow().store.is_enabled()); + let get_plugins = add_get_plugins_tab(&pages); + match self.manager.borrow().plug_manage_state { manager::PlugManageState::Unknown => { add_help_tab( @@ -78,15 +80,7 @@ impl<'a> Ui<'a> { Current configuration taken from your vim-plug", ); } - manager::PlugManageState::NvimGtk => { - let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); - - Vimawesome::new().log(); - - let get_plugins_lbl = gtk::Label::new("Get Plugins"); - pages.add_page(&get_plugins_lbl, &get_plugins, "get_plugins"); - - } + manager::PlugManageState::NvimGtk => {} } let plugs_panel = self.add_plugin_list_tab(&pages, &self.manager.borrow().store); @@ -105,9 +99,26 @@ impl<'a> Ui<'a> { content.pack_start(&*pages, true, true, 0); content.show_all(); + let get_plugins = UiMutex::new(get_plugins); + vimawesome::call(move |res| { + let panel = get_plugins.borrow(); + for child in panel.get_children() { + panel.remove(&child); + } + match res { + Ok(list) => { + let result = vimawesome::build_result_panel(&list); + panel.pack_start(&result, true, true, 0); + } + Err(e) => { + panel.pack_start(>k::Label::new(format!("{}", e).as_str()), false, true, 0); + error!("{}", e) + }, + } + }); let ok: i32 = gtk::ResponseType::Ok.into(); - if dlg.run() == ok { + if dlg.run() == ok { let mut manager = self.manager.borrow_mut(); manager.clear_removed(); manager.save(); @@ -226,6 +237,23 @@ fn create_plug_label(plug_info: &PlugInfo) -> gtk::Box { label_box } +fn add_get_plugins_tab(pages: &SettingsPages) -> gtk::Box { + let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); + let spinner = gtk::Spinner::new(); + let get_plugins_lbl = gtk::Label::new("Get Plugins"); + pages.add_page(&get_plugins_lbl, &get_plugins, "get_plugins"); + + let list_panel = gtk::Box::new(gtk::Orientation::Vertical, 0); + let link_button = gtk::Label::new(None); + link_button.set_markup("Plugins source: https://vimawesome.com"); + get_plugins.pack_start(&link_button, false, true, 15); + get_plugins.pack_start(&list_panel, true, true, 0); + list_panel.pack_start(&spinner, true, true, 0); + spinner.start(); + + list_panel +} + fn add_help_tab(pages: &SettingsPages, markup: &str) { let help = gtk::Box::new(gtk::Orientation::Vertical, 3); let label = gtk::Label::new(None); diff --git a/src/plug_manager/vimawesome.rs b/src/plug_manager/vimawesome.rs index e72d1c6..7bc8819 100644 --- a/src/plug_manager/vimawesome.rs +++ b/src/plug_manager/vimawesome.rs @@ -1,56 +1,130 @@ use std::io; -use futures::{Future, Stream}; -use hyper::{self, Client}; -use tokio_core::reactor::Core; +use std::thread; +use std::process::{Command, Stdio}; + use serde_json; -use hyper_tls::HttpsConnector; -pub struct Vimawesome {} +use gtk; +use gtk::prelude::*; +use glib; -impl Vimawesome { - pub fn new() -> Self { - Vimawesome {} +pub fn call(cb: F) +where + F: FnOnce(io::Result) + Send + 'static, +{ + thread::spawn(move || { + let mut cb = Some(cb); + glib::idle_add(move || { + cb.take().unwrap()(request()); + glib::Continue(false) + }) + }); +} + +fn request() -> io::Result { + let child = Command::new("curl") + .arg("-s") + .arg("https://vimawesome.com/api/plugins?query=&page=1") + .stdout(Stdio::piped()) + .spawn()?; + + let out = child.wait_with_output()?; + + if out.status.success() { + let description_list: DescriptionList = serde_json::from_slice(&out.stdout).map_err(|e| { + io::Error::new(io::ErrorKind::Other, e) + })?; + Ok(description_list) + } else { + Err(io::Error::new( + io::ErrorKind::Other, + format!( + "curl exit with error:\n{}", + match out.status.code() { + Some(code) => format!("Exited with status code: {}", code), + None => "Process terminated by signal".to_owned(), + } + ), + )) + } +} + +pub fn build_result_panel(list: &DescriptionList) -> gtk::ScrolledWindow { + let scroll = gtk::ScrolledWindow::new(None, None); + scroll.get_style_context().map(|c| c.add_class("view")); + let panel = gtk::ListBox::new(); + + for plug in list.plugins.iter() { + let row = create_plug_row(plug); + + panel.add(&row); } - pub fn log(&self) { - match self.request() { - Ok(list) => println!("list: {:?}", list), - Err(e) => error!("{}", e), - } - } + scroll.add(&panel); + scroll.show_all(); + scroll +} - fn request(&self) -> Result { - let mut core = Core::new()?; - let handle = core.handle(); - let client = Client::configure() - .connector(HttpsConnector::new(4, &handle).map_err(|e| { - io::Error::new(io::ErrorKind::Other, e) - })?) - .build(&handle); - let uri = "https://vimawesome.com/api/plugins?query=&page=1".parse()?; +fn create_plug_row(plug: &Description) -> gtk::ListBoxRow { + let row = gtk::ListBoxRow::new(); + let row_container = gtk::Box::new(gtk::Orientation::Vertical, 5); + row_container.set_border_width(5); + let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 5); + let label_box = create_plug_label(plug); - let work = client.get(uri).and_then(|res| { - res.body().concat2().and_then(move |body| { - let description_list: DescriptionList = - serde_json::from_slice(&body).map_err(|e| { - io::Error::new(io::ErrorKind::Other, e) - })?; - Ok(description_list) - }) - }); - core.run(work) + + let button_box = gtk::Box::new(gtk::Orientation::Horizontal, 0); + button_box.set_halign(gtk::Align::End); + + let add_btn = gtk::Button::new_with_label("Install"); + button_box.pack_start(&add_btn, false, true, 0); + + row_container.pack_start(&hbox, true, true, 0); + hbox.pack_start(&label_box, true, true, 0); + hbox.pack_start(&button_box, false, true, 0); + + row.add(&row_container); + + + add_btn.connect_clicked(clone!(button_box => move |_| { })); + + row +} + + +fn create_plug_label(plug: &Description) -> gtk::Box { + let label_box = gtk::Box::new(gtk::Orientation::Vertical, 5); + + let name_lbl = gtk::Label::new(None); + name_lbl.set_markup(&format!( + "{} by {}", + plug.name, + plug.author.as_ref().map(|s| s.as_ref()).unwrap_or( + "unknown", + ) + )); + name_lbl.set_halign(gtk::Align::Start); + let url_lbl = gtk::Label::new(None); + if let Some(url) = plug.github_url.as_ref() { + url_lbl.set_markup(&format!("{}", url, url)); } + url_lbl.set_halign(gtk::Align::Start); + + + label_box.pack_start(&name_lbl, true, true, 0); + label_box.pack_start(&url_lbl, true, true, 0); + label_box } #[derive(Serialize, Deserialize, Debug)] -struct DescriptionList { - plugins: Box<[Description]>, +pub struct DescriptionList { + pub plugins: Box<[Description]>, } #[derive(Serialize, Deserialize, Debug)] -struct Description { - name: String, - github_url: String, - author: String, - github_stars: i64, +pub struct Description { + pub name: String, + pub github_url: Option, + pub author: Option, + pub github_stars: Option, } From edebb8b673cccc33371f1e1f2074617c437614e3 Mon Sep 17 00:00:00 2001 From: daa84 Date: Wed, 1 Nov 2017 17:40:54 +0300 Subject: [PATCH 22/30] vimawesome search, allow to install vimawesome plugins --- src/plug_manager/manager.rs | 4 +- src/plug_manager/store.rs | 7 +- src/plug_manager/ui.rs | 122 +++++++++++++++++++++++---------- src/plug_manager/vimawesome.rs | 40 ++++++++--- 4 files changed, 122 insertions(+), 51 deletions(-) diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index 727cf1a..8b824ff 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -57,8 +57,8 @@ impl Manager { self.store.clear_removed(); } - pub fn add_plug(&mut self, plug: PlugInfo) { - self.store.add_plug(plug); + pub fn add_plug(&mut self, plug: PlugInfo) -> bool { + self.store.add_plug(plug) } } diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index a9cf6eb..f9e5be5 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -66,8 +66,13 @@ impl Store { self.settings.plugs[idx].removed = false; } - pub fn add_plug(&mut self, plug: PlugInfo) { + pub fn add_plug(&mut self, plug: PlugInfo) -> bool { + let path = plug.get_plug_path(); + if self.settings.plugs.iter().any(|p| p.get_plug_path() == path || p.name == plug.name) { + return false; + } self.settings.plugs.push(plug); + true } pub fn plugs_count(&self) -> usize { diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index 5b88918..c24d430 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -63,7 +63,10 @@ impl<'a> Ui<'a> { enable_swc.set_state(self.manager.borrow().store.is_enabled()); - let get_plugins = add_get_plugins_tab(&pages); + let plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); + let plugs_panel = self.fill_plugin_list(&plugins, &self.manager.borrow().store); + + add_vimawesome_tab(&pages, &self.manager, &plugs_panel); match self.manager.borrow().plug_manage_state { manager::PlugManageState::Unknown => { @@ -83,7 +86,8 @@ impl<'a> Ui<'a> { manager::PlugManageState::NvimGtk => {} } - let plugs_panel = self.add_plugin_list_tab(&pages, &self.manager.borrow().store); + let plugins_lbl = gtk::Label::new("Plugins"); + pages.add_page(&plugins_lbl, &plugins, "plugins"); let manager_ref = self.manager.clone(); enable_swc.connect_state_set(move |_, state| { @@ -93,29 +97,12 @@ impl<'a> Ui<'a> { let manager_ref = self.manager.clone(); add_plug_btn.connect_clicked(clone!(dlg => move |_| { - add_plugin(&dlg, &manager_ref, &plugs_panel); + show_add_plug_dlg(&dlg, &manager_ref, &plugs_panel); })); content.pack_start(&*pages, true, true, 0); content.show_all(); - let get_plugins = UiMutex::new(get_plugins); - vimawesome::call(move |res| { - let panel = get_plugins.borrow(); - for child in panel.get_children() { - panel.remove(&child); - } - match res { - Ok(list) => { - let result = vimawesome::build_result_panel(&list); - panel.pack_start(&result, true, true, 0); - } - Err(e) => { - panel.pack_start(>k::Label::new(format!("{}", e).as_str()), false, true, 0); - error!("{}", e) - }, - } - }); let ok: i32 = gtk::ResponseType::Ok.into(); if dlg.run() == ok { @@ -127,15 +114,6 @@ impl<'a> Ui<'a> { dlg.destroy(); } - fn add_plugin_list_tab(&self, pages: &SettingsPages, store: &Store) -> gtk::ListBox { - let plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); - let plugs_panel = self.fill_plugin_list(&plugins, store); - - let plugins_lbl = gtk::Label::new("Plugins"); - pages.add_page(&plugins_lbl, &plugins, "plugins"); - plugs_panel - } - fn fill_plugin_list(&self, panel: >k::Box, store: &Store) -> gtk::ListBox { let scroll = gtk::ScrolledWindow::new(None, None); scroll.get_style_context().map(|c| c.add_class("view")); @@ -154,6 +132,34 @@ impl<'a> Ui<'a> { } } +fn populate_get_plugins( + query: Option, + get_plugins: >k::Box, + manager: Arc>, + plugs_panel: gtk::ListBox, +) { + let plugs_panel = UiMutex::new(plugs_panel); + let get_plugins = UiMutex::new(get_plugins.clone()); + vimawesome::call(query, move |res| { + let panel = get_plugins.borrow(); + for child in panel.get_children() { + panel.remove(&child); + } + match res { + Ok(list) => { + let result = vimawesome::build_result_panel(&list, move |new_plug| { + add_plugin(&manager, &*plugs_panel.borrow(), new_plug); + }); + panel.pack_start(&result, true, true, 0); + } + Err(e) => { + panel.pack_start(>k::Label::new(format!("{}", e).as_str()), false, true, 0); + error!("{}", e) + } + } + }); +} + fn create_plug_row( plug_idx: usize, plug_info: &PlugInfo, @@ -208,17 +214,38 @@ fn create_plug_row( row } -fn add_plugin>( +fn show_add_plug_dlg>( parent: &F, manager: &Arc>, plugs_panel: >k::ListBox, ) { if let Some(new_plugin) = plugin_settings_dlg::Builder::new("Add plugin").show(parent) { - let row = create_plug_row(manager.borrow().store.plugs_count(), &new_plugin, manager); + add_plugin(manager, plugs_panel, new_plugin); + } +} + +fn add_plugin( + manager: &Arc>, + plugs_panel: >k::ListBox, + new_plugin: PlugInfo, +) -> bool { + let row = create_plug_row(manager.borrow().store.plugs_count(), &new_plugin, manager); + + if manager.borrow_mut().add_plug(new_plugin) { row.show_all(); plugs_panel.add(&row); - - manager.borrow_mut().add_plug(new_plugin); + true + } else { + let dlg = gtk::MessageDialog::new( + None::<>k::Window>, + gtk::DialogFlags::empty(), + gtk::MessageType::Error, + gtk::ButtonsType::Ok, + "Plugin with this name or path already exists", + ); + dlg.run(); + dlg.destroy(); + false } } @@ -237,7 +264,11 @@ fn create_plug_label(plug_info: &PlugInfo) -> gtk::Box { label_box } -fn add_get_plugins_tab(pages: &SettingsPages) -> gtk::Box { +fn add_vimawesome_tab( + pages: &SettingsPages, + manager: &Arc>, + plugs_panel: >k::ListBox, +) { let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); let spinner = gtk::Spinner::new(); let get_plugins_lbl = gtk::Label::new("Get Plugins"); @@ -245,13 +276,30 @@ fn add_get_plugins_tab(pages: &SettingsPages) -> gtk::Box { let list_panel = gtk::Box::new(gtk::Orientation::Vertical, 0); let link_button = gtk::Label::new(None); - link_button.set_markup("Plugins source: https://vimawesome.com"); - get_plugins.pack_start(&link_button, false, true, 15); + link_button.set_markup( + "Plugins are taken from: https://vimawesome.com", + ); + let search_entry = gtk::Entry::new(); + search_entry.set_icon_from_icon_name(gtk::EntryIconPosition::Primary, "edit-find"); + + get_plugins.pack_start(&link_button, false, true, 10); + get_plugins.pack_start(&search_entry, false, true, 5); get_plugins.pack_start(&list_panel, true, true, 0); list_panel.pack_start(&spinner, true, true, 0); spinner.start(); - list_panel + search_entry.connect_activate(clone!(list_panel, manager, plugs_panel => move |se| { + let spinner = gtk::Spinner::new(); + list_panel.pack_start(&spinner, false, true, 5); + spinner.show(); + spinner.start(); + populate_get_plugins(se.get_text(), &list_panel, manager.clone(), plugs_panel.clone()); + })); + + gtk::idle_add(clone!(manager, plugs_panel => move || { + populate_get_plugins(None, &list_panel, manager.clone(), plugs_panel.clone()); + Continue(false) + })); } fn add_help_tab(pages: &SettingsPages, markup: &str) { diff --git a/src/plug_manager/vimawesome.rs b/src/plug_manager/vimawesome.rs index 7bc8819..82497cc 100644 --- a/src/plug_manager/vimawesome.rs +++ b/src/plug_manager/vimawesome.rs @@ -1,5 +1,6 @@ use std::io; use std::thread; +use std::rc::Rc; use std::process::{Command, Stdio}; use serde_json; @@ -8,23 +9,28 @@ use gtk; use gtk::prelude::*; use glib; -pub fn call(cb: F) +use super::store::PlugInfo; + +pub fn call(query: Option, cb: F) where F: FnOnce(io::Result) + Send + 'static, { thread::spawn(move || { let mut cb = Some(cb); glib::idle_add(move || { - cb.take().unwrap()(request()); - glib::Continue(false) + cb.take().unwrap()(request(query.as_ref().map(|s| s.as_ref()))); + Continue(false) }) }); } -fn request() -> io::Result { +fn request(query: Option<&str>) -> io::Result { let child = Command::new("curl") .arg("-s") - .arg("https://vimawesome.com/api/plugins?query=&page=1") + .arg(format!( + "https://vimawesome.com/api/plugins?query={}&page=1", + query.unwrap_or("") + )) .stdout(Stdio::piped()) .spawn()?; @@ -49,13 +55,17 @@ fn request() -> io::Result { } } -pub fn build_result_panel(list: &DescriptionList) -> gtk::ScrolledWindow { +pub fn build_result_panel( + list: &DescriptionList, + add_cb: F, +) -> gtk::ScrolledWindow { let scroll = gtk::ScrolledWindow::new(None, None); scroll.get_style_context().map(|c| c.add_class("view")); let panel = gtk::ListBox::new(); + let cb_ref = Rc::new(add_cb); for plug in list.plugins.iter() { - let row = create_plug_row(plug); + let row = create_plug_row(plug, cb_ref.clone()); panel.add(&row); } @@ -65,7 +75,10 @@ pub fn build_result_panel(list: &DescriptionList) -> gtk::ScrolledWindow { scroll } -fn create_plug_row(plug: &Description) -> gtk::ListBoxRow { +fn create_plug_row( + plug: &Description, + add_cb: Rc, +) -> gtk::ListBoxRow { let row = gtk::ListBoxRow::new(); let row_container = gtk::Box::new(gtk::Orientation::Vertical, 5); row_container.set_border_width(5); @@ -86,7 +99,12 @@ fn create_plug_row(plug: &Description) -> gtk::ListBoxRow { row.add(&row_container); - add_btn.connect_clicked(clone!(button_box => move |_| { })); + add_btn.connect_clicked(clone!(plug => move |btn| { + if let Some(ref github_url) = plug.github_url { + btn.set_sensitive(false); + add_cb(PlugInfo::new(plug.name.clone(), github_url.clone())); + } + })); row } @@ -116,12 +134,12 @@ fn create_plug_label(plug: &Description) -> gtk::Box { label_box } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Deserialize, Debug)] pub struct DescriptionList { pub plugins: Box<[Description]>, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone)] pub struct Description { pub name: String, pub github_url: Option, From afa282833adda66ce3ce1fc3f4ead71e991bfe88 Mon Sep 17 00:00:00 2001 From: daa84 Date: Thu, 2 Nov 2017 17:31:46 +0300 Subject: [PATCH 23/30] Plugs reordering, load config on window start --- src/plug_manager/manager.rs | 31 ++++++++++++- src/plug_manager/store.rs | 5 ++ src/plug_manager/ui.rs | 91 +++++++++++++++++++++++++++++-------- 3 files changed, 106 insertions(+), 21 deletions(-) diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index 8b824ff..a81c830 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -40,7 +40,32 @@ impl Manager { self.vim_plug.initialize(nvim); } - pub fn update_state(&mut self) { + pub fn reload_store(&mut self) { + match self.plug_manage_state { + PlugManageState::Unknown => { + if self.vim_plug.is_loaded() { + self.store = Store::load_from_plug(&self.vim_plug); + self.plug_manage_state = PlugManageState::VimPlug; + } else { + self.store = Store::empty(); + } + } + PlugManageState::NvimGtk => { + if Store::is_config_exists() { + self.store = Store::load(); + } else { + self.store = Store::empty(); + } + } + PlugManageState::VimPlug => { + if Store::is_config_exists() { + self.store = Store::load(); + self.plug_manage_state = PlugManageState::NvimGtk; + } else { + self.store = Store::empty(); + } + } + } if let PlugManageState::Unknown = self.plug_manage_state { if self.vim_plug.is_loaded() { self.store = Store::load_from_plug(&self.vim_plug); @@ -60,6 +85,10 @@ impl Manager { pub fn add_plug(&mut self, plug: PlugInfo) -> bool { self.store.add_plug(plug) } + + pub fn move_item(&mut self, idx: usize, offset: i32) { + self.store.move_item(idx, offset); + } } pub enum PlugManageState { diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index f9e5be5..39e8903 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -78,6 +78,11 @@ impl Store { pub fn plugs_count(&self) -> usize { self.settings.plugs.len() } + + pub fn move_item(&mut self, idx: usize, offset: i32) { + let plug = self.settings.plugs.remove(idx); + self.settings.plugs.insert((idx as i32 + offset) as usize, plug); + } } #[derive(Serialize, Deserialize)] diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index c24d430..fa8aee5 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -7,6 +7,7 @@ use ui::UiMutex; use gtk; use gtk::prelude::*; +use gtk_sys; use super::manager; use super::store::{Store, PlugInfo}; @@ -19,7 +20,7 @@ pub struct Ui<'a> { impl<'a> Ui<'a> { pub fn new(manager: &'a Arc>) -> Ui<'a> { - manager.borrow_mut().update_state(); + manager.borrow_mut().reload_store(); Ui { manager } } @@ -29,7 +30,10 @@ impl<'a> Ui<'a> { Some("Plug"), Some(parent), gtk::DIALOG_DESTROY_WITH_PARENT, - &[("Ok", gtk::ResponseType::Ok.into())], + &[ + ("Cancel", gtk::ResponseType::Cancel.into()), + ("Ok", gtk::ResponseType::Ok.into()), + ], ); dlg.set_default_size(800, 600); @@ -68,27 +72,25 @@ impl<'a> Ui<'a> { add_vimawesome_tab(&pages, &self.manager, &plugs_panel); - match self.manager.borrow().plug_manage_state { - manager::PlugManageState::Unknown => { - add_help_tab( - &pages, - "Note: NeovimGtk plugin manager disabled!", - ); - } - manager::PlugManageState::VimPlug => { - add_help_tab( - &pages, - "Note: NeovimGtk plugin manager disabled!\n\ - NeovimGtk manages plugins use vim-plug as backend, so enable it disables vim-plug configuration.\n\ - Current configuration taken from your vim-plug", - ); - } - manager::PlugManageState::NvimGtk => {} - } let plugins_lbl = gtk::Label::new("Plugins"); pages.add_page(&plugins_lbl, &plugins, "plugins"); + add_help_tab( + &pages, + &format!("NeovimGtk plugin manager is a GUI for vim-plug.\n\ + It can load plugins from vim-plug configuration if vim-plug sarted and self settings is empty.\n\ + When enabled it generate and load vim-plug as simple vim file at startup before init.vim is processed.\n\ + So after enabling this manager you must disable vim-plug configuration in init.vim.\n\ + This manager currently only manage vim-plug configuration and do not any actions on plugin management.\n\ + So you must call all vim-plug (PlugInstall, PlugUpdate, PlugClean) commands manually.\n\ + Current configuration source is {}", match self.manager.borrow().plug_manage_state { + manager::PlugManageState::NvimGtk => "config file", + manager::PlugManageState::VimPlug => "loaded from vim-plug", + manager::PlugManageState::Unknown => "Unknown", + }), + ); + let manager_ref = self.manager.clone(); enable_swc.connect_state_set(move |_, state| { manager_ref.borrow_mut().store.set_enabled(state); @@ -126,12 +128,61 @@ impl<'a> Ui<'a> { } scroll.add(&plugs_panel); - panel.pack_start(&scroll, true, true, 0); + panel.pack_start(&scroll, true, true, 5); + + panel.pack_start( + &create_up_down_btns(&plugs_panel, &self.manager), + false, + true, + 0, + ); plugs_panel } } +fn create_up_down_btns( + plugs_panel: >k::ListBox, + manager: &Arc>, +) -> gtk::Box { + let buttons_panel = gtk::Box::new(gtk::Orientation::Horizontal, 5); + let up_btn = gtk::Button::new_from_icon_name("go-up", gtk_sys::GTK_ICON_SIZE_BUTTON as i32); + let down_btn = gtk::Button::new_from_icon_name("go-down", gtk_sys::GTK_ICON_SIZE_BUTTON as i32); + + up_btn.connect_clicked(clone!(plugs_panel, manager => move |_| { + if let Some(row) = plugs_panel.get_selected_row() { + let idx = row.get_index(); + if idx > 0 { + plugs_panel.unselect_row(&row); + plugs_panel.remove(&row); + plugs_panel.insert(&row, idx - 1); + plugs_panel.select_row(&row); + manager.borrow_mut().move_item(idx as usize, -1); + } + } + })); + + + down_btn.connect_clicked(clone!(plugs_panel, manager => move |_| { + if let Some(row) = plugs_panel.get_selected_row() { + let idx = row.get_index(); + let mut manager = manager.borrow_mut(); + if idx >= 0 && idx < manager.store.plugs_count() as i32 { + plugs_panel.unselect_row(&row); + plugs_panel.remove(&row); + plugs_panel.insert(&row, idx + 1); + plugs_panel.select_row(&row); + manager.move_item(idx as usize, 1); + } + } + })); + + buttons_panel.pack_start(&up_btn, false, true, 0); + buttons_panel.pack_start(&down_btn, false, true, 0); + + buttons_panel +} + fn populate_get_plugins( query: Option, get_plugins: >k::Box, From 5345d178bfb12518af5434a5f48602ce4ee3565a Mon Sep 17 00:00:00 2001 From: daa Date: Sat, 4 Nov 2017 23:04:03 +0300 Subject: [PATCH 24/30] Update vim configuration on save source configuration one Ok pressed --- src/nvim.rs | 3 +- src/nvim_config.rs | 15 ++++++- src/plug_manager/manager.rs | 3 +- src/plug_manager/plugin_settings_dlg.rs | 57 ++++++++++++++++++++++--- src/plug_manager/ui.rs | 21 ++++++--- src/plug_manager/vim_plug.rs | 6 +++ src/plug_manager/vimawesome.rs | 24 ++++++++--- src/shell.rs | 15 +++---- src/ui.rs | 7 +-- 9 files changed, 113 insertions(+), 38 deletions(-) diff --git a/src/nvim.rs b/src/nvim.rs index aef6c11..2f5cec0 100644 --- a/src/nvim.rs +++ b/src/nvim.rs @@ -228,7 +228,6 @@ impl error::Error for NvimInitError { pub fn start( shell: Arc>, nvim_bin_path: Option<&String>, - nvim_config: NvimConfig, ) -> result::Result { let mut cmd = if let Some(path) = nvim_bin_path { Command::new(path) @@ -259,7 +258,7 @@ pub fn start( cmd.arg("--cmd").arg("let &rtp.=',runtime'"); } - if let Some(nvim_config) = nvim_config.generate_config() { + if let Some(nvim_config) = NvimConfig::config_path() { if let Some(path) = nvim_config.to_str() { cmd.arg("--cmd").arg(format!("source {}", path)); } diff --git a/src/nvim_config.rs b/src/nvim_config.rs index c0d328a..592eb3d 100644 --- a/src/nvim_config.rs +++ b/src/nvim_config.rs @@ -11,6 +11,8 @@ pub struct NvimConfig { } impl NvimConfig { + const CONFIG_PATH: &'static str = "settings.vim"; + pub fn new(plug_config: Option) -> Self { NvimConfig { plug_config } } @@ -29,9 +31,20 @@ impl NvimConfig { } } + pub fn config_path() -> Option { + if let Ok(mut path) = dirs::get_app_config_dir() { + path.push(NvimConfig::CONFIG_PATH); + if path.is_file() { + return Some(path); + } + } + + None + } + fn write_file(&self) -> Result { let mut config_dir = dirs::get_app_config_dir_create()?; - config_dir.push("plugins.vim"); + config_dir.push(NvimConfig::CONFIG_PATH); let mut file = OpenOptions::new() .create(true) diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index a81c830..1ac6382 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -7,14 +7,13 @@ use super::store::{Store, PlugInfo}; use nvim::NeovimClient; pub struct Manager { - vim_plug: vim_plug::Manager, + pub vim_plug: vim_plug::Manager, pub store: Store, pub plug_manage_state: PlugManageState, } impl Manager { pub fn new() -> Self { - let (plug_manage_state, store) = if Store::is_config_exists() { (PlugManageState::NvimGtk, Store::load()) } else { diff --git a/src/plug_manager/plugin_settings_dlg.rs b/src/plug_manager/plugin_settings_dlg.rs index 26c680d..6f27b1d 100644 --- a/src/plug_manager/plugin_settings_dlg.rs +++ b/src/plug_manager/plugin_settings_dlg.rs @@ -28,22 +28,41 @@ impl<'a> Builder<'a> { list.set_selection_mode(gtk::SelectionMode::None); let path = gtk::Box::new(gtk::Orientation::Horizontal, 0); - let label = gtk::Label::new("Repo"); - let entry = gtk::Entry::new(); + let path_lbl = gtk::Label::new("Repo"); + let path_e = gtk::Entry::new(); - path.pack_start(&label, true, true, 0); - path.pack_end(&entry, false, true, 0); + path.pack_start(&path_lbl, true, true, 0); + path.pack_end(&path_e, false, true, 0); list.add(&path); + let name = gtk::Box::new(gtk::Orientation::Horizontal, 0); + let name_lbl = gtk::Label::new("Name"); + let name_e = gtk::Entry::new(); + + name.pack_start(&name_lbl, true, true, 0); + name.pack_end(&name_e, false, true, 0); + + list.add(&name); + content.add(&list); content.show_all(); let ok: i32 = gtk::ResponseType::Ok.into(); let res = if dlg.run() == ok { - entry.get_text().map(|name| { - store::PlugInfo::new(name.to_owned(), name.to_owned()) + path_e.get_text().map(|path| { + let name = name_e + .get_text() + .and_then(|name| if name.trim().is_empty() { + None + } else { + Some(name) + }) + .or_else(|| Builder::extract_name(&path)) + .unwrap_or_else(|| path.clone()); + + store::PlugInfo::new(name.to_owned(), path.to_owned()) }) } else { None @@ -53,4 +72,30 @@ impl<'a> Builder<'a> { res } + + fn extract_name(path: &str) -> Option { + if let Some(idx) = path.rfind(|c| c == '/' || c == '\\') { + if idx < path.len() - 1 { + let path = path.trim_right_matches(".git"); + Some(path[idx + 1..].to_owned()) + } else { + None + } + } else { + None + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_extract_name() { + assert_eq!( + Some("plugin_name"), + Builder::extract_name("http://github.com/somebody/plugin_name.git") + ); + } } diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index fa8aee5..5f13c82 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -13,6 +13,7 @@ use super::manager; use super::store::{Store, PlugInfo}; use super::plugin_settings_dlg; use super::vimawesome; +use nvim_config::NvimConfig; pub struct Ui<'a> { manager: &'a Arc>, @@ -78,17 +79,20 @@ impl<'a> Ui<'a> { add_help_tab( &pages, - &format!("NeovimGtk plugin manager is a GUI for vim-plug.\n\ + &format!( + "NeovimGtk plugin manager is a GUI for vim-plug.\n\ It can load plugins from vim-plug configuration if vim-plug sarted and self settings is empty.\n\ When enabled it generate and load vim-plug as simple vim file at startup before init.vim is processed.\n\ So after enabling this manager you must disable vim-plug configuration in init.vim.\n\ This manager currently only manage vim-plug configuration and do not any actions on plugin management.\n\ So you must call all vim-plug (PlugInstall, PlugUpdate, PlugClean) commands manually.\n\ - Current configuration source is {}", match self.manager.borrow().plug_manage_state { - manager::PlugManageState::NvimGtk => "config file", - manager::PlugManageState::VimPlug => "loaded from vim-plug", - manager::PlugManageState::Unknown => "Unknown", - }), + Current configuration source is {}", + match self.manager.borrow().plug_manage_state { + manager::PlugManageState::NvimGtk => "config file", + manager::PlugManageState::VimPlug => "loaded from vim-plug", + manager::PlugManageState::Unknown => "Unknown", + } + ), ); let manager_ref = self.manager.clone(); @@ -111,6 +115,11 @@ impl<'a> Ui<'a> { let mut manager = self.manager.borrow_mut(); manager.clear_removed(); manager.save(); + if let Some(config_path) = NvimConfig::new(manager.load_config()).generate_config() { + if let Some(path) = config_path.to_str() { + manager.vim_plug.reload(path); + } + } } dlg.destroy(); diff --git a/src/plug_manager/vim_plug.rs b/src/plug_manager/vim_plug.rs index d878d65..e6327d8 100644 --- a/src/plug_manager/vim_plug.rs +++ b/src/plug_manager/vim_plug.rs @@ -87,6 +87,12 @@ impl Manager { false } } + + pub fn reload(&self, path: &str) { + if let Some(mut nvim) = self.nvim() { + nvim.command(&format!("source {}", path)).report_err(&mut *nvim); + } + } } #[derive(Debug)] diff --git a/src/plug_manager/vimawesome.rs b/src/plug_manager/vimawesome.rs index 82497cc..78b53d3 100644 --- a/src/plug_manager/vimawesome.rs +++ b/src/plug_manager/vimawesome.rs @@ -16,9 +16,11 @@ where F: FnOnce(io::Result) + Send + 'static, { thread::spawn(move || { + let mut result = Some(request(query.as_ref().map(|s| s.as_ref()))); let mut cb = Some(cb); + glib::idle_add(move || { - cb.take().unwrap()(request(query.as_ref().map(|s| s.as_ref()))); + cb.take().unwrap()(result.take().unwrap()); Continue(false) }) }); @@ -37,10 +39,14 @@ fn request(query: Option<&str>) -> io::Result { let out = child.wait_with_output()?; if out.status.success() { - let description_list: DescriptionList = serde_json::from_slice(&out.stdout).map_err(|e| { - io::Error::new(io::ErrorKind::Other, e) - })?; - Ok(description_list) + if out.stdout.is_empty() { + Ok(DescriptionList::empty()) + } else { + let description_list: DescriptionList = serde_json::from_slice(&out.stdout).map_err(|e| { + io::Error::new(io::ErrorKind::Other, e) + })?; + Ok(description_list) + } } else { Err(io::Error::new( io::ErrorKind::Other, @@ -139,6 +145,14 @@ pub struct DescriptionList { pub plugins: Box<[Description]>, } +impl DescriptionList { + fn empty() -> DescriptionList { + DescriptionList { + plugins: Box::new([]), + } + } +} + #[derive(Deserialize, Debug, Clone)] pub struct Description { pub name: String, diff --git a/src/shell.rs b/src/shell.rs index 70af8d1..10facfb 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -22,7 +22,6 @@ use ui_model::{UiModel, Attrs, ModelRect}; use color::{ColorModel, Color, COLOR_BLACK, COLOR_WHITE, COLOR_RED}; use nvim; use nvim::{RedrawEvents, GuiApi, RepaintMode, ErrorReport, NeovimClient}; -use nvim_config::NvimConfig; use input; use input::keyval_to_input_string; use cursor::Cursor; @@ -78,14 +77,13 @@ pub struct State { resize_state: Rc>, options: ShellOptions, - nvim_config: NvimConfig, detach_cb: Option>>, nvim_started_cb: Option>>, } impl State { - pub fn new(settings: Rc>, options: ShellOptions, nvim_config: NvimConfig) -> State { + pub fn new(settings: Rc>, options: ShellOptions) -> State { let drawing_area = gtk::DrawingArea::new(); let popup_menu = RefCell::new(PopupMenu::new(&drawing_area)); let font_ctx = render::Context::new(FontDescription::from_string(DEFAULT_FONT_NAME)); @@ -113,7 +111,6 @@ impl State { resize_state: Rc::new(Cell::new(ResizeState::Wait)), options, - nvim_config, detach_cb: None, nvim_started_cb: None, @@ -393,9 +390,9 @@ pub struct Shell { } impl Shell { - pub fn new(settings: Rc>, options: ShellOptions, nvim_config: NvimConfig) -> Shell { + pub fn new(settings: Rc>, options: ShellOptions) -> Shell { let shell = Shell { - state: Arc::new(UiMutex::new(State::new(settings, options, nvim_config))), + state: Arc::new(UiMutex::new(State::new(settings, options))), ui_state: Rc::new(RefCell::new(UiState::new())), widget: gtk::Box::new(gtk::Orientation::Vertical, 0), @@ -768,12 +765,11 @@ fn show_nvim_init_error(err: &nvim::NvimInitError, state_arc: Arc fn init_nvim_async( state_arc: Arc>, options: ShellOptions, - nvim_config: NvimConfig, cols: usize, rows: usize, ) { // execute nvim - let mut nvim = match nvim::start(state_arc.clone(), options.nvim_bin_path.as_ref(), nvim_config) { + let mut nvim = match nvim::start(state_arc.clone(), options.nvim_bin_path.as_ref()) { Ok(nvim) => nvim, Err(err) => { show_nvim_start_error(&err, state_arc); @@ -868,8 +864,7 @@ fn init_nvim(state_ref: &Arc>) { let state_arc = state_ref.clone(); let options = state.options.clone(); - let nvim_config = state.nvim_config.clone(); - thread::spawn(move || init_nvim_async(state_arc, options, nvim_config, cols, rows)); + thread::spawn(move || init_nvim_async(state_arc, options, cols, rows)); } } diff --git a/src/ui.rs b/src/ui.rs index 48b87c8..5bd89c5 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -10,7 +10,6 @@ use gtk::{ApplicationWindow, HeaderBar, ToolButton, Image, AboutDialog}; use gio::prelude::*; use gio::{Menu, MenuExt, MenuItem, MenuItemExt, SimpleAction}; -use nvim_config::NvimConfig; use settings::Settings; use shell::{Shell, ShellOptions}; use shell_dlg; @@ -54,15 +53,11 @@ impl Components { impl Ui { pub fn new(options: ShellOptions) -> Ui { let plug_manager = plug_manager::Manager::new(); - let plug_config = plug_manager.load_config(); - let nvim_config = NvimConfig::new(plug_config); let plug_manager = Arc::new(UiMutex::new(plug_manager)); let comps = Arc::new(UiMutex::new(Components::new())); let settings = Rc::new(RefCell::new(Settings::new())); - let shell = Rc::new(RefCell::new( - Shell::new(settings.clone(), options, nvim_config), - )); + let shell = Rc::new(RefCell::new(Shell::new(settings.clone(), options))); settings.borrow_mut().set_shell(Rc::downgrade(&shell)); let projects = Projects::new(&comps.borrow().open_btn, shell.clone()); From bb984c8223583184b0c5eb1b775c6f03ae7f7454 Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 5 Nov 2017 13:06:12 +0300 Subject: [PATCH 25/30] Test fix --- src/plug_manager/plugin_settings_dlg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plug_manager/plugin_settings_dlg.rs b/src/plug_manager/plugin_settings_dlg.rs index 6f27b1d..ec8b59f 100644 --- a/src/plug_manager/plugin_settings_dlg.rs +++ b/src/plug_manager/plugin_settings_dlg.rs @@ -94,7 +94,7 @@ mod tests { #[test] fn test_extract_name() { assert_eq!( - Some("plugin_name"), + Some("plugin_name".to_owned()), Builder::extract_name("http://github.com/somebody/plugin_name.git") ); } From 50bea23b6ba0191dc3155b2a98616628da526631 Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 5 Nov 2017 20:52:29 +0300 Subject: [PATCH 26/30] Number of ui improvements --- src/plug_manager/manager.rs | 2 +- src/plug_manager/plugin_settings_dlg.rs | 37 +++++++++++++++++-------- src/plug_manager/ui.rs | 12 ++++---- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index 1ac6382..352fda8 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -107,7 +107,7 @@ impl PlugManagerConfigSource { for plug in store.get_plugs() { if !plug.removed { - builder += &format!("Plug '{}'\n", plug.get_plug_path()); + builder += &format!("Plug '{}', {{ 'as': '{}' }}\n", plug.get_plug_path(), plug.name); } } diff --git a/src/plug_manager/plugin_settings_dlg.rs b/src/plug_manager/plugin_settings_dlg.rs index ec8b59f..d618567 100644 --- a/src/plug_manager/plugin_settings_dlg.rs +++ b/src/plug_manager/plugin_settings_dlg.rs @@ -24,12 +24,17 @@ impl<'a> Builder<'a> { ); let content = dlg.get_content_area(); + let border = gtk::Box::new(gtk::Orientation::Horizontal, 0); + border.set_border_width(12); + let list = gtk::ListBox::new(); list.set_selection_mode(gtk::SelectionMode::None); - let path = gtk::Box::new(gtk::Orientation::Horizontal, 0); + let path = gtk::Box::new(gtk::Orientation::Horizontal, 5); + path.set_border_width(5); let path_lbl = gtk::Label::new("Repo"); let path_e = gtk::Entry::new(); + path_e.set_placeholder_text("user_name/repo_name"); path.pack_start(&path_lbl, true, true, 0); path.pack_end(&path_e, false, true, 0); @@ -37,7 +42,8 @@ impl<'a> Builder<'a> { list.add(&path); - let name = gtk::Box::new(gtk::Orientation::Horizontal, 0); + let name = gtk::Box::new(gtk::Orientation::Horizontal, 5); + name.set_border_width(5); let name_lbl = gtk::Label::new("Name"); let name_e = gtk::Entry::new(); @@ -46,9 +52,16 @@ impl<'a> Builder<'a> { list.add(&name); - content.add(&list); + border.pack_start(&list, true, true, 0); + content.add(&border); content.show_all(); + path_e.connect_changed(clone!(name_e => move |p| { + if let Some(name) = p.get_text().and_then(|t| extract_name(&t)) { + name_e.set_text(&name); + } + })); + let ok: i32 = gtk::ResponseType::Ok.into(); let res = if dlg.run() == ok { path_e.get_text().map(|path| { @@ -59,7 +72,7 @@ impl<'a> Builder<'a> { } else { Some(name) }) - .or_else(|| Builder::extract_name(&path)) + .or_else(|| extract_name(&path)) .unwrap_or_else(|| path.clone()); store::PlugInfo::new(name.to_owned(), path.to_owned()) @@ -72,18 +85,18 @@ impl<'a> Builder<'a> { res } +} - fn extract_name(path: &str) -> Option { - if let Some(idx) = path.rfind(|c| c == '/' || c == '\\') { - if idx < path.len() - 1 { - let path = path.trim_right_matches(".git"); - Some(path[idx + 1..].to_owned()) - } else { - None - } +fn extract_name(path: &str) -> Option { + if let Some(idx) = path.rfind(|c| c == '/' || c == '\\') { + if idx < path.len() - 1 { + let path = path.trim_right_matches(".git"); + Some(path[idx + 1..].to_owned()) } else { None } + } else { + None } } diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index 5f13c82..ce35bd1 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -43,6 +43,7 @@ impl<'a> Ui<'a> { let header_bar = gtk::HeaderBar::new(); let add_plug_btn = gtk::Button::new_with_label("Add.."); + add_plug_btn.get_style_context().map(|c| c.add_class("suggested-action")); header_bar.pack_end(&add_plug_btn); @@ -81,14 +82,14 @@ impl<'a> Ui<'a> { &pages, &format!( "NeovimGtk plugin manager is a GUI for vim-plug.\n\ - It can load plugins from vim-plug configuration if vim-plug sarted and self settings is empty.\n\ + It can load plugins from vim-plug configuration if vim-plug sarted and NeovimGtk manager settings is empty.\n\ When enabled it generate and load vim-plug as simple vim file at startup before init.vim is processed.\n\ - So after enabling this manager you must disable vim-plug configuration in init.vim.\n\ + So after enabling this manager you must disable vim-plug configuration in init.vim.\n\ This manager currently only manage vim-plug configuration and do not any actions on plugin management.\n\ So you must call all vim-plug (PlugInstall, PlugUpdate, PlugClean) commands manually.\n\ Current configuration source is {}", match self.manager.borrow().plug_manage_state { - manager::PlugManageState::NvimGtk => "config file", + manager::PlugManageState::NvimGtk => "NeovimGtk config file", manager::PlugManageState::VimPlug => "loaded from vim-plug", manager::PlugManageState::Unknown => "Unknown", } @@ -155,8 +156,8 @@ fn create_up_down_btns( manager: &Arc>, ) -> gtk::Box { let buttons_panel = gtk::Box::new(gtk::Orientation::Horizontal, 5); - let up_btn = gtk::Button::new_from_icon_name("go-up", gtk_sys::GTK_ICON_SIZE_BUTTON as i32); - let down_btn = gtk::Button::new_from_icon_name("go-down", gtk_sys::GTK_ICON_SIZE_BUTTON as i32); + let up_btn = gtk::Button::new_from_icon_name("go-up-symbolic", gtk_sys::GTK_ICON_SIZE_BUTTON as i32); + let down_btn = gtk::Button::new_from_icon_name("go-down-symbolic", gtk_sys::GTK_ICON_SIZE_BUTTON as i32); up_btn.connect_clicked(clone!(plugs_panel, manager => move |_| { if let Some(row) = plugs_panel.get_selected_row() { @@ -188,6 +189,7 @@ fn create_up_down_btns( buttons_panel.pack_start(&up_btn, false, true, 0); buttons_panel.pack_start(&down_btn, false, true, 0); + buttons_panel.set_halign(gtk::Align::Center); buttons_panel } From eb70ce8d71d4590a005f26a0ff1521f22006ceef Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 5 Nov 2017 21:07:02 +0300 Subject: [PATCH 27/30] Move plugs to menu --- src/ui.rs | 74 +++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index 5bd89c5..28f3f6c 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -16,6 +16,23 @@ use shell_dlg; use project::Projects; use plug_manager; +macro_rules! clone { + (@param _) => ( _ ); + (@param $x:ident) => ( $x ); + ($($n:ident),+ => move || $body:expr) => ( + { + $( let $n = $n.clone(); )+ + move || $body + } + ); + ($($n:ident),+ => move |$($p:tt),+| $body:expr) => ( + { + $( let $n = $n.clone(); )+ + move |$(clone!(@param $p),)+| $body + } + ); +} + pub struct Ui { initialized: bool, comps: Arc>, @@ -125,25 +142,6 @@ impl Ui { paste_btn.connect_clicked(move |_| shell.borrow_mut().edit_paste()); header_bar.pack_start(&paste_btn); - let plug_image = Image::new_from_icon_name( - "system-software-install", - gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32, - ); - let plug_btn = ToolButton::new(Some(&plug_image), "Plug"); - - let comps_ref = self.comps.clone(); - let plug_manager_ref = self.plug_manager.clone(); - plug_btn.connect_clicked(move |_| { - plug_manager::Ui::new(&plug_manager_ref).show( - comps_ref - .borrow() - .window - .as_ref() - .unwrap(), - ) - }); - header_bar.pack_start(&plug_btn); - header_bar.set_show_close_button(true); window.set_titlebar(Some(&header_bar)); @@ -182,19 +180,38 @@ impl Ui { } fn create_main_menu(&self, app: >k::Application) { + let comps = self.comps.clone(); + let plug_manager = self.plug_manager.clone(); + let menu = Menu::new(); + let plugs = MenuItem::new("Plugins", None); + plugs.set_detailed_action("app.Plugins"); + menu.append_item(&plugs); + let about = MenuItem::new("About", None); about.set_detailed_action("app.HelpAbout"); menu.append_item(&about); app.set_app_menu(Some(&menu)); + let plugs_action = SimpleAction::new("Plugins", None); + plugs_action.connect_activate( + clone!(comps => move |_, _| plug_manager::Ui::new(&plug_manager).show( + comps + .borrow() + .window + .as_ref() + .unwrap(), + )), + ); + let about_action = SimpleAction::new("HelpAbout", None); - let comps = self.comps.clone(); about_action.connect_activate(move |_, _| on_help_about(&*comps.borrow())); about_action.set_enabled(true); + app.add_action(&about_action); + app.add_action(&plugs_action); } } @@ -260,20 +277,3 @@ impl UiMutex { } } } - -macro_rules! clone { - (@param _) => ( _ ); - (@param $x:ident) => ( $x ); - ($($n:ident),+ => move || $body:expr) => ( - { - $( let $n = $n.clone(); )+ - move || $body - } - ); - ($($n:ident),+ => move |$($p:tt),+| $body:expr) => ( - { - $( let $n = $n.clone(); )+ - move |$(clone!(@param $p),)+| $body - } - ); -} From 9c997a5165e959eb3f8104b9849a57c2e7dabc5a Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 5 Nov 2017 21:13:31 +0300 Subject: [PATCH 28/30] Fix test --- src/plug_manager/plugin_settings_dlg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plug_manager/plugin_settings_dlg.rs b/src/plug_manager/plugin_settings_dlg.rs index d618567..3860f71 100644 --- a/src/plug_manager/plugin_settings_dlg.rs +++ b/src/plug_manager/plugin_settings_dlg.rs @@ -108,7 +108,7 @@ mod tests { fn test_extract_name() { assert_eq!( Some("plugin_name".to_owned()), - Builder::extract_name("http://github.com/somebody/plugin_name.git") + extract_name("http://github.com/somebody/plugin_name.git") ); } } From bff3bdb12073e4e97c861ff0383345bd4c0a3f5d Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 5 Nov 2017 22:31:38 +0300 Subject: [PATCH 29/30] Remove .vim file when disabled --- src/nvim_config.rs | 3 ++- src/plug_manager/manager.rs | 2 +- src/plug_manager/ui.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/nvim_config.rs b/src/nvim_config.rs index 592eb3d..b4a1891 100644 --- a/src/nvim_config.rs +++ b/src/nvim_config.rs @@ -1,5 +1,5 @@ use std::path::PathBuf; -use std::fs::OpenOptions; +use std::fs::{remove_file, OpenOptions}; use std::io::Write; use dirs; @@ -27,6 +27,7 @@ impl NvimConfig { Ok(file) => Some(file), } } else { + NvimConfig::config_path().map(remove_file); None } } diff --git a/src/plug_manager/manager.rs b/src/plug_manager/manager.rs index 352fda8..ae499a8 100644 --- a/src/plug_manager/manager.rs +++ b/src/plug_manager/manager.rs @@ -27,7 +27,7 @@ impl Manager { } } - pub fn load_config(&self) -> Option { + pub fn generate_config(&self) -> Option { if self.store.is_enabled() { Some(PlugManagerConfigSource::new(&self.store)) } else { diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index ce35bd1..16402af 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -116,7 +116,7 @@ impl<'a> Ui<'a> { let mut manager = self.manager.borrow_mut(); manager.clear_removed(); manager.save(); - if let Some(config_path) = NvimConfig::new(manager.load_config()).generate_config() { + if let Some(config_path) = NvimConfig::new(manager.generate_config()).generate_config() { if let Some(path) = config_path.to_str() { manager.vim_plug.reload(path); } From e423dff0914aa009562bf7128682a7e1504f6a66 Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 5 Nov 2017 23:30:40 +0300 Subject: [PATCH 30/30] Use search entry --- src/plug_manager/ui.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index 16402af..80d21f9 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -341,8 +341,7 @@ fn add_vimawesome_tab( link_button.set_markup( "Plugins are taken from: https://vimawesome.com", ); - let search_entry = gtk::Entry::new(); - search_entry.set_icon_from_icon_name(gtk::EntryIconPosition::Primary, "edit-find"); + let search_entry = gtk::SearchEntry::new(); get_plugins.pack_start(&link_button, false, true, 10); get_plugins.pack_start(&search_entry, false, true, 5);