//! Directory and file paths used by iris. use std::path::PathBuf; /// Root of the data directory fn base_config_dir() -> PathBuf { dirs::config_local_dir().expect("could not locate config directory") } /// Root of the config directory fn base_data_dir() -> PathBuf { dirs::data_local_dir().expect("could not locate data directory") } /// Path to the current diectort pub fn current_dir() -> PathBuf { std::env::current_dir().expect("could not locate current directory") } /// Path to iris's config directory. /// /// This is the directory where iris will look and save it's config files. pub fn config_dir() -> PathBuf { base_config_dir().join("iris") } /// Default path to iris's plugin file pub fn default_plugin_file() -> PathBuf { config_dir().join("iris.toml") } /// Path to iris's plugin file pub fn plugin_file() -> PathBuf { [current_dir(), config_dir()] .into_iter() .map(|dir| dir.join("iris.toml")) .find(|path| path.exists()) .unwrap_or_else(default_plugin_file) } /// Path to iris's lock file pub fn lock_file() -> PathBuf { plugin_file().with_file_name("iris.lock") } /// Path to iris's data directory. pub fn data_dir() -> PathBuf { base_data_dir().join("iris") } /// Path to iris's plugin directory. /// /// This is where each checkout for each plugin repository will be saved. pub fn plugin_dir() -> PathBuf { data_dir().join("plugins") } /// Path to iris's transaction lock file. /// /// The transaction lock ensures that only one process is operating on iris's /// data directory at a time. pub fn transaction_lock_file() -> PathBuf { data_dir().join("lock") } /// Destination path for iris's vim autoload file. pub fn autoload_file() -> PathBuf { base_data_dir().join("nvim/site/autoload/iris.vim") }