coc-git icon indicating copy to clipboard operation
coc-git copied to clipboard

If git 'conflictstyle' is set to 'diff3' then keymaps for git conflicts are not working properly

Open subev opened this issue 4 years ago • 1 comments

I use the following in my .gitconfig more info here

[merge]
  conflictstyle = diff3

This causes the commands:

  nnoremap g1 <Plug>(coc-git-keepcurrent)
  nnoremap g2 <Plug>(coc-git-keepboth)
  nnoremap g3 <Plug>(coc-git-keepincoming)

to leave the common-ancestor section untouched

https://user-images.githubusercontent.com/1330872/114862227-f00f9200-9df6-11eb-831b-38966e84acc1.mov

Hope there will be a setting or smth that takes conflictstyle into account

subev avatar Apr 15 '21 11:04 subev

I created the following shortcuts as a vim-implementation, however would love to see this as part of coc-vim

  nnoremap g1 :<C-U>call MergeKeepLeft()<CR>
  nnoremap g2 :<C-U>call MergeKeepBoth()<CR>
  nnoremap g3 :<C-U>call MergeKeepRight()<CR>

  function! MergeKeepLeft()
    let lastsearch = @/
    let @/ = '<<<<<<<'
    execute "normal! ?\<cr>dd"

    let @/ = '|||||||'
    execute "normal! /\<cr>V"

    let @/ = '>>>>>>>'
    execute "normal! /\<cr>d"

    let @/ = lastsearch
  endfunction

  function! MergeKeepBoth()
    let lastsearch = @/
    let @/ = '<<<<<<<'
    execute "normal! ?\<cr>dd"

    let @/ = '|||||||'
    execute "normal! /\<cr>V"

    let @/ = '======='
    execute "normal! /\<cr>d"

    let @/ = '>>>>>>>'
    execute "normal! /\<cr>dd"

    let @/ = lastsearch
  endfunction

  function! MergeKeepRight()
    let lastsearch = @/
    let @/ = '<<<<<<<'
    execute "normal! ?\<cr>V"

    let @/ = '======='
    execute "normal! /\<cr>d"

    let @/ = '>>>>>>>'
    execute "normal! /\<cr>dd"

    let @/ = lastsearch
  endfunction

subev avatar Apr 15 '21 12:04 subev