diff --git a/plugins/default.nix b/plugins/default.nix index 968ec447..c95c5040 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -40,6 +40,7 @@ ./git/committia.nix ./git/diffview.nix ./git/fugitive.nix + ./git/git-conflict.nix ./git/git-worktree.nix ./git/gitblame.nix ./git/gitgutter.nix diff --git a/plugins/git/git-conflict.nix b/plugins/git/git-conflict.nix new file mode 100644 index 00000000..e3c7bf71 --- /dev/null +++ b/plugins/git/git-conflict.nix @@ -0,0 +1,94 @@ +{ + lib, + helpers, + config, + pkgs, + ... +}: +with lib; +helpers.neovim-plugin.mkNeovimPlugin config { + name = "git-conflict"; + originalName = "git-conflict.nvim"; + defaultPackage = pkgs.vimPlugins.git-conflict-nvim; + + maintainers = [ maintainers.GaetanLepage ]; + + extraOptions = { + gitPackage = helpers.mkPackageOption { + name = "git"; + default = pkgs.git; + }; + }; + + extraConfig = cfg: { extraPackages = [ cfg.gitPackage ]; }; + + settingsOptions = { + default_mappings = + helpers.defaultNullOpts.mkNullable (with types; either bool (attrsOf str)) "true" + '' + This plugin offers default buffer local mappings inside conflicted files. + This is primarily because applying these mappings only to relevant buffers is impossible + through global mappings. + + Set to `false` to disable mappings entirely. + + Defaults (if left `true`): + ```nix + { + ours = "co"; + theirs = "ct"; + none = "c0"; + both = "cb"; + next = "[x"; + prev = "]x"; + } + ``` + ''; + + default_commands = helpers.defaultNullOpts.mkBool true '' + Set to `false` to disable commands created by this plugin. + ''; + + disable_diagnostics = helpers.defaultNullOpts.mkBool false '' + This will disable the diagnostics in a buffer whilst it is conflicted. + ''; + + list_opener = helpers.defaultNullOpts.mkStr "copen" '' + Command or function to open the conflicts list. + ''; + + highlights = { + incoming = helpers.defaultNullOpts.mkStr "DiffAdd" '' + Which highlight group to use for incoming changes. + ''; + + current = helpers.defaultNullOpts.mkStr "DiffText" '' + Which highlight group to use for current changes. + ''; + + ancestor = helpers.mkNullOrStr '' + Which highlight group to use for ancestor. + + Plugin default: `null` + ''; + }; + }; + + settingsExample = { + default_mappings = { + ours = "o"; + theirs = "t"; + none = "0"; + both = "b"; + next = "n"; + prev = "p"; + }; + default_commands = true; + disable_diagnostics = false; + list_opener = "copen"; + highlights = { + incoming = "DiffAdd"; + current = "DiffText"; + }; + }; +} diff --git a/tests/test-sources/plugins/git/git-conflict.nix b/tests/test-sources/plugins/git/git-conflict.nix new file mode 100644 index 00000000..d1b8a32f --- /dev/null +++ b/tests/test-sources/plugins/git/git-conflict.nix @@ -0,0 +1,47 @@ +{ + empty = { + plugins.git-conflict.enable = true; + }; + + defaults = { + plugins.git-conflict = { + enable = true; + + settings = { + default_mappings = true; + default_commands = true; + disable_diagnostics = false; + list_opener = "copen"; + highlights = { + incoming = "DiffAdd"; + current = "DiffText"; + ancestor = null; + }; + }; + }; + }; + + example = { + plugins.git-conflict = { + enable = true; + + settings = { + default_mappings = { + ours = "o"; + theirs = "t"; + none = "0"; + both = "b"; + next = "n"; + prev = "p"; + }; + default_commands = true; + disable_diagnostics = false; + list_opener = "copen"; + highlights = { + incoming = "DiffAdd"; + current = "DiffText"; + }; + }; + }; + }; +}