Skip to content

Commit

Permalink
Merge pull request #193 from NotAShelf/neocord
Browse files Browse the repository at this point in the history
modules/rich-presence: deprecate presence-nvim in favor of neocord
  • Loading branch information
NotAShelf authored Jan 16, 2024
2 parents 0242f22 + cffe399 commit 980d497
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 70 deletions.
12 changes: 1 addition & 11 deletions configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,7 @@ inputs: let
};

vim.presence = {
presence-nvim = {
enable = true;
auto_update = true;
image_text = "The Superior Text Editor";
client_id = "793271441293967371";
main_image = "neovim";
show_time = true;
rich_presence = {
editing_text = "Editing %s";
};
};
neocord.enable = true;
};
};
};
Expand Down
4 changes: 4 additions & 0 deletions docs/release-notes/rl-0.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ Release notes for release 0.6
- Finished moving to `nixosOptionsDoc` in the documentation and changelog. We are fully free of asciidoc now

- Bumped plugin inputs to their latest versions

- Deprecated `presence.nvim` in favor of `neocord`. This means `vim.rich-presence.presence-nvim` is removed and will throw
a warning if used. You are recommended to rewrite your neocord config from scratch based on the
[official documentation](https://github.com/IogaMaster/neocord)
40 changes: 20 additions & 20 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@
};

# Presence
presence-nvim = {
url = "github:andweeb/presence.nvim";
flake = false;
neocord = {
url = "github:IogaMaster/neocord";
flake = false; # uses flake-utils, avoid the flake
};

# Autopairs
Expand Down
2 changes: 1 addition & 1 deletion lib/types/plugins.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ with lib; let
"cheatsheet-nvim"
"ccc"
"cellular-automaton"
"presence-nvim"
"neocord"
"icon-picker-nvim"
"dressing-nvim"
"orgmode-nvim"
Expand Down
4 changes: 2 additions & 2 deletions modules/rich-presence/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_: {
{
imports = [
./presence-nvim
./neocord
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@
...
}: let
inherit (lib) mkIf nvim boolToString;
inherit (lib.nvim.lua) listToLuaTable;
inherit (builtins) toString;

cfg = config.vim.presence.presence-nvim;
cfg = config.vim.presence.neocord;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["presence-nvim"];
vim.startPlugins = ["neocord"];

vim.luaConfigRC.presence-nvim = nvim.dag.entryAnywhere ''
-- Description of each option can be found in https://github.com/andweeb/presence.nvim
require("presence").setup({
vim.luaConfigRC.neocord = nvim.dag.entryAnywhere ''
-- Description of each option can be found in https://github.com/IogaMaster/neocord#lua
require("neocord").setup({
-- General options
auto_update = true,
neovim_image_text = "${cfg.image_text}",
logo = "${cfg.logo}",
logo_tooltip = "${cfg.logo_tooltip}",
main_image = "${cfg.main_image}",
client_id = "${cfg.client_id}",
log_level = nil,
debounce_timeout = 10,
enable_line_number = "${boolToString cfg.enable_line_number}",
blacklist = {},
buttons = "${boolToString cfg.buttons}",
file_assets = {},
log_level = "${
if cfg.log_level == null
then "nil"
else cfg.log_level
}",
debounce_timeout = ${toString cfg.debounce_timeout},
blacklist = ${listToLuaTable cfg.blacklist},
show_time = "${boolToString cfg.show_time}",
-- Rich Presence text options
Expand All @@ -34,6 +37,7 @@ in {
reading_text = "${cfg.rich_presence.reading_text}",
workspace_text = "${cfg.rich_presence.workspace_text}",
line_number_text = "${cfg.rich_presence.line_number_text}",
terminal_text = "${cfg.rich_presence.terminal_text}",
})
'';
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_: {
{
imports = [
./config.nix
./presence-nvim.nix
./neocord.nix
];
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,58 @@
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types;
{lib, ...}: let
inherit (lib) mkEnableOption mkOption types literalExpression mkRemovedOptionModule;
in {
options.vim.presence.presence-nvim = {
enable = mkEnableOption "presence.nvim plugin for discord rich presence";
imports = [
(mkRemovedOptionModule ["vim" "presence" "presence-nvim"] ''
The option vim.presence.presence-nvim has been deprecated in favor of the new neocord module.
Options provided by the plugin remain mostly the same, but manual migration is required.
image_text = mkOption {
Please see neocord documentation and the neovim-flake options for more info
'')
];

options.vim.presence.neocord = {
enable = mkEnableOption "neocord plugin for discord rich presence";

logo = mkOption {
type = types.str; # TODO: can the default be documented better, maybe with an enum?
default = "auto";
description = ''
Logo to be displayed on the RPC item
This must be either "auto" or an URL to your image of choice
'';
};

logo_tooltip = mkOption {
type = types.str;
default = "The One True Text Editor";
description = "Text displayed when hovering over the Neovim image";
};

main_image = mkOption {
type = types.str;
default = "neovim";
type = types.enum ["language" "logo"];
default = "language";
description = "Main image to be displayed";
};

client_id = mkOption {
type = types.str;
default = "79327144129396737";
default = "1157438221865717891";
description = "Client ID of the application";
};

log_level = mkOption {
type = with types; nullOr (enum ["debug" "info" "warn" "error"]);
default = null;
description = "Log level to be used by the plugin";
};

debounce_timeout = mkOption {
type = types.int;
default = 10;
description = "Number of seconds to debounce events";
};

auto_update = mkOption {
type = types.bool;
default = true;
Expand All @@ -38,18 +65,19 @@ in {
description = "Show line number on the RPC item";
};

buttons = mkOption {
type = types.bool;
default = true;
description = "Show buttons on the RPC item";
};

show_time = mkOption {
type = types.bool;
default = true;
description = "Show time on the RPC item";
};

blacklist = mkOption {
type = with types; listOf str;
default = [];
example = literalExpression ''["Alpha"]'';
description = "List of filetypes to ignore";
};

rich_presence = {
editing_text = mkOption {
type = types.str;
Expand Down Expand Up @@ -92,6 +120,12 @@ in {
default = "Line %s out of %s";
description = "Text displayed when showing line number";
};

terminal_text = mkOption {
type = types.str;
default = "Working on the terminal";
description = "Text displayed when working on the terminal";
};
};
};
}

0 comments on commit 980d497

Please sign in to comment.