From ca6240ddc2f507742f52650b3ea6a74d477afe30 Mon Sep 17 00:00:00 2001 From: Redyf Date: Thu, 15 Feb 2024 17:20:45 -0300 Subject: [PATCH] plugins/neocord: init Add support for https://github.com/IogaMaster/neocord --- plugins/default.nix | 1 + plugins/utils/neocord.nix | 172 +++++++++++++++++++ tests/test-sources/plugins/utils/neocord.nix | 73 ++++++++ 3 files changed, 246 insertions(+) create mode 100644 plugins/utils/neocord.nix create mode 100644 tests/test-sources/plugins/utils/neocord.nix diff --git a/plugins/default.nix b/plugins/default.nix index 832ac1fc..d926b631 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -142,6 +142,7 @@ ./utils/molten.nix ./utils/multicursors.nix ./utils/navbuddy.nix + ./utils/neocord.nix ./utils/neogen.nix ./utils/neorg.nix ./utils/netman.nix diff --git a/plugins/utils/neocord.nix b/plugins/utils/neocord.nix new file mode 100644 index 00000000..7aa9d26c --- /dev/null +++ b/plugins/utils/neocord.nix @@ -0,0 +1,172 @@ +{ + lib, + helpers, + config, + pkgs, + ... +}: +with lib; + helpers.neovim-plugin.mkNeovimPlugin config { + name = "neocord"; + defaultPackage = pkgs.vimPlugins.neocord; + + maintainers = [maintainers.redyf]; + + settingsOptions = { + # General options. + auto_update = helpers.defaultNullOpts.mkBool true '' + Update activity based on autocmd events. + If `false`, map or manually execute + `:lua package.loaded.neocord:update()` + ''; + + logo = helpers.defaultNullOpts.mkEnum ["auto" "url"] "auto" '' + Update the Logo to the specified option ("auto" or url). + ''; + + logo_tooltip = helpers.defaultNullOpts.mkEnum ["null" "string"] "null" '' + Sets the logo tooltip + ''; + + main_image = helpers.defaultNullOpts.mkEnum ["language" "logo"] "language" '' + Main image display (either "language" or "logo") + ''; + + client_id = helpers.defaultNullOpts.mkStr "1157438221865717891" '' + Use your own Discord application client id. (not recommended) + ''; + + log_level = helpers.defaultNullOpts.mkEnum ["debug" "info" "warn" "error"] "null" '' + Log messages at or above this level. + ''; + + debounce_timeout = helpers.defaultNullOpts.mkInt 10 '' + Number of seconds to debounce events. + (or calls to `:lua package.loaded.neocord:update(, true)`) + ''; + + enable_line_number = helpers.defaultNullOpts.mkBool false '' + Displays the current line number instead of the current project. + ''; + + blacklist = helpers.defaultNullOpts.mkListOf types.str "[]" '' + A list of strings or Lua patterns that disable Rich Presence if the + current file name, path, or workspace matches. + ''; + + buttons = + helpers.defaultNullOpts.mkNullable + (with types; + either + helpers.nixvimTypes.rawLua + (listOf (submodule { + options = { + label = helpers.mkNullOrOption str ""; + url = helpers.mkNullOrOption str ""; + }; + }))) + "[]" + '' + Button configurations which will always appear in Rich Presence. + Can be a list of attribute sets, each with the following attributes: + `label`: The label of the button. e.g. `"GitHub Profile"`. + `url`: The URL the button leads to. e.g. `"https://github.com/"`. + Can also be a lua function: `function(buffer: string, repo_url: string|nil): table` + ''; + + file_assets = helpers.mkNullOrOption (with types; attrsOf (listOf str)) '' + Custom file asset definitions keyed by file names and extensions. + List elements for each attribute (filetype): + `name`: The name of the asset shown as the title of the file in Discord. + `source`: The source of the asset, either an art asset key or the URL of an image asset. + Example: + ```nix + { + # Use art assets uploaded in Discord application for the configured client id + js = [ "JavaScript" "javascript" ]; + ts = [ "TypeScript" "typescript" ]; + # Use image URLs + rs = [ "Rust" "https://www.rust-lang.org/logos/rust-logo-512x512.png" ]; + go = [ "Go" "https://go.dev/blog/go-brand/Go-Logo/PNG/Go-Logo_Aqua.png" ]; + }; + ``` + ''; + + show_time = helpers.defaultNullOpts.mkBool true "Show the timer."; + + global_timer = helpers.defaultNullOpts.mkBool false "if set true, timer won't update when any event are triggered."; + + # Rich presence text options. + editing_text = helpers.defaultNullOpts.mkStr "Editing %s" '' + String rendered when an editable file is loaded in the buffer. + Can also be a lua function: + `function(filename: string): string` + ''; + + file_explorer_text = helpers.defaultNullOpts.mkStr "Browsing %s" '' + String rendered when browsing a file explorer. + Can also be a lua function: + `function(file_explorer_name: string): string` + ''; + + git_commit_text = helpers.defaultNullOpts.mkStr "Committing changes" '' + String rendered when committing changes in git. + Can also be a lua function: + `function(filename: string): string` + ''; + + plugin_manager_text = helpers.defaultNullOpts.mkStr "Managing plugins" '' + String rendered when managing plugins. + Can also be a lua function: + `function(plugin_manager_name: string): string` + ''; + + reading_text = helpers.defaultNullOpts.mkStr "Reading %s" '' + String rendered when a read-only/unmodifiable file is loaded into the buffer. + Can also be a lua function: + `function(filename: string): string` + ''; + + workspace_text = helpers.defaultNullOpts.mkStr "Working on %s" '' + String rendered when in a git repository. + Can also be a lua function: + `function(project_name: string|nil, filename: string): string` + ''; + + line_number_text = helpers.defaultNullOpts.mkStr "Line %s out of %s" '' + String rendered when `enableLineNumber` is set to `true` to display the current line number. + Can also be a lua function: + `function(line_number: number, line_count: number): string` + ''; + + terminal_text = helpers.defaultNullOpts.mkStr "Using Terminal" '' + Format string rendered when in terminal mode. + ''; + }; + + settingsExample = { + #General options + auto_update = true; + logo = "auto"; + logo_tooltip = null; + main_image = "language"; + client_id = "1157438221865717891"; + log_level = null; + debounce_timeout = 10; + enable_line_number = false; + blacklist = []; + file_assets = null; + show_time = true; + global_timer = false; + + # Rich Presence text options + editing_text = "Editing..."; + file_explorer_text = "Browsing..."; + git_commit_text = "Committing changes..."; + plugin_manager_text = "Managing plugins..."; + reading_text = "Reading..."; + workspace_text = "Working on %s"; + line_number_text = "Line %s out of %s"; + terminal_text = "Using Terminal..."; + }; + } diff --git a/tests/test-sources/plugins/utils/neocord.nix b/tests/test-sources/plugins/utils/neocord.nix new file mode 100644 index 00000000..e714487c --- /dev/null +++ b/tests/test-sources/plugins/utils/neocord.nix @@ -0,0 +1,73 @@ +{ + empty = { + # don't run tests as they try to acess the network. + tests.dontRun = true; + plugins.neocord.enable = true; + }; + + defaults = { + # don't run tests as they try to acess the network. + tests.dontRun = true; + plugins.neocord = { + enable = true; + + settings = { + # General options. + logo = "auto"; + logo_tooltip = null; + main_image = "language"; + client_id = "1157438221865717891"; + log_level = null; + debounce_timeout = 10; + blacklist = []; + file_assets = null; + show_time = true; + global_timer = false; + + # 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"; + terminal_text = "Using Terminal"; + }; + }; + }; + + example = { + # don't run tests as they try to acess the network. + tests.dontRun = true; + plugins.neocord = { + enable = true; + + settings = { + #General options + auto_update = true; + logo = "auto"; + logo_tooltip = null; + main_image = "language"; + client_id = "1157438221865717891"; + log_level = null; + debounce_timeout = 10; + enable_line_number = false; + blacklist = []; + file_assets = null; + show_time = true; + global_timer = false; + + # Rich Presence text options + editing_text = "Editing..."; + file_explorer_text = "Browsing..."; + git_commit_text = "Committing changes..."; + plugin_manager_text = "Managing plugins..."; + reading_text = "Reading..."; + workspace_text = "Working on %s"; + line_number_text = "Line %s out of %s"; + terminal_text = "Using Terminal..."; + }; + }; + }; +}