mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-11 04:53:46 -05:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user