diff --git a/configuration.nix b/configuration.nix index 5cabc67b..a038db2d 100644 --- a/configuration.nix +++ b/configuration.nix @@ -293,6 +293,7 @@ isMaximal: { presence = { neocord.enable = false; + cord-nvim.enable = false; }; }; } diff --git a/docs/manual/release-notes/rl-0.9.md b/docs/manual/release-notes/rl-0.9.md index 3d1fef06..db04e48c 100644 --- a/docs/manual/release-notes/rl-0.9.md +++ b/docs/manual/release-notes/rl-0.9.md @@ -506,4 +506,10 @@ https://github.com/gorbit99/codewindow.nvim - Allow `vim.treesitter.context.setupOpts.max_lines` to also be given as a string in order to allow percentage values like `"20%"` +[Adam0](https://github.com/adam01110): + +[cord.nvim]: https://github.com/vyfor/cord.nvim + +- Add [cord.nvim] plugin in `vim.presence.cord` with `enable` and `setupOpts` + diff --git a/flake/pkgs/by-name/cord-nvim/package.nix b/flake/pkgs/by-name/cord-nvim/package.nix new file mode 100644 index 00000000..17f89be0 --- /dev/null +++ b/flake/pkgs/by-name/cord-nvim/package.nix @@ -0,0 +1,56 @@ +{ + lib, + pins, + fetchFromGitHub, + rustPlatform, + stdenv, + vimUtils, +}: let + pin = pins.cord-nvim; + + pname = "cord"; + version = pin.revision; + src = fetchFromGitHub { + inherit (pin.repository) owner repo; + rev = pin.revision; + sha256 = pin.hash; + }; + + cord-server = rustPlatform.buildRustPackage { + inherit pname version src; + + postPatch = '' + substituteInPlace .github/server-version.txt \ + --replace-fail "2.3.13" "${version}" + ''; + + cargoHash = "sha256-/O+jOaA0PinUiEVILNEF+vUS7Kh3XAwWyFqSvD54rGM="; + + doCheck = false; + + env.RUSTFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-C link-arg=-undefined -C link-arg=dynamic_lookup"; + + meta.mainProgram = "cord"; + }; +in + vimUtils.buildVimPlugin { + pname = "cord-nvim"; + inherit version src; + + doCheck = false; + + postPatch = '' + substituteInPlace lua/cord/server/fs/init.lua \ + --replace-fail "or M.get_data_path()" "or '${cord-server}'" + + substituteInPlace lua/cord/api/config/init.lua \ + --replace-fail "update = 'fetch'," "update = 'none'," \ + --replace-fail "auto_update = true," "auto_update = false," + ''; + + meta = { + description = "Discord rich presence plugin for Neovim"; + homepage = "https://github.com/vyfor/cord.nvim"; + license = lib.licenses.asl20; + }; + } diff --git a/modules/plugins/rich-presence/cord-nvim/config.nix b/modules/plugins/rich-presence/cord-nvim/config.nix new file mode 100644 index 00000000..c22c1858 --- /dev/null +++ b/modules/plugins/rich-presence/cord-nvim/config.nix @@ -0,0 +1,22 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + + cfg = config.vim.presence.cord-nvim; +in { + config = mkIf cfg.enable { + vim = { + globals.cord_defer_startup = true; + + lazy.plugins.cord-nvim = { + package = "cord-nvim"; + setupModule = "cord"; + inherit (cfg) setupOpts; + event = ["DeferredUIEnter"]; + }; + }; + }; +} diff --git a/modules/plugins/rich-presence/cord-nvim/cord-nvim.nix b/modules/plugins/rich-presence/cord-nvim/cord-nvim.nix new file mode 100644 index 00000000..a89e1837 --- /dev/null +++ b/modules/plugins/rich-presence/cord-nvim/cord-nvim.nix @@ -0,0 +1,10 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.presence.cord-nvim = { + enable = mkEnableOption "Discord rich presence [cord.nvim]"; + + setupOpts = mkPluginSetupOption "cord.nvim" {}; + }; +} diff --git a/modules/plugins/rich-presence/cord-nvim/default.nix b/modules/plugins/rich-presence/cord-nvim/default.nix new file mode 100644 index 00000000..8662e4c7 --- /dev/null +++ b/modules/plugins/rich-presence/cord-nvim/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./cord-nvim.nix + ]; +} diff --git a/modules/plugins/rich-presence/default.nix b/modules/plugins/rich-presence/default.nix index 4e7fe0fa..8e96b6b3 100644 --- a/modules/plugins/rich-presence/default.nix +++ b/modules/plugins/rich-presence/default.nix @@ -1,5 +1,6 @@ { imports = [ + ./cord-nvim ./neocord ]; } diff --git a/modules/wrapper/build/config.nix b/modules/wrapper/build/config.nix index ba25552c..d2c27291 100644 --- a/modules/wrapper/build/config.nix +++ b/modules/wrapper/build/config.nix @@ -57,7 +57,7 @@ # Get plugins built from source from self.packages # If adding a new plugin to be built from source, it must also be inherited # here. - inherit (inputs.self.packages.${pkgs.stdenv.system}) blink-cmp avante-nvim; + inherit (inputs.self.packages.${pkgs.stdenv.system}) blink-cmp avante-nvim cord-nvim; }; buildConfigPlugins = plugins: diff --git a/npins/sources.json b/npins/sources.json index 1e2b4526..dbd0ac34 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -381,6 +381,19 @@ "url": "https://github.com/zbirenbaum/copilot.lua/archive/0552b44fceedf0c4cba2cd4953d3976633b2509a.tar.gz", "hash": "sha256-PULc9fiFljpomXDBY1HeJDttImQf7lYprpNEx5MZO4Y=" }, + "cord-nvim": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "vyfor", + "repo": "cord.nvim" + }, + "branch": "master", + "submodules": false, + "revision": "0be090969e978f7442870ef227e09eff7bf3480d", + "url": "https://github.com/vyfor/cord.nvim/archive/0be090969e978f7442870ef227e09eff7bf3480d.tar.gz", + "hash": "sha256-J1Hc38vrltbRQi+ztiMMu1G6z3N1PVtFxQ7qMGsgq00=" + }, "crates-nvim": { "type": "Git", "repository": {