Skip to content

tronikelis/conflict-marker.nvim

Repository files navigation

conflict-marker.nvim

The simple git conflict resolver for neovim

image

quick demo
2024-10-06.21-19-44.mp4

You can customize these colors, I just picked something at random :P

Philosophy

  • it has to be simple (in fact whole plugin is under 300 lua loc)
  • performance-first (finding conflicts does not load whole buf into extra memory)

Features

  • highlights
  • resolving conflicts
  • diff3 style

User commands

  • Conflict ours: resolves the conflict under the cursor with our changes
  • Conflict theirs: resolves the conflict under the cursor with their changes
  • Conflict both: resolves the conflict under the cursor with both changes (removes markers)
  • Conflict none: resolves the conflict the best way possible, just removing it xd

Highlighting

Highlighting is enabled by default but can be disabled by setting highlights = false in config

Note for nvimdiff users !!!: if highlighting is enabled, the Diff* hl groups are disabled in buffers which have a conflict, because those groups interfere heavily with conflict-marker.nvim highlighting

Groups

  • ConflictOurs
  • ConflictTheirs

Config

require("conflict-marker").setup({
  highlights = true,
  on_attach = function(conflict) end,
})

Recipes

Jump to markers

require("conflict-marker").setup({
  on_attach = function(conflict)
    local MID = "^=======$"

    vim.keymap.set("n", "[x", function()
      vim.cmd("?" .. MID)
    end, { buffer = conflict.bufnr })

    vim.keymap.set("n", "]x", function()
      vim.cmd("/" .. MID)
    end, { buffer = conflict.bufnr })
  end,
})

extra keymaps (co, ct, etc...)

require("conflict-marker").setup({
  on_attach = function(conflict)
    local map = function(key, fn)
      vim.keymap.set("n", key, fn, { buffer = conflict.bufnr })
    end

    -- or you can map these to <cmd>ChooseOurs<cr>

    map("co", function()
      conflict:choose_ours()
    end)
    map("ct", function()
      conflict:choose_theirs()
    end)
    map("cb", function()
      conflict:choose_both()
    end)
    map("cn", function()
      conflict:choose_none()
    end)
  end,
})

About

The simple git conflict resolver for neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published