diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-11-14 14:15:51 -0500 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-11-18 12:23:28 -0500 |
commit | c2767a50a556a2929b64d2f7b08d458d83aebae9 (patch) | |
tree | 0df3c903da9f8bb777d4b69074374c478457aa73 /src/cli.rs | |
parent | 914a5a83fa244b7515df44d0a326f4e5b05d8342 (diff) |
Handle grep output769-git-grep-rebase
- Handle standard filepath:code and filepath:line_number:code output
as produced by `git grep`, `rg -H`, `grep -H`, etc (with -n for line
numbers).
- Retain the match highlighting as produced by the grep tool, and
expose it in delta's color output styled with grep-match-style.
(Note that --color=always is needed to retain the color if piping
into delta, but not for `git grep` when delta is configured as git's
pager)
- Special handling of -p, and -W options of `git grep`: these display
the function context in which the matches occur.
- `navigate` keybindings jump between match function contexts under
`git grep -p` and between matching lines under `git grep -W`.
Thanks @zachriggle for the proposal.
Fixes #769
Diffstat (limited to 'src/cli.rs')
-rw-r--r-- | src/cli.rs | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -441,6 +441,40 @@ pub struct Opt { )] pub blame_timestamp_format: String, + #[structopt(long = "grep-match-line-style")] + /// Style (foreground, background, attributes) for matching lines of code in + /// grep output. See STYLES section. Defaults to plus-style. + pub grep_match_line_style: Option<String>, + + #[structopt(long = "grep-match-word-style")] + /// Style (foreground, background, attributes) for the specific matching + /// substrings within a matching line of code in grep output. See STYLES + /// section. Defaults to plus-style. + pub grep_match_word_style: Option<String>, + + #[structopt(long = "grep-context-line-style")] + /// Style (foreground, background, attributes) for non-matching lines of + /// code in grep output. See STYLES section. Defaults to zero-style. + pub grep_context_line_style: Option<String>, + + #[structopt(long = "grep-file-style")] + /// Style (foreground, background, attributes) for file paths in grep + /// output. See STYLES section. Defaults to hunk-header-file-path-style. + pub grep_file_style: Option<String>, + + #[structopt(long = "grep-line-number-style")] + /// Style (foreground, background, attributes) for line numbers in grep + /// output. See STYLES section. Defaults to hunk-header-line-number-style. + pub grep_line_number_style: Option<String>, + + #[structopt(long = "grep-separator-symbol", default_value = ":")] + /// Symbol used in grep output to separate file path (and line number) from + /// the line of file contents. Defaults to ":" for both match and context + /// lines, since many terminal emulators recognize constructs like + /// "/path/to/file:7:". However, standard grep output uses "-" for context + /// lines: set this option to "keep" to keep the original separator symbols. + pub grep_separator_symbol: 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) |