{ lib, cmake, fetchFromGitHub, nix-update-script, vimUtils, vimPlugins, autoPatchelfHook, stdenv, llvmPackages, }: vimUtils.buildVimPlugin rec { pname = "codediff.nvim"; version = "2.67.0"; src = fetchFromGitHub { owner = "esmuellert"; repo = "codediff.nvim"; tag = "v${version}"; hash = "sha256-LNDCn8OAbRXBC2B4pbAhxVxGWBCbOJmDAELlB0LuGvI="; }; dependencies = [ vimPlugins.nui-nvim ]; nativeBuildInputs = [ cmake ] ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ]; buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ stdenv.cc.cc.lib ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ llvmPackages.openmp ]; dontUseCmakeConfigure = true; postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' substituteInPlace libvscode-diff/CMakeLists.txt \ --replace-fail 'COMMAND brew --prefix libomp' 'COMMAND echo ${llvmPackages.openmp}' ''; buildPhase = '' runHook preBuild make runHook postBuild ''; # Cleanup preInstall = '' rm -rf build ''; # The plugin detects Nix and tries to download libgomp at runtime. # Symlinking it into the plugin directory fixes error message. postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' ln -s ${stdenv.cc.cc.lib}/lib/libgomp.so.1 $out/libgomp.so.1 ''; passthru.updateScript = nix-update-script { }; meta = { description = "VSCode-style side-by-side diff rendering with two-tier highlighting (line + character level)"; homepage = "https://github.com/esmuellert/codediff.nvim/"; license = lib.licenses.mit; platforms = lib.platforms.all; }; }