1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
use figment::{providers::Serialized, value, Figment, Metadata, Profile, Provider};
use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct Config {
pub program: String,
pub args: Vec<String>,
}
impl Config {
pub fn from<T: Provider>(provider: T) -> figment::error::Result<Config> {
Figment::from(provider).extract()
}
}
impl Default for Config {
fn default() -> Self {
Self {
program: "fzf-tmux".into(),
args: vec![
"--",
"--multi",
"--print-query",
"-d/",
"--preview-window='right,75%,<80(up,75%,border-bottom)'",
"--preview='sel={}; less ${sel:-{q}} 2>/dev/null'",
]
.into_iter()
.map(Into::into)
.collect(),
}
}
}
impl Provider for Config {
fn metadata(&self) -> Metadata {
Metadata::named("Tmuxr finder config")
}
fn data(&self) -> figment::error::Result<value::Map<Profile, value::Dict>> {
Serialized::defaults(Config::default()).data()
}
}
|