Home

Awesome

coc-git

Git integration of coc.nvim.

Note: many useful features not implemented, it's recommended to use plugin like vim-fugitive at the same time.

Install

In your vim/neovim, run command:

:CocInstall coc-git

Why

Features

Note for GitHub issues completion support:

Note for GitLab issues completion support:

Configuration

more information, see package.json

Note for user from vim-gitgutter, if your have highlight groups defined for vim-gitgutter, you can use:

"git.addedSign.hlGroup": "GitGutterAdd",
"git.changedSign.hlGroup": "GitGutterChange",
"git.removedSign.hlGroup": "GitGutterDelete",
"git.topRemovedSign.hlGroup": "GitGutterDelete",
"git.changeRemovedSign.hlGroup": "GitGutterChangeDelete",

When you have git.addGBlameToVirtualText enabled, use command let g:coc_git_hide_blame_virtual_text = !get(g:, 'coc_git_hide_blame_virtual_text', 0) to dynamic toggle virtual text.

Usage

Statusline integration

Example for lightline user:

" lightline
let g:lightline = {
  \ 'active': {
  \   'left': [
  \     [ 'mode', 'paste' ],
  \     [ 'ctrlpmark', 'git', 'diagnostic', 'cocstatus', 'filename', 'method' ]
  \   ],
  \   'right':[
  \     [ 'filetype', 'fileencoding', 'lineinfo', 'percent' ],
  \     [ 'blame' ]
  \   ],
  \ },
  \ 'component_function': {
  \   'blame': 'LightlineGitBlame',
  \ }
\ }

function! LightlineGitBlame() abort
  let blame = get(b:, 'coc_git_blame', '')
  " return blame
  return winwidth(0) > 120 ? blame : ''
endfunction

If you're not using statusline plugin, you can add them to statusline by:

set statusline^=%{get(g:,'coc_git_status','')}%{get(b:,'coc_git_status','')}%{get(b:,'coc_git_blame','')}

User autocmd

autocmd User CocGitStatusChange {command}

Triggered after the g:coc_git_status b:coc_git_status b:coc_git_blame has changed.

Could be used for update the statusline.

Keymaps

Create keymappings like:

" navigate chunks of current buffer
nmap [g <Plug>(coc-git-prevchunk)
nmap ]g <Plug>(coc-git-nextchunk)
" navigate conflicts of current buffer
nmap [c <Plug>(coc-git-prevconflict)
nmap ]c <Plug>(coc-git-nextconflict)
" show chunk diff at current position
nmap gs <Plug>(coc-git-chunkinfo)
" show commit contains current position
nmap gc <Plug>(coc-git-commit)
" create text object for git chunks
omap ig <Plug>(coc-git-chunk-inner)
xmap ig <Plug>(coc-git-chunk-inner)
omap ag <Plug>(coc-git-chunk-outer)
xmap ag <Plug>(coc-git-chunk-outer)

Commands

Use command :CocCommand to open commands and type git. to get all git related commands.

Work with git lists

To open a specified coc list, you have different ways:

To toggle list mode, use <C-o> and i.

To move up&down on insertmode, use <C-j> and <C-k>

To run a action, press <tab> and select the action.

For more advance usage, checkout :h coc-list.

Issue autocomplete from multiple GitHub repositories

To enable autocompletion of issues from multiple GitHub repositories, put a comma-separated list of issue repository specifiers in the git config variable coc-git.issuesources. An issue repository specifier looks like this: github/neoclide/coc-git.

Multiple repositories can be specified using comma separation, like this: github/neoclide/coc-git,github/neoclide/coc.nvim

F.A.Q

Q: Virtual text not working.

A: Make sure your neovim/vim support virtual text by command :echo has('nvim-0.5.0') || has('patch-9.0.0067').

Supporting

If you like my extension, consider supporting me on Patreon or PayPal:

<a href="https://www.patreon.com/chemzqm"><img src="https://c5.patreon.com/external/logo/become_a_patron_button.png" alt="Patreon donate button" /> </a> <a href="https://www.paypal.com/paypalme/chezqm"><img src="https://werwolv.net/assets/paypal_banner.png" alt="PayPal donate button" /> </a>

License

MIT