1
0
Fork 0
mirror of https://github.com/jiriks74/presence.nvim synced 2024-12-27 02:22:36 +01:00
Discord Rich Presence for Neovim
Find a file
jiriks74 c850b9e245
All checks were successful
StyLua / StyLua (push) Successful in 2m3s
Luacheck / Luacheck (push) Successful in 21s
Revert "fix(ci): Use submodules for actions"
Breaks `lazy.nvim` because of the submodules

Fixes https://github.com/jiriks74/presence.nvim/issues/67

This reverts commit 8117a074d5.
2024-12-13 03:33:59 +01:00
.github Revert "fix(ci): Use submodules for actions" 2024-12-13 03:33:59 +01:00
autoload Re-add BufEnter autocmd and handle tmux bug 2021-06-07 20:03:19 -07:00
lua feat(files): Add Typst (#65) 2024-10-07 16:49:52 +02:00
plugin Move autocmd to autoload and validate setup opts 2021-01-03 11:29:19 -08:00
.envrc feat(nix): Add basic nix environment (#49) 2024-04-17 19:05:07 +02:00
.gitignore feat(nix): Add basic nix environment (#49) 2024-04-17 19:05:07 +02:00
.luacheckrc Update README and luacheckrc 2021-05-13 19:57:38 -07:00
CONTRIBUTING.md feat(docs): Add contributin guidelines (#51) 2024-04-18 18:52:51 +02:00
default.nix feat(nix): Add basic nix environment (#49) 2024-04-17 19:05:07 +02:00
LICENSE Create LICENSE 2024-04-20 00:33:20 +02:00
README.md feat: Blacklist repositories (#41) 2024-05-14 15:33:20 +02:00

presence.nvim

A Discord Rich Presence plugin for Neovim

Features | Installation | Configuration | Troubleshooting | Development | Contributing

Presence demo

Stats

Conventional Commits

GitHub Repo stars GitHub forks

GitHub last commit GitHub repo size GitHub License

Open Issues Closed Issues

Luacheck Workflow Status StyLua Workflow status

Features

  • Light and unobtrusive
  • No Python/Node providers (or CoC) required
  • Cross-platform support: macOS, nixOS, Linux Windows, WSL
  • Startup time is fast(er than other Rich Presence plugins, by kind of a lot)
  • Written in Lua and highly configurable in Lua (but also configurable in VimL if you want)
  • Manages Rich Presence across multiple Neovim instances in various environments (tmux panes/windows, ssh sessions, terminal tabs/windows, etc.)
  • Now with Flatpak support!

Installation

Note

Requires Neovim 0.5 or higher

Use your favorite plugin manager

{
  "jiriks74/presence.nvim",
  event = "UIEnter",
},

Rich Presence should work automatically after installation

Important

If you're using WSL1 there's additional setup needed. WSL2 is not supported but may work. See Wiki)

Configuration

Configuration is not necesary unless you want to override the default config.

If you want to change the default config here are your options in Lua and VimL:

Lua

Require the plugin and call setup with a config table with one or more of the following keys:

-- The setup config table shows all available config options with their default values:
require("presence").setup({
    -- 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   = "The One True Text Editor", -- Text displayed when hovered over the Neovim image
    main_image          = "neovim",                   -- Main image display (either "neovim" or "file")
    client_id           = "1172122807501594644",       -- 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           = {},                         -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches
    blacklist_repos     = {},                         -- A blacklist that applies to git remote repo URLs instead of folder/file names
    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)
})

VimL

Or if global variables are more your thing, you can use any of the following instead:

" General options
let g:presence_auto_update         = 1
let g:presence_neovim_image_text   = "The One True Text Editor"
let g:presence_main_image          = "neovim"
let g:presence_client_id           = "1172122807501594644"
let g:presence_log_level
let g:presence_debounce_timeout    = 10
let g:presence_enable_line_number  = 0
let g:presence_blacklist           = []
let g:presence_blacklist_repos     = []
let g:presence_buttons             = 1
let g:presence_file_assets         = {}
let g:presence_show_time           = 1

" Rich Presence text options
let g:presence_editing_text        = "Editing %s"
let g:presence_file_explorer_text  = "Browsing %s"
let g:presence_git_commit_text     = "Committing changes"
let g:presence_plugin_manager_text = "Managing plugins"
let g:presence_reading_text        = "Reading %s"
let g:presence_workspace_text      = "Working on %s"
let g:presence_line_number_text    = "Line %s out of %s"

Troubleshooting

  • Ensure that Discord is running
  • Ensure that your Neovim version is 0.5 or higher
  • Ensure Game Activity is enabled in your Discord settings
  • Enable logging and inspect the logs after opening a buffer
  • If there is a Failed to determine Discord IPC socket error, your particular OS may not yet be supported
    • If you don't see an existing issue or card for your OS, create a prefixed issue (e.g. [Void Linux])
  • Still not working and need help? Create a new issue!

Development

  • Clone the repo: git clone https://github.com/jiriks74/presence.nvim.git
  • Enable logging and ensure that presence.nvim is not in the list of vim plugins in your config
  • Run nvim with your local changes: nvim --cmd 'set rtp+=path/to/your/local/presence.nvim' file.txt
  • Make sure that your contribution follows CONTRIBUTING.md guidelines before creating a PR.

Contributing

Please read CONTRIBUTING.md before creating a PR or an issue.

Pull requests are very welcome, feel free to open an issue to work on or message me directly (@jiriks74) on my Discord server!