diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cli.rs | 6 | ||||
-rw-r--r-- | src/config.rs | 2 | ||||
-rw-r--r-- | src/options/set.rs | 3 |
3 files changed, 11 insertions, 0 deletions
@@ -419,6 +419,12 @@ pub struct Opt { /// (underline), 'ol' (overline), or the combination 'ul ol'. pub hunk_header_decoration_style: String, + // Default language used for syntax highlighting when this cannot be + // inferred from a filename. It will typically make sense to set this in + // per-repository git config ().git/config) + #[structopt(long = "default-language")] + pub default_language: Option<String>, + /// The regular expression used to decide what a word is for the within-line highlight /// algorithm. For less fine-grained matching than the default try --word-diff-regex="\S+" /// --max-line-distance=1.0 (this is more similar to `git --word-diff`). diff --git a/src/config.rs b/src/config.rs index 9b1c23ce..d45c2124 100644 --- a/src/config.rs +++ b/src/config.rs @@ -26,6 +26,7 @@ pub struct Config { pub commit_regex: Regex, pub cwd_relative_to_repo_root: Option<String>, pub decorations_width: cli::Width, + pub default_language: Option<String>, pub diff_stat_align_width: usize, pub error_exit_code: i32, pub file_added_label: String, @@ -206,6 +207,7 @@ impl From<cli::Opt> for Config { commit_regex, cwd_relative_to_repo_root: std::env::var("GIT_PREFIX").ok(), decorations_width: opt.computed.decorations_width, + default_language: opt.default_language, diff_stat_align_width: opt.diff_stat_align_width, error_exit_code: 2, // Use 2 for error because diff uses 0 and 1 for non-error. file_added_label, diff --git a/src/options/set.rs b/src/options/set.rs index 53240fce..34d87bdf 100644 --- a/src/options/set.rs +++ b/src/options/set.rs @@ -125,6 +125,7 @@ pub fn set_options( commit_decoration_style, commit_regex, commit_style, + default_language, diff_stat_align_width, file_added_label, file_copied_label, @@ -599,6 +600,7 @@ pub mod tests { commit-decoration-style = black black commit-style = black black dark = false + default-language = rs diff-highlight = true diff-so-fancy = true features = xxxyyyzzz @@ -656,6 +658,7 @@ pub mod tests { assert_eq!(opt.commit_decoration_style, "black black"); assert_eq!(opt.commit_style, "black black"); assert_eq!(opt.dark, false); + assert_eq!(opt.default_language, Some("rs".to_owned())); // TODO: should set_options not be called on any feature flags? // assert_eq!(opt.diff_highlight, true); // assert_eq!(opt.diff_so_fancy, true); |