34 lines
854 B
Rust
34 lines
854 B
Rust
|
|
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",
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|