Remove .vim file when disabled

This commit is contained in:
daa 2017-11-05 22:31:38 +03:00
parent 9c997a5165
commit bff3bdb120
3 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,5 @@
use std::path::PathBuf; use std::path::PathBuf;
use std::fs::OpenOptions; use std::fs::{remove_file, OpenOptions};
use std::io::Write; use std::io::Write;
use dirs; use dirs;
@ -27,6 +27,7 @@ impl NvimConfig {
Ok(file) => Some(file), Ok(file) => Some(file),
} }
} else { } else {
NvimConfig::config_path().map(remove_file);
None None
} }
} }

View File

@ -27,7 +27,7 @@ impl Manager {
} }
} }
pub fn load_config(&self) -> Option<PlugManagerConfigSource> { pub fn generate_config(&self) -> Option<PlugManagerConfigSource> {
if self.store.is_enabled() { if self.store.is_enabled() {
Some(PlugManagerConfigSource::new(&self.store)) Some(PlugManagerConfigSource::new(&self.store))
} else { } else {

View File

@ -116,7 +116,7 @@ impl<'a> Ui<'a> {
let mut manager = self.manager.borrow_mut(); let mut manager = self.manager.borrow_mut();
manager.clear_removed(); manager.clear_removed();
manager.save(); 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() { if let Some(path) = config_path.to_str() {
manager.vim_plug.reload(path); manager.vim_plug.reload(path);
} }