GitHub - neoclide/coc-git: Git integration of coc.nvim (original) (raw)

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:

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

Patreon donate button PayPal donate button

License

MIT