rhysd / git-messenger.vim

Vim and Neovim plugin to reveal the commit messages under the cursor
MIT License
1.34k stars 32 forks source link

expose command to customise git diff #89

Open gennaro-tedesco opened 2 years ago

gennaro-tedesco commented 2 years ago

Perhaps a long shot, but worth asking! I see that there is an option g:git_messenger_git_command to specify the git executable: could there be a similar one to specify custom git options/scripts to pipe/execute when showing the git diff?

To clarify the rationale, the problem I am trying to solve is the following: when showing the file diff in the popup window (say pressing d/r) the text shown is presumably the output of git diff; in the case of a neovim popup I would not need all the git metadata that are part of a diff, for instance I would like to cut off the context lines or the chunk markers or any other similar thing: imagine something along the lines of

git diff -U0 <file> | tail +6

Now you could argue that one could simply specify the above options as general git configuration (which I assume the plugin uses), however I would only need such "special" config when in the popup window in neovim and keep the normal behaviour outside, for general git diff. Thus I thought one could expose a command along the lines of

let g:git_diff_command = 'git diff {} | tail +6'

with {} indicating the current buffer or such (to replicate my example above).

I understand this is probably complicated and likely nobody needs it, but again, worth asking! Thank you for the awesome plugin!