Skip to content

Commit

Permalink
make discord presence templateable
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef Hofer committed Nov 11, 2024
1 parent deb6ffc commit 796a630
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 36 deletions.
44 changes: 41 additions & 3 deletions hosts/shared/programs/editor/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, vars, ... }:
let
# Filter out lazy-lock.json from the source directory
nvimConfigFiltered = lib.cleanSourceWith {
Expand All @@ -8,6 +8,7 @@ let
in baseName != "lazy-lock.json";
};
treeSitterWithAllGrammars = pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars);
nvim.discord.blacklist = vars.nvim.discord.blacklist or "";
in
{
# Packages you also want to outside use outside of nvim
Expand Down Expand Up @@ -66,14 +67,51 @@ in
];
};

# Copy your Neovim configuration
xdg.configFile = {
# Copy the filtered nvim configuration directory
"nvim" = {
source = nvimConfigFiltered;
recursive = true;
};
};

# Discord Rich Presence Configuration
"nvim/lua/plugins/presence.lua" = {
text = ''
return {
-- add symbols-outline
{
"andweeb/presence.nvim",
-- cmd = "SymbolsOutline",
lazy = true,
event = "VeryLazy",
-- keys = { { "<leader>cs", "<cmd>SymbolsOutline<cr>", desc = "Symbols Outline" } },
opts = {
-- General options
auto_update = true, -- Update activity based on autocmd events (if `false`, map or manually execute `:lua package.loaded.presence:update()`)
neovim_image_text = "How do I exit this?", -- Text displayed when hovered over the Neovim image
main_image = "file", -- Main image display (either "neovim" or "file")
client_id = "793271441293967371", -- Use your own Discord application client id (not recommended)
log_level = nil, -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error")
debounce_timeout = 10, -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(<filename>, true)`)
enable_line_number = false, -- Displays the current line number instead of the current project
blacklist = { "${toString nvim.discord.blacklist}" }, -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches
buttons = true, -- Configure Rich Presence button(s), either a boolean to enable/disable, a static table (`{{ label = "<label>", url = "<url>" }, ...}`, or a function(buffer: string, repo_url: string|nil): table)
file_assets = {}, -- Custom file asset definitions keyed by file names and extensions (see default config at `lua/presence/file_assets.lua` for reference)
show_time = true, -- Show the timer
-- Rich Presence text options
editing_text = "Editing %s", -- Format string rendered when an editable file is loaded in the buffer (either string or function(filename: string): string)
file_explorer_text = "Browsing %s", -- Format string rendered when browsing a file explorer (either string or function(file_explorer_name: string): string)
git_commit_text = "Committing changes", -- Format string rendered when committing changes in git (either string or function(filename: string): string)
plugin_manager_text = "Managing plugins", -- Format string rendered when managing plugins (either string or function(plugin_manager_name: string): string)
reading_text = "Reading %s", -- Format string rendered when a read-only or unmodifiable file is loaded in the buffer (either string or function(filename: string): string)
workspace_text = "Working on %s", -- Format string rendered when in a git repository (either string or function(project_name: string|nil, filename: string): string)
line_number_text = "Line %s out of %s", -- Format string rendered when `enable_line_number` is set to true (either string or function(line_number: number, line_count: number): string)
},
},
}
'';
};

home.file = {
# Ensure the .local/share/nvim directory exists with correct permissions
Expand Down
33 changes: 0 additions & 33 deletions hosts/shared/programs/editor/nvim/lua/plugins/discord-presence.lua

This file was deleted.

0 comments on commit 796a630

Please sign in to comment.