Clean up exposure of the grep command

This change breaks up the determining of the user's grep command, and
the arguments it sends it.

Configuration is now:

    let g:gitgutter_grep_command = 'grep --color=never -e'

This makes it easier for users to configure now, though not quite as
flexible.
This commit is contained in:
Dan Church
2016-01-11 11:14:32 -06:00
committed by Andy Stewart
parent 95734c6f6b
commit 8d229c222c
3 changed files with 6 additions and 6 deletions

View File

@@ -273,10 +273,10 @@ let g:gitgutter_escape_grep = 1
#### Use a custom `grep` command
If you use an alternative to grep, you can tell vim-gitgutter to use it here.
If you use an alternative to grep, you can tell vim-gitgutter to use it here. It only needs to support extended POSIX regex.
```viml
let g:gitgutter_grep_command = ' | grep --color=never -e "^@@"'
let g:gitgutter_grep_command = 'grep --color=never -e'
```
#### To turn off vim-gitgutter by default

View File

@@ -4,12 +4,12 @@ if exists('g:gitgutter_grep_command')
else
let s:grep_available = executable('grep')
if s:grep_available
let s:grep_command = ' | '.(g:gitgutter_escape_grep ? '\grep' : 'grep')
let s:grep_command = (g:gitgutter_escape_grep ? '\grep' : 'grep')
let s:grep_help = gitgutter#utility#system('grep --help')
if s:grep_help =~# '--color'
let s:grep_command .= ' --color=never'
endif
let s:grep_command .= ' -e '.gitgutter#utility#shellescape('^@@ ')
let s:grep_command .= ' -e'
endif
endif
let s:hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'
@@ -101,7 +101,7 @@ function! gitgutter#diff#run_diff(realtime, use_external_grep)
endif
if a:use_external_grep && s:grep_available
let cmd .= s:grep_command
let cmd .= ' | '.s:grep_command.' '.gitgutter#utility#shellescape('^@@ ')
endif
if (a:use_external_grep && s:grep_available) || a:realtime

View File

@@ -217,7 +217,7 @@ TO ESCAPE GREP
To use a custom invocation for grep, use this:
>
let g:gitgutter_grep_command = ' | grep --color=never -e "^@@ "'
let g:gitgutter_grep_command = 'grep --color=never -e'
<
To avoid any alias you have for grep, use this: