airblade / vim-gitgutter

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bare repo - Issue configuring gitgutter_git_args

arthur-remy opened this issue · comments

What is the latest commit SHA in your installed vim-gitgutter?
f7ea5f40a680797b0ad8d78ec972e32cf17e63c7
What vim/nvim version are you on?
NVIM v0.7.0

I'm trying to setup gitgutter to work with a dotfiles bare repository.
The git-dir is located in $HOME/.dotfiles
The work-tree is the home directory.
I'm working on it with the following command alias dot='git --git-dir=$HOME/.dotfiles --work-tree=$HOME'

I saw that some people having the same issue were able to fix it with g:gitgutter_git_args ( #658 , #754 )
Unfortunately that is not working for me, I've tried different formatting:

  • let g:gitgutter_git_args='--git-dir=$HOME/.dotfiles --work-tree=$HOME'
  • let g:gitgutter_git_args='--git-dir-"$HOME/.dotfiles" --work-tree-"$HOME"'

I've also tried with the full paths of the directories or setting up g:gitgutter_diff_args or g:gitgutter_git_executable without any success.

However git --git-dir=$HOME/.dotfiles --work-tree=$HOME diff [file] is working fine from the terminal.

Do you have any idea how to solve the issue?
Thanks a lot for your help!

A couple of ideas:

  • Try replacing $HOME with the actual path, e.g. let g:gitgutter_git_args='--git-dir=/some/home/path/.dotfiles --work-tree=/some/home/path/'
  • Switch on logging (let g:gitgutter_log=1) and see what is the actual command that gitgutter is running.

Thank for your quick answer. I've tried to use the full path but it does not work either.
I've switched gitgutter_log but I don't find gitgutter.log file anywhere.

The log file should be in gitgutter's own directory, i.e. where it is installed.

What is the value of your $HOME? I wonder whether there's an escaping problem.

My home directory is /home/arthur. It is reflected properly in nvim with the command :echo $HOME.
I installed gitgutter with plug but I don't see any log files in /home/arthur/.vim/plugged/vim-gitgutter/.
PS: I'm using neovim but nvim config is jusr redirecting to the vim one:

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vim/vimrc

I don't see any log files...

Is it possible you made a typo when switching on logging?

Or maybe your custom git args are crashing the plugin straightaway. You could try switching on logging without your git args, and then setting them.

BTW I just noticed I made a typo in #658 (comment). The --git-dir flag should be followed by = not -.

No typo on let g:gitgutter_log = 1 (except the spaces around the equal sign).
I tried removing git args but still no logs.

I'm baffled. All I can suggest is adding echom 'plugin dir' s:plugin_dir somewhere around line 5 of debug.vim and then restarting nvim to see what it says.

Without the log I'm not sure how to debug the original problem. Also, the fact that the log isn't working indicates something weird is going on. Could you have two copies of gitgutter somehow? You could check with :filter /gitgutter/ scriptnames.

Again, thanks a lot for the time you spent helping me. I really appreciate it.

Your suggestion really confused me because I found out that:

  1. Plug install source from https://github.com/vim-scripts/vim-gitgutter instead of this repo, the two version are not on par, especially the debug.vim file
  2. I had unstagged modification in my local version (see git status output at the end)

Unfortunately reinstalling the gitgutter via plugged (no unstaged changes) did not solve the issue.

I've added echom 'plugin dir' s:plugin_dirat the top of the debug.vim (plug version) but I've no output when restarting nvim

:filter /gitgutter/ scriptnames output:

 22: ~/.vim/plugged/vim-gitgutter/plugin/gitgutter.vim
 23: ~/.vim/plugged/vim-gitgutter/autoload/highlight.vim
 49: ~/.vim/plugged/vim-gitgutter/autoload/gitgutter.vim
 50: ~/.vim/plugged/vim-gitgutter/autoload/utility.vim
 51: ~/.vim/plugged/vim-gitgutter/autoload/hunk.vim

git status previous output:

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   ../.gitignore
	modified:   ../README
	modified:   ../README.mkd
	modified:   debug.vim
	modified:   diff.vim
	modified:   gitgutter.vim
	modified:   highlight.vim
	modified:   hunk.vim
	modified:   sign.vim
	modified:   utility.vim
	modified:   ../doc/gitgutter.txt
	modified:   ../plugin/gitgutter.vim
	modified:   ../screenshot.png

This looks like a breakthrough :)

You definitely don't want the version from vim-scripts. I have no idea who added it but it's out of date by 8 years.

I don't use vim-plug myself but I think you want Plug 'airblade/vim-gitgutter' in your config.

There shouldn't be any modifications in your local version.

I suggest you quit nvim, remove the ~/.vim/plugged/vim-gitgutter directory, start nvim, and re-install the plugin. The latest SHA is ded1194.

Great! I've modified Plug 'vim-scripts/vim-gitgutter' to Plug 'airblade/vim-gitgutter' in my config and it's working fine now.
Sorry for that, I must have pasted it from some random dotfiles. Will be careful next time.
Do you have any "Buy me a coffee" or crypto address where I can send you a little thank you present and support your really great work?

I'm glad you fixed it. I really should have spotted it straightaway: the very first thing you wrote was:

What is the latest commit SHA in your installed vim-gitgutter?
f7ea5f40a680797b0ad8d78ec972e32cf17e63c7

– which should have told me the version was hopelessly out of date. Sorry about that!

Thanks for the kind offer, I appreciate it, but there's no need.