Files
topgrade/src/vim.rs

34 lines
854 B
Rust
Raw Normal View History

2018-06-07 08:51:16 +03:00
use std::fs;
use std::path::PathBuf;
#[derive(Debug, Clone, Copy)]
pub enum PluginFramework {
Plug,
Vundle,
NeoBundle,
}
impl PluginFramework {
pub fn detect(vimrc: &PathBuf) -> Option<PluginFramework> {
let content = fs::read_to_string(vimrc).ok()?;
if content.contains("NeoBundle") {
Some(PluginFramework::NeoBundle)
} else if content.contains("Vundle") {
Some(PluginFramework::Vundle)
} else if content.contains("plug#begin") {
Some(PluginFramework::Plug)
} else {
None
}
}
pub fn upgrade_command(self) -> &'static str {
match self {
PluginFramework::NeoBundle => "NeoBundleUpdate",
PluginFramework::Vundle => "PluginUpdate",
PluginFramework::Plug => "PlugUpdate",
}
}
}