Skip to content

isaksamsten/conflicting.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

conflicting.nvim

conflicting.nvim allows you to resolve conflicts while highlighting them in style.

The plugin was originally integrated into my LLM code assistant (sia.nvim), but I appreciated its workflow for managing merge conflicts. So here it is: a conflict resolver that is resource-light (it adds no overhead when there are no conflicts) while offering a more visually appealing experience.

Demo

Screen.Recording.2025-02-16.at.21.30.08.mov
Screen.Recording.2025-02-16.at.21.33.20.mov

Features

  • Track Git repositories for merge conflicts. No overhead for files without conflicts.
  • Manually track files for conflicts from other source (e.g., sia.nvim)
  • Resolve conflicts:
    • Accept current changes
    • Accept incoming changes
    • Reject all changes
    • Diff current and incoming changes

Installation

{
  "isaksamsten/conflicting.nvim",
  --- Optionally bind keys
  keys = {
    {
      "ct",
      mode = "n",
      function()
        require("conflicting").accept_incoming()
      end,
      desc = "Accept incoming change",
    },
    {
      "co",
      mode = "n",
      function()
        require("conflicting").accept_current()
      end,
      desc = "Accept current change",
    },
    {
      "cd",
      mode = "n",
      function()
        require("conflicting").diff()
      end,
      desc = "Diff change",
    },
  },
  config = true,
}

Configuration

{
  -- Track conflicts using the following trackers
  trackers = { require("conflicting").trackers.git, require("conflicting").trackers.manual },

  -- Automatically enable conflicting for all buffers
  auto_enable = true,
}

Usage

Bind the following functions to suitable keys or use the command Conflicting:

  • require("conflicting").accept_incoming(): accept incoming changes. The same as Conflicting incoming
  • require("conflicting").accept_current(): accept current changes (reject incoming changes). The same as Conflicting current.
  • require("conflicting").accept_both(): accept both changes (and manually edit the conflict). The same as Conflicting both.
  • require("conflicting").reject(): reject both changes. The same as Conflicting reject.
  • require("conflicting").diff(): open a two-way diff with the current and incoming changes to manually merge the changes. The same as Conflicting diff.

Highlight groups

conflicting.nvim uses the following highlight groups:

  • ConflictingOursHeader links to DiffAdd by default
  • ConflictingOurs links to DiffAdd by default
  • ConflictingTheirs links to DiffChange by default
  • ConflictingTheirsHeader links to DiffChange by default
  • ConflictingDelimiter links to Normal by default

Since no colorscheme integrates with conflicting.nvim, you need to set the highlight groups manually to override these defaults. See my config for inspiration.

About

Resolve conflicts and highlighting them in style.

Resources

License

Stars

Watchers

Forks

Languages