zhaocai / GoldenView.Vim

Always have a nice view for vim split windows!
http://zhaocai.github.io/GoldenView.Vim/
219 stars 14 forks source link

GoldenView breaks vimdiff 4-pane layout #33

Open easoncxz opened 4 years ago

easoncxz commented 4 years ago

I enjoy using vim as my Git merge-tool, and have done so for a while. When I run git mergetool, I'm used to a vimdiff layout like this: (diagram copied from a vim StackExchange post)

-------------------------
| LOCAL | BASE | REMOTE |
-------------------------
|        MERGED         |
-------------------------

However from some unknown point in time onwards (in hindsight, it was perhaps after I started using GoldenView), this four-pane layout got messed up. I instead have got a layout like this:

-------------------------
| LOCAL | BASE | REMOTE |
-------------------------

After poking around my vim setup on and off for a long time, today it finally crossed my mind to try launching vimdiff via vim -u NONE to debug things, and lo and behold, I see all four panes like I expected from the old days. I then made a guess among my plugins that perhaps GoldenView, the only plugin that does something about my splits, may have some strange interactions.

I tried disabling GoldenView for diffmode by using this unusual line in my plugin definition: (I use vim-plug)

call plug#begin('~/.vim/plugged')

" ... other plugins

" Activate GoldenView unless vim is launched in diffmode
if (&diff == 0)
    Plug 'zhaocai/GoldenView.Vim'
endif

" ... other plugins

call plug#end()

I dug around to find what kind of command-line Git uses to launch vim as a difftool/mergetool, and found this via StackOverflow:

vim -d $MERGED $LOCAL $BASE $REMOTE -c wincmd J

So I created four files for testing:

echo one > one
echo two > two
echo three > three
echo four > four

And then launched vim using this command:

vim -c 'wincmd J' -d one two three four

And voila, I see four panes as I wanted:

image

To check that indeed GoldenView is interfering with vim diffmode somehow, I tried doing the same thing but with GoldenView activated. I changed my ~/.vimrc back to its previous state (i.e. the state in which I could not get vimdiff to show four panes):

call plug#begin('~/.vim/plugged')

" ... other plugins

" Activate GoldenView unless vim is launched in diffmode
"if (&diff == 0)
    " Debugging: Always load GoldenView, regardless of whether vim is in diffmode
    Plug 'zhaocai/GoldenView.Vim'
"endif

" ... other plugins

call plug#end()

And behold, the layout is messed up again --- only the first three of the four panes are showing:

image

I didn't put in the time to make a minimal ~/.vimrc, but I think this is evidence enough that GoldenView somehow has some interactions with how vim functions as a Git mergetool. I also haven't read the GoldenView code yet, but regardless of whether anything is done in GoldenView to address this issue, hopefully my post here would be helpful to someone.