Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
subev opened this issue Apr 15, 2021 · 1 comment

Comments

@subev
Copy link

subev commented Apr 15, 2021

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

Screen.Recording.2021-04-15.at.14.28.26.mov

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

@subev
Copy link
Author

subev commented Apr 15, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant