ok/jj
1
0
Fork 0
forked from mirrors/jj

Add a default merge tool config for meld, vimdiff, kdiff3.

This commit is contained in:
Ilya Grigoriev 2022-10-30 19:41:19 -07:00
parent d6c1b0bc9c
commit e3fd49993e

View file

@ -68,9 +68,32 @@ fn env_base() -> config::Config {
} else if let Ok(value) = env::var("EDITOR") {
builder = builder.set_override("ui.editor", value).unwrap();
}
builder.build().unwrap()
}
fn default_mergetool_config() -> config::Config {
config::Config::builder()
.add_source(config::File::from_str(
r#"
[merge-tools]
meld.merge-args = ["$left", "$base", "$right",
"-o", "$output", "--auto-merge"]
kdiff3.merge-args = ["$base", "$left", "$right",
"-o", "$output", "--auto"]
vimdiff.program = "vim"
vimdiff.merge-args = ["-f", "-d", "$output", "-M",
"$left", "$base", "$right",
"-c", "wincmd J", "-c", "set modifiable",
"-c", "set write"]
vimdiff.merge-tool-edits-conflict-markers=true
"#,
config::FileFormat::Toml,
))
.build()
.unwrap()
}
/// Environment variables that override config values
fn env_overrides() -> config::Config {
let mut builder = config::Config::builder();
@ -99,7 +122,9 @@ fn env_overrides() -> config::Config {
}
pub fn read_config() -> Result<UserSettings, ConfigError> {
let mut config_builder = config::Config::builder().add_source(env_base());
let mut config_builder = config::Config::builder()
.add_source(default_mergetool_config())
.add_source(env_base());
if let Some(config_path) = config_path()? {
let mut files = vec![];