Closed DehanLUO closed 2 years ago
Thanks for the detailed report. However I can't reproduce the problem.
When I type this:
:nmap <Leader>gqf :w<CR>:GitGutterQuickFix\|copen<CR>
– and then in normal mode type \gqf
(my leader key is \
), it works: it saves the buffer, loads the diff locations into the quickfix list, and opens it.
Does the GitGutterQuickFix
command work when you execute it directly? I.e. when you do this:
:w
:GitGutterQuickFix
:copen
By the way you don't need let g:gitgutter_signs=1
because that's the default anyway.
Thanks, Nothing was output after executing GitGutterQuickFix directly.
Thanks so much. I've found the key. After I set vim log to verbose, I found the GitGutterQuickFix did the following command in a child process.
(git --no-pager diff --no-ext-diff --no-color -U0 --src-prefix=a/ --dst-prefix=b/ )>/var/folders/_d/bsqrml45219_br128q2pgsg40000gn/T/v03Ac2B/6 2>&1
This works for the gVim(MacVim) launched from command line interface.
However, I installed my MacVim via homebrew.
brew install macvim --cask
If I launched MacVim from the launchpad icon. This causes problem.
Well spotted.
GitGutterQuickFix
uses systemlist()
to run the diff so I think this must be a bug in MacVim
Here is the problem when I run GitGutterQuickFix with gVim launched from launchpad
And this is what I got when I launched gVim from CLI
The key is that if I run :echo systemlist('pwd')
when I open my vimrc in both gvim, I got different Print Working Directory.
With CLI : ['/Users/dehan/.vim']
With Launchpad: ['/Users/dehan']
Seems that adding an absolute path to the git command can sovle the problem?
The first thing GitGutterQuickFix
does is establish the path to the repo – that's the git rev-parse --show-cdup
. It assumes your current working directory is somewhere within your repo. Your first screenshot suggests that your current working directory is not in your repo. What does :pwd
produce in gVim launched from launchpad?
The second screenshot shows an error unrelated to the plugin. Your vim is having trouble setting up the quickfix window because it can't find an indent file.
Seems that adding an absolute path to the git command can sovle the problem?
Then the quickfix window will be much harder to read, with long absolute paths in the filenames.
What does :pwd
inside Vim give?
Seems it is fixed to where I launched my gVim.
Even if I launched gvim in CLI at $HOME and executed :e $MYVIMRC
, :pwd
and echo systemlist('pwd')
still gave the path where I launched from. /Users/dehan
I use vim-rooter to make sure my working directory is always the repo I'm working in.
I use vim-rooter to make sure my working directory is always the repo I'm working in.
Thank you again for all your information and assistance. I should have a try. Have a Great Day.
You too!
Nothing was added to my QuickFix list after I did some change and executed
:w<CR>:GitGutterQuickFix\|copen<CR>
.logs channel.log gitgutter.log
screenshot
" Plugins settings " Automatic installation of missing plugins " @https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation " Download vim-plug if plug.vim not found if has('unix') " For unix system " Install vim-plug if not found if empty(glob('~/.vim/autoload/plug.vim')) sil !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim en elsei has('win32') "For windows system if empty(glob('$HOME/vimfiles/autoload/plug.vim')) sil !curl -fLo \%HOMEPATH\%/vimfiles/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim en en
" Run PlugInstall if there are missing plugins au VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) | PlugInstall --sync | so $MYVIMRC | en
" Plugins package manager if has('unix') cal plug#begin('~/.vim/plugged') elsei has('win32') cal plug#begin('$HOME/vimfiles/plugged') en
cal plug#end()
" PlugCfg 'airblade/vim-gitgutter' :help gitgutter.txt let g:gitgutter_log=1 let g:gitgutter_map_keys=0 " Clear all gitgutter mappings
set scl=yes " Always draw the signcolumn let g:gitgutter_signs=1 " Show signs " Customise the symbols let g:gitgutter_sign_added='' let g:gitgutter_sign_modified='שׂ' let g:gitgutter_sign_modified_removed='' let g:gitgutter_sign_removed='' let g:gitgutter_sign_removed_above_and_below='' let g:gitgutter_sign_removed_first_line='' " Sync LineNr background color hi! link SignColumn LineNr hi! link GitGutterAdd LineNr hi! link GitGutterChange LineNr hi! link GitGutterDelete LineNr hi! link GitGUtterChangeDelete LineNr " Give the foreground color to GitGutter_Sign hi GitGutterAdd guifg=#009900 ctermfg=Green hi GitGutterChange guifg=#bbbb00 ctermfg=Yellow hi GitGutterDelete guifg=#ff2222 ctermfg=Red hi GitGUtterChangeDelete guifg=#ff2222 ctermfg=Red
if has('gui_running') let g:gitgutter_highlight_lines=1 " Enable line highlighting
en
" Get a list of counts of added, modified, and removed lines let g:airline#extensions#hunks#enabled=1 " Showing a summary of changed hunks let g:airline#extensions#hunks#non_zero_only=0 " Showing all hunks let g:airline#extensions#hunks#hunk_symbols=['','שׂ',''] " Set count symbols
" Augment folded text with an indicator of weather lines have been changed set fdt=gitgutter#fold#foldtext()
"Stage/undo/preview the hunk nmhs :GitGutterStageHunk
nm hu :GitGutterUndoHunk
nm hp :GitGutterPreviewHunk
" Fold/execute unchanged lines nm gf :GitGutterFold
let g:gitgutter_use_location_list=0 " Hunks not to the location list " Load all SAVED hunks into window's/quickfix list com! Gqf GitGutterQuickFix |cope nm gqf :Gqf
nmapgqf :w:GitGutterQuickFix|copen
" Next/Previous hunk cycle through hunks in current buffer nm gj :call GitGutterNextHunkCycle()
nm gk :call GitGutterPrevHunkCycle()
fu! GitGutterNextHunkCycle()
let line = line('.')
sil! GitGutterNextHunk
if line('.') == line
1
GitGutterNextHunk
en
endf
fu! GitGutterPrevHunkCycle()
let line = line('.')
sil! GitGutterPrevHunk
if line('.') == line
norm! G
GitGutterPrevHunk
en
endf