mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Allow plugin to bypass any alias for grep.
This is an opt-in configuration.
This commit is contained in:
10
README.mkd
10
README.mkd
@@ -77,6 +77,7 @@ You can customise:
|
||||
* The signs' colours and symbols
|
||||
* Line highlights
|
||||
* Extra arguments for `git diff`
|
||||
* Whether or not to escape `grep` (default to no)
|
||||
* Whether or not vim-gitgutter is on initially (defaults to on)
|
||||
* Whether or not signs are shown (defaults to yes)
|
||||
* Whether or not line highlighting is on initially (defaults to off)
|
||||
@@ -152,6 +153,14 @@ If you want to pass extra arguments to `git diff`, for example to ignore whitesp
|
||||
let g:gitgutter_diff_args = '-w'
|
||||
```
|
||||
|
||||
#### Whether or not to escape `grep`
|
||||
|
||||
If you have `grep` aliased to something which changes its output, for example `grep --color=auto -H`, you will need to tell vim-gitgutter to use raw grep:
|
||||
|
||||
```viml
|
||||
let g:gitgutter_escape_grep = 1
|
||||
```
|
||||
|
||||
#### To turn off vim-gitgutter by default
|
||||
|
||||
Add `let g:gitgutter_enabled = 0` to your `~/.vimrc`.
|
||||
@@ -218,7 +227,6 @@ Here are some things you can check:
|
||||
* Your git config is compatible with the version of git which your Vim is calling (`:echo system('git --version')`).
|
||||
* Your Vim supports signs (`:echo has('signs')` should give `1`).
|
||||
* Your file is being tracked by git and has unstaged changes.
|
||||
* `grep` is on your path and available to Vim (`:echo executable('grep')` should return 1)
|
||||
|
||||
|
||||
### Alternatives
|
||||
|
||||
@@ -95,6 +95,7 @@ You can customise:
|
||||
- The signs' colours and symbols
|
||||
- Line highlights
|
||||
- Extra arguments for git-diff
|
||||
- Whether or not to escape grep (defaults to no)
|
||||
- Whether or not vim-gitgutter is on initially (defaults to on)
|
||||
- Whether or not signs are shown (defaults to yes)
|
||||
- Whether or not line highlighting is on initially (defaults to off)
|
||||
@@ -181,6 +182,13 @@ To pass extra arguments to git-diff, add this to your |vimrc|:
|
||||
let g:gitgutter_diff_args = '-w'
|
||||
<
|
||||
|
||||
TO ESCAPE GREP
|
||||
|
||||
To avoid any alias you have for grep, use this:
|
||||
>
|
||||
let g:gitgutter_escape_grep = 1
|
||||
<
|
||||
|
||||
TO TURN OFF VIM-GITGUTTER BY DEFAULT
|
||||
|
||||
Add to your |vimrc|
|
||||
|
||||
@@ -27,6 +27,7 @@ call s:set('g:gitgutter_sign_modified', '~')
|
||||
call s:set('g:gitgutter_sign_removed', '_')
|
||||
call s:set('g:gitgutter_sign_modified_removed', '~_')
|
||||
call s:set('g:gitgutter_diff_args', '')
|
||||
call s:set('g:gitgutter_escape_grep', 0)
|
||||
|
||||
let s:file = ''
|
||||
|
||||
@@ -48,6 +49,7 @@ function! s:init()
|
||||
let s:dummy_sign_id = 153
|
||||
|
||||
let s:grep_available = executable('grep')
|
||||
let s:grep_command = ' | ' . (g:gitgutter_escape_grep ? '\grep' : 'grep') . ' -e "^@@ "'
|
||||
|
||||
let g:gitgutter_initialised = 1
|
||||
endif
|
||||
@@ -193,7 +195,7 @@ endfunction
|
||||
function! s:run_diff()
|
||||
let cmd = 'git diff --no-ext-diff --no-color -U0 ' . g:gitgutter_diff_args . ' ' . shellescape(s:file())
|
||||
if s:grep_available
|
||||
let cmd .= ' | grep -e "^@@ "'
|
||||
let cmd .= s:grep_command
|
||||
endif
|
||||
let diff = system(s:command_in_directory_of_file(cmd))
|
||||
return diff
|
||||
|
||||
Reference in New Issue
Block a user