From 31e7645ce1e675ccb96a53e8f10834310d50de7c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 18 Feb 2023 15:32:43 +0300 Subject: [PATCH] feat: add `presence.nvim` config options --- extra.nix | 15 +++- flake.lock | 34 ++++----- flake.nix | 2 +- modules/presence/default.nix | 2 +- modules/presence/discord-nvim.nix | 111 ++++++++++++++++++++++++++---- 5 files changed, 131 insertions(+), 33 deletions(-) diff --git a/extra.nix b/extra.nix index e767e1e..fdaca8d 100644 --- a/extra.nix +++ b/extra.nix @@ -163,7 +163,20 @@ inputs: let vim.comments = { comment-nvim.enable = true; - kommentary = builtins.trace "WARNING: kommentary is deprecated and will be removed in the future, use comment-nvim instead" {enable = false;}; + kommentary. enable = false; + }; + + vim.presence = { + presence-nvim = { + enable = true; + auto_update = true; + image_text = "The One True Text Editor"; + client_id = "793271441293967371"; + main_image = "neovim"; + rich_presence = { + editing_text = "Editing %s"; + }; + }; }; }; }; diff --git a/flake.lock b/flake.lock index 08f28d6..5b539ce 100644 --- a/flake.lock +++ b/flake.lock @@ -289,22 +289,6 @@ "type": "github" } }, - "discord-nvim": { - "flake": false, - "locked": { - "lastModified": 1674984077, - "narHash": "sha256-ZpsunLsn//zYgUtmAm5FqKVueVd/Pa1r55ZDqxCimBk=", - "owner": "andweeb", - "repo": "presence.nvim", - "rev": "87c857a56b7703f976d3a5ef15967d80508df6e6", - "type": "github" - }, - "original": { - "owner": "andweeb", - "repo": "presence.nvim", - "type": "github" - } - }, "dressing-nvim": { "flake": false, "locked": { @@ -1026,6 +1010,22 @@ "type": "github" } }, + "presence-nvim": { + "flake": false, + "locked": { + "lastModified": 1674984077, + "narHash": "sha256-ZpsunLsn//zYgUtmAm5FqKVueVd/Pa1r55ZDqxCimBk=", + "owner": "andweeb", + "repo": "presence.nvim", + "rev": "87c857a56b7703f976d3a5ef15967d80508df6e6", + "type": "github" + }, + "original": { + "owner": "andweeb", + "repo": "presence.nvim", + "type": "github" + } + }, "registers": { "flake": false, "locked": { @@ -1081,7 +1081,6 @@ "copilot-lua": "copilot-lua", "crates-nvim": "crates-nvim", "dashboard-nvim": "dashboard-nvim", - "discord-nvim": "discord-nvim", "dressing-nvim": "dressing-nvim", "flake-parts": "flake-parts", "flake-utils": "flake-utils", @@ -1122,6 +1121,7 @@ "onedark": "onedark", "orgmode-nvim": "orgmode-nvim", "plenary-nvim": "plenary-nvim", + "presence-nvim": "presence-nvim", "registers": "registers", "rnix-lsp": "rnix-lsp", "rust-tools": "rust-tools", diff --git a/flake.nix b/flake.nix index 4cd1704..36a224f 100644 --- a/flake.nix +++ b/flake.nix @@ -181,7 +181,7 @@ }; # Presence - discord-nvim = { + presence-nvim = { url = "github:andweeb/presence.nvim"; flake = false; }; diff --git a/modules/presence/default.nix b/modules/presence/default.nix index 649fa76..bc4e28b 100644 --- a/modules/presence/default.nix +++ b/modules/presence/default.nix @@ -1,5 +1,5 @@ _: { imports = [ - ./discord-nvim.nix + ./presence-nvim.nix ]; } diff --git a/modules/presence/discord-nvim.nix b/modules/presence/discord-nvim.nix index 50f9f3d..c1d1275 100644 --- a/modules/presence/discord-nvim.nix +++ b/modules/presence/discord-nvim.nix @@ -10,6 +10,91 @@ with builtins; let in { options.vim.presence.presence-nvim = { enable = mkEnableOption "Enable presence.nvim plugin"; + + image_text = 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"; + description = "Main image to be displayed"; + }; + + client_id = mkOption { + type = types.str; + default = "859194972255989790"; + description = "Client ID of the application"; + }; + auto_update = mkOption { + type = types.bool; + default = true; + description = "Automatically update the presence"; + }; + + enable_line_number = mkOption { + type = types.bool; + default = false; + 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"; + }; + + rich_presence = { + editing_text = mkOption { + type = types.str; + default = "Editing %s"; + description = "Text displayed when editing a file"; + }; + + file_explorer_text = mkOption { + type = types.str; + default = "Browsing %s"; + description = "Text displayed when browsing files"; + }; + + git_commit_text = mkOption { + type = types.str; + default = "Committing changes"; + description = "Text displayed when committing changes"; + }; + + plugin_manager_text = mkOption { + type = types.str; + default = "Managing plugins"; + description = "Text displayed when managing plugins"; + }; + + reading_text = mkOption { + type = types.str; + default = "Reading %s"; + description = "Text displayed when reading a file"; + }; + + workspace_text = mkOption { + type = types.str; + default = "Working on %s"; + description = "Text displayed when working on a project"; + }; + + line_number_text = mkOption { + type = types.str; + default = "Line %s out of %s"; + description = "Text displayed when showing line number"; + }; + }; }; config = mkIf cfg.enable { @@ -20,25 +105,25 @@ in { require("presence").setup({ -- General options auto_update = true, - neovim_image_text = "The One True Text Editor", - main_image = "neovim", - client_id = "793271441293967371", + neovim_image_text = ${cfg.image_text}, + main_image = ${cfg.main_image}, + client_id = ${cfg.client_id}, log_level = nil, debounce_timeout = 10, - enable_line_number = false, + enable_line_number = ${boolToString cfg.enable_line_number}, blacklist = {}, - buttons = true, + buttons = ${boolToString cfg.buttons}, file_assets = {}, - show_time = true, + show_time = ${boolToString cfg.show_time}, -- Rich Presence text options - editing_text = "Editing %s", - file_explorer_text = "Browsing %s", - git_commit_text = "Committing changes", - plugin_manager_text = "Managing plugins", - reading_text = "Reading %s", - workspace_text = "Working on %s", - line_number_text = "Line %s out of %s", + editing_text = ${cfg.rich_presence.editing_text}, + file_explorer_text = ${cfg.rich_presence.file_explorer_text}, + git_commit_text = ${cfg.rich_presence.git_commit_text}, + plugin_manager_text = ${cfg.rich_presence.plugin_manager_text}, + reading_text = ${cfg.rich_presence.reading_text}, + workspace_text = ${cfg.rich_presence.workspace_text}, + line_number_text = ${cfg.rich_presence.line_number_text}, }) ''; };