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

Feature: Choose Ours/Theirs/Both for entire File #34

Open
ariel-frischer opened this issue Oct 31, 2022 · 10 comments
Open

Feature: Choose Ours/Theirs/Both for entire File #34

ariel-frischer opened this issue Oct 31, 2022 · 10 comments

Comments

@ariel-frischer
Copy link

ariel-frischer commented Oct 31, 2022

I really like this plugin, only thing I wish it has would be some util functions Choose ours/theirs/both for the entire file. The use case is, I had a yarn.lock file where many conflicts occurred. It had over 400 conflicts which is actually normal for a larger codebase. Going to next conflict and resolving in this case is not feasible, I just created a quick macro and called it +400 times which worked but seems janky and inefficient. A command mode function for this situation seems appropriate.

@akinsho
Copy link
Owner

akinsho commented Nov 7, 2022

Would be happy to take a PR to implement something like this, maybe allowing the commands to take a visual range 🤷🏿‍♂️. Probably not going to work on this myself though, as I definitely don't have the time.

@Chaitanyabsprip
Copy link

A vim macro should be a decent solution for this.

@partounian
Copy link

This is super late, but why not just use git checkout {branch_name} -- {filepath} to checkout the file from the branch you want?

@ariel-frischer
Copy link
Author

This is super late, but why not just use git checkout {branch_name} -- {filepath} to checkout the file from the branch you want?

Yea good point.

@jgarciaokode
Copy link

Hi, is this possible then? I don't know how to create that action, should we wait for a solution from the plugin author o could we implemente something on our own?

@Tokarak
Copy link

Tokarak commented Oct 28, 2023

I'm for using a visual selection; that makes it much more general than the whole file.

@CWood-sdf
Copy link
Contributor

I made a PR for this that adds visual mode remaps a few months ago, but it hasnt gotten any comments or anything from @akinsho so im not really sure if it's going to be merged

@akinsho
Copy link
Owner

akinsho commented Mar 28, 2024

@CWood-sdf thanks for the PR I noticed it but have not really had the time to look into open source projects given work and life, let alone this is one of my smaller plugins 😅. It's on my todo list

@TheNoeTrevino
Copy link

TheNoeTrevino commented Oct 7, 2024

It has been a while, but this is what I would do for this:

The command below puts all the conflicts in my quickfix list when a file with conflicts is detected (modified from the README)

vim.api.nvim_create_autocmd("User", {
  pattern = "GitConflictDetected",
  callback = function()
    vim.notify("Conflict detected in: " .. vim.fn.expand("%:t") .. " ")

    vim.schedule(function()
      vim.cmd("GitConflictListQf")
      vim.cmd("cclose")
    end)
  end,
})

I would then map this:

map('n', 'gco', '<cmd>cdo GitConflictChooseOurs<CR>) (globally choose ours)

I have done this before! I personally do not have a mapping, as I feel this is not an action that should not be taken lightly. But i am not here to stop you!

@CWood-sdf
Copy link
Contributor

I had a pr merged for this (#78 ) a while back. It allows you to use visual selection mode to resolve a range of conflicts. It's more powerful than having to do something for the entire file

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

8 participants