airblade / vim-gitgutter

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.
MIT License
8.35k stars 296 forks source link

Question: Run a oneshot diff synchronously? #716

Closed somini closed 4 years ago

somini commented 4 years ago

I sometimes work on computers with a very slow disk, so I disable the automatic git diff. Still, I would like to be able to run GitGutter on a keybinding, in a "oneshot" mode. Meaning it should run whatever git commands, show the gutter and don't run git anymore.

I'm using this workaround:

" One-shot "diff"
function! s:DiffOneShot_GitGutter()
    call gitgutter#buffer_enable()
    GitGutter
    sleep 500 m
    call gitgutter#utility#setbufvar(bufnr(), 'enabled', 0)
endfunction

So I'm requesting 2 things:

Note this is a rare thing, if this is too much work it's fine to close this.

airblade commented 4 years ago

To run GitGutter synchronously: let g:gitgutter_async = 0. I'm not sure why you want to run synchronously, especially if the system is slow?

I think you've already got the best way to turn off GitGutter without removing the signs. I think it's a rare need so I wouldn't build in that feature.

airblade commented 4 years ago

Perhaps a better option is to remove all the autocmds which trigger GitGutter:

autocmd! gitgutter

Then just call GitGutter whenever you want.

somini commented 4 years ago

Perhaps a better option is to remove all the autocmds which trigger GitGutter:

autocmd! gitgutter

Then just call GitGutter whenever you want.

This is the best option, thanks.