mirror of
https://github.com/nix-community/nixvim.git
synced 2025-11-08 19:46:06 +01:00
plugins/presence-nvim: migrate to mkNeovimPlugin
This commit is contained in:
parent
98c0bd99a1
commit
f56b6d184b
3 changed files with 91 additions and 235 deletions
|
|
@ -1,219 +1,34 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
let
|
name = "presence-nvim";
|
||||||
cfg = config.plugins.presence-nvim;
|
package = "presence-nvim";
|
||||||
in
|
moduleName = "presence";
|
||||||
{
|
description = "Discord Rich Presence for Neovim.";
|
||||||
options = {
|
|
||||||
plugins.presence-nvim = lib.nixvim.plugins.neovim.extraOptionsOptions // {
|
|
||||||
enable = mkEnableOption "presence-nvim";
|
|
||||||
package = lib.mkPackageOption pkgs "presence-nvim" {
|
|
||||||
default = [
|
|
||||||
"vimPlugins"
|
|
||||||
"presence-nvim"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
# General options.
|
maintainers = [ lib.maintainers.khaneliman ];
|
||||||
autoUpdate = helpers.defaultNullOpts.mkBool true ''
|
|
||||||
Update activity based on autocmd events.
|
|
||||||
If `false`, map or manually execute
|
|
||||||
`:lua package.loaded.presence:update()`
|
|
||||||
'';
|
|
||||||
|
|
||||||
neovimImageText = helpers.defaultNullOpts.mkStr "The One True Text Editor" ''
|
# TODO: introduced 2025-10-06
|
||||||
Text displayed when hovered over the Neovim image.
|
inherit (import ./deprecations.nix) deprecateExtraOptions optionsRenamedToSettings;
|
||||||
'';
|
|
||||||
|
|
||||||
mainImage =
|
settingsExample = {
|
||||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
auto_update = false;
|
||||||
[
|
neovim_image_text = "The Superior Text Editor";
|
||||||
"neovim"
|
main_image = "file";
|
||||||
"file"
|
editing_text = "Crafting %s";
|
||||||
]
|
workspace_text = "Working on %s";
|
||||||
''
|
enable_line_number = true;
|
||||||
Main image display.
|
buttons = [
|
||||||
'';
|
{
|
||||||
|
label = "GitHub";
|
||||||
clientId = helpers.defaultNullOpts.mkStr "793271441293967371" ''
|
url = "https://github.com/username";
|
||||||
Use your own Discord application client id. (not recommended)
|
|
||||||
'';
|
|
||||||
|
|
||||||
logLevel =
|
|
||||||
helpers.defaultNullOpts.mkEnum
|
|
||||||
[
|
|
||||||
"debug"
|
|
||||||
"info"
|
|
||||||
"warn"
|
|
||||||
"error"
|
|
||||||
]
|
|
||||||
null
|
|
||||||
''
|
|
||||||
Log messages at or above this level.
|
|
||||||
'';
|
|
||||||
|
|
||||||
debounceTimeout = helpers.defaultNullOpts.mkInt 10 ''
|
|
||||||
Number of seconds to debounce events.
|
|
||||||
(or calls to `:lua package.loaded.presence:update(<filename>, true)`)
|
|
||||||
'';
|
|
||||||
|
|
||||||
enableLineNumber = 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.mkListOf
|
|
||||||
(types.submodule {
|
|
||||||
options = {
|
|
||||||
label = helpers.mkNullOrOption types.str "";
|
|
||||||
url = helpers.mkNullOrOption types.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/<NAME>"`.
|
|
||||||
|
|
||||||
Can also be a lua function: `function(buffer: string, repo_url: string|nil): table)`
|
|
||||||
'';
|
|
||||||
|
|
||||||
fileAssets = 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" ];
|
|
||||||
};
|
|
||||||
```
|
|
||||||
'';
|
|
||||||
|
|
||||||
showTime = helpers.defaultNullOpts.mkBool true "Show the timer.";
|
|
||||||
|
|
||||||
# Rich presence text options.
|
|
||||||
editingText =
|
|
||||||
helpers.defaultNullOpts.mkNullable (types.either types.str types.rawLua) "Editing %s"
|
|
||||||
''
|
|
||||||
String rendered when an editable file is loaded in the buffer.
|
|
||||||
|
|
||||||
Can also be a lua function:
|
|
||||||
`function(filename: string): string`
|
|
||||||
'';
|
|
||||||
|
|
||||||
fileExplorerText =
|
|
||||||
helpers.defaultNullOpts.mkNullable (types.either types.str types.rawLua) "Browsing %s"
|
|
||||||
''
|
|
||||||
String rendered when browsing a file explorer.
|
|
||||||
|
|
||||||
Can also be a lua function:
|
|
||||||
`function(file_explorer_name: string): string`
|
|
||||||
'';
|
|
||||||
|
|
||||||
gitCommitText =
|
|
||||||
helpers.defaultNullOpts.mkNullable (types.either types.str types.rawLua) "Committing changes"
|
|
||||||
''
|
|
||||||
String rendered when committing changes in git.
|
|
||||||
|
|
||||||
Can also be a lua function:
|
|
||||||
`function(filename: string): string`
|
|
||||||
'';
|
|
||||||
|
|
||||||
pluginManagerText =
|
|
||||||
helpers.defaultNullOpts.mkNullable (types.either types.str types.rawLua) "Managing plugins"
|
|
||||||
''
|
|
||||||
String rendered when managing plugins.
|
|
||||||
|
|
||||||
Can also be a lua function:
|
|
||||||
`function(plugin_manager_name: string): string`
|
|
||||||
'';
|
|
||||||
|
|
||||||
readingText =
|
|
||||||
helpers.defaultNullOpts.mkNullable (types.either types.str types.rawLua) "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`
|
|
||||||
'';
|
|
||||||
|
|
||||||
workspaceText =
|
|
||||||
helpers.defaultNullOpts.mkNullable (types.either types.str types.rawLua) "Working on %s"
|
|
||||||
''
|
|
||||||
String rendered when in a git repository.
|
|
||||||
|
|
||||||
Can also be a lua function:
|
|
||||||
`function(project_name: string|nil, filename: string): string`
|
|
||||||
'';
|
|
||||||
|
|
||||||
lineNumberText =
|
|
||||||
helpers.defaultNullOpts.mkNullable (types.either types.str types.rawLua) "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`
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config =
|
|
||||||
let
|
|
||||||
setupOptions = {
|
|
||||||
# General options.
|
|
||||||
auto_update = cfg.autoUpdate;
|
|
||||||
neovim_image_text = cfg.neovimImageText;
|
|
||||||
main_image = cfg.mainImage;
|
|
||||||
client_id = cfg.clientId;
|
|
||||||
log_level = cfg.logLevel;
|
|
||||||
debounce_timeout = cfg.debounceTimeout;
|
|
||||||
enable_line_number = cfg.enableLineNumber;
|
|
||||||
inherit (cfg) blacklist;
|
|
||||||
file_assets = cfg.fileAssets;
|
|
||||||
show_time = cfg.showTime;
|
|
||||||
inherit (cfg) buttons;
|
|
||||||
|
|
||||||
# Rich presence text options.
|
|
||||||
editing_text = cfg.editingText;
|
|
||||||
file_explorer_text = cfg.fileExplorerText;
|
|
||||||
git_commit_text = cfg.gitCommitText;
|
|
||||||
plugin_manager_text = cfg.pluginManagerText;
|
|
||||||
reading_text = cfg.readingText;
|
|
||||||
workspace_text = cfg.workspaceText;
|
|
||||||
line_number_text = cfg.lineNumberText;
|
|
||||||
}
|
}
|
||||||
// cfg.extraOptions;
|
];
|
||||||
in
|
blacklist = [
|
||||||
mkIf cfg.enable {
|
"NvimTree"
|
||||||
extraPlugins = [ cfg.package ];
|
"alpha"
|
||||||
extraConfigLua = ''
|
];
|
||||||
require("presence").setup${lib.nixvim.toLuaObject setupOptions}
|
};
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
23
plugins/by-name/presence-nvim/deprecations.nix
Normal file
23
plugins/by-name/presence-nvim/deprecations.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
deprecateExtraOptions = true;
|
||||||
|
optionsRenamedToSettings = [
|
||||||
|
"autoUpdate"
|
||||||
|
"neovimImageText"
|
||||||
|
"mainImage"
|
||||||
|
"clientId"
|
||||||
|
"logLevel"
|
||||||
|
"debounceTimeout"
|
||||||
|
"enableLineNumber"
|
||||||
|
"blacklist"
|
||||||
|
"buttons"
|
||||||
|
"fileAssets"
|
||||||
|
"showTime"
|
||||||
|
"editingText"
|
||||||
|
"fileExplorerText"
|
||||||
|
"gitCommitText"
|
||||||
|
"pluginManagerText"
|
||||||
|
"readingText"
|
||||||
|
"workspaceText"
|
||||||
|
"lineNumberText"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -6,32 +6,50 @@
|
||||||
defaults = {
|
defaults = {
|
||||||
plugins.presence-nvim = {
|
plugins.presence-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
auto_update = true;
|
||||||
|
neovim_image_text = "The One True Text Editor";
|
||||||
|
main_image = "neovim";
|
||||||
|
client_id = "793271441293967371";
|
||||||
|
log_level = null;
|
||||||
|
debounce_timeout = 10;
|
||||||
|
enable_line_number = false;
|
||||||
|
blacklist = [ ];
|
||||||
|
file_assets = null;
|
||||||
|
show_time = true;
|
||||||
|
buttons = [ ];
|
||||||
|
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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# General options.
|
example = {
|
||||||
autoUpdate = true;
|
plugins.presence-nvim = {
|
||||||
|
enable = true;
|
||||||
neovimImageText = "The One True Text Editor";
|
settings = {
|
||||||
mainImage = "neovim";
|
auto_update = false;
|
||||||
|
neovim_image_text = "The Superior Text Editor";
|
||||||
clientId = "793271441293967371";
|
main_image = "file";
|
||||||
logLevel = null;
|
editing_text = "Crafting %s";
|
||||||
debounceTimeout = 10;
|
workspace_text = "Working on %s";
|
||||||
enableLineNumber = false;
|
enable_line_number = true;
|
||||||
|
buttons = [
|
||||||
blacklist = [ ];
|
{
|
||||||
fileAssets = null;
|
label = "GitHub";
|
||||||
showTime = true;
|
url = "https://github.com/username";
|
||||||
|
}
|
||||||
buttons = [ ];
|
];
|
||||||
|
blacklist = [
|
||||||
# Rich presence text options.
|
"NvimTree"
|
||||||
editingText = "Editing %s";
|
"alpha"
|
||||||
fileExplorerText = "Browsing %s";
|
];
|
||||||
gitCommitText = "Committing changes";
|
};
|
||||||
pluginManagerText = "Managing plugins";
|
|
||||||
readingText = "Reading %s";
|
|
||||||
workspaceText = "Working on %s";
|
|
||||||
lineNumberText = "Line %s out of %s";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue