2024-02-28 18:37:44 +01:00
# ![presence.nvim](https://gist.githubusercontent.com/andweeb/df3216345530234289b87cf5080c2c60/raw/8de399cfed82c137f793e9f580027b5246bc4379/presence.nvim.png)
2023-09-28 22:34:52 +02:00
2024-04-20 01:56:37 +02:00
A Discord [Rich Presence ](https://discord.com/rich-presence ) plugin for [Neovim ](https://neovim.io )
2021-03-01 18:34:30 +01:00
2024-02-28 18:37:44 +01:00
**[Features](#features)** | ** [Installation ](#installation )** |
**[Configuration](#configuration)** | ** [Troubleshooting ](#troubleshooting )** |
**[Development](#development)** | ** [Contributing ](#contributing )**
2021-05-06 08:18:04 +02:00
2021-03-01 18:34:30 +01:00
2024-02-28 18:37:44 +01:00
![Presence demo ](https://gist.githubusercontent.com/andweeb/df3216345530234289b87cf5080c2c60/raw/ad916fec8de921d0021801a0af877a5349621e7e/presence-demo-a.gif )
2021-03-01 18:34:30 +01:00
2024-04-20 01:56:37 +02:00
< h2 align = "center" > Stats< / h2 >
< p align = "center" >
< img alt = "Conventional Commits" src = "https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org" >
< / p >
< p align = "center" >
< img alt = "GitHub Repo stars" src = "https://img.shields.io/github/stars/jiriks74/presence.nvim" >
< img alt = "GitHub forks" src = "https://img.shields.io/github/forks/jiriks74/presence.nvim" >
< / p >
< p align = "center" >
< img alt = "GitHub last commit" src = "https://img.shields.io/github/last-commit/jiriks74/presence.nvim" >
< img alt = "GitHub repo size" src = "https://img.shields.io/github/repo-size/jiriks74/presence.nvim" >
< img alt = "GitHub License" src = "https://img.shields.io/github/license/jiriks74/presence.nvim" >
< / p >
< p align = "center" >
< img alt = "Open Issues" src = "https://img.shields.io/github/issues-raw/jiriks74/presence.nvim" ? label = Open Issues " >
< img alt = "Closed Issues" src = "https://img.shields.io/github/issues-closed-raw/jiriks74/presence.nvim" ? label = Closed Issues " >
< / p >
< p align = "center" >
< img alt = "Luacheck Workflow Status" src = "https://img.shields.io/github/actions/workflow/status/jiriks74/presence.nvim/luacheck.yml?label=Luacheck" >
< img alt = "StyLua Workflow status" src = "https://img.shields.io/github/actions/workflow/status/jiriks74/presence.nvim/stylua.yml?label=StyLua" >
< / p >
2021-03-01 18:34:30 +01:00
## Features
2023-09-28 22:19:36 +02:00
- Light and unobtrusive
- No Python/Node providers (or CoC) required
2024-04-20 01:56:37 +02:00
- Cross-platform support: macOS, nixOS, Linux
2023-09-28 22:19:36 +02:00
Windows, WSL
2024-02-28 18:37:44 +01:00
- Startup time is fast(er than other Rich Presence plugins, by
2024-04-19 23:52:15 +02:00
[kind of a lot ](https://github.com/jiriks74/presence.nvim/wiki/Plugin-Comparisons ))
2023-09-28 22:19:36 +02:00
- Written in Lua and [highly configurable ](#configuration ) 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!
2021-03-01 18:34:30 +01:00
## Installation
2023-09-28 22:19:36 +02:00
2024-04-19 23:52:15 +02:00
> [!Note]
>
> Requires [Neovim 0.5](https://github.com/neovim/neovim/releases/tag/v0.5.0)
> or higher
2021-03-01 18:34:30 +01:00
Use your favorite plugin manager
2023-09-28 22:19:36 +02:00
- [vim-plug ](https://github.com/junegunn/vim-plug ): `Plug 'jiriks74/presence.nvim'`
- [packer.nvim ](https://github.com/wbthomason/packer.nvim ): `use 'jiriks74/presence.nvim'`
- [lazy.nvim ](https://github.com/folke/lazy.nvim ):
```lua
{
"jiriks74/presence.nvim",
event = "UIEnter",
},
```
2024-04-19 23:52:15 +02:00
Rich Presence should work automatically after installation
2023-09-28 22:19:36 +02:00
2024-04-19 23:52:15 +02:00
> [!Important]
>
> If you're using WSL1 there's additional setup needed.
> WSL2 **is not supported** but ***may*** work.
> [**See Wiki**](https://github.com/jiriks74/presence.nvim/wiki/Rich-Presence-in-WSL))
2021-03-01 18:34:30 +01:00
## Configuration
2023-09-28 22:19:36 +02:00
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:
2021-03-01 18:34:30 +01:00
### Lua
2023-09-28 22:19:36 +02:00
Require the plugin and call `setup` with a config table with one or more of the
following keys:
2021-03-01 18:34:30 +01:00
```lua
2021-05-20 07:38:26 +02:00
-- The setup config table shows all available config options with their default values:
2023-01-29 10:21:17 +01:00
require("presence").setup({
2021-05-20 07:38:26 +02:00
-- 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")
2023-11-09 15:59:42 +01:00
client_id = "1172122807501594644", -- Use your own Discord application client id (not recommended)
2021-05-20 07:38:26 +02:00
log_level = nil, -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error")
2021-05-22 21:46:41 +02:00
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
2021-08-11 04:51:57 +02:00
blacklist = {}, -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches
2024-05-14 15:33:20 +02:00
blacklist_repos = {}, -- A blacklist that applies to git remote repo URLs instead of folder/file names
2021-08-10 08:17:37 +02:00
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)
2022-01-16 07:47:49 +01:00
file_assets = {}, -- Custom file asset definitions keyed by file names and extensions (see default config at `lua/presence/file_assets.lua` for reference)
2022-09-10 01:04:11 +02:00
show_time = true, -- Show the timer
2021-05-20 07:38:26 +02:00
-- Rich Presence text options
2021-10-19 07:12:44 +02:00
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)
2021-03-01 18:34:30 +01:00
})
```
### VimL
2023-09-28 22:19:36 +02:00
2021-03-01 18:34:30 +01:00
Or if global variables are more your thing, you can use any of the following instead:
2023-09-28 22:19:36 +02:00
2021-03-01 18:34:30 +01:00
```viml
2021-05-20 07:38:26 +02:00
" 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"
2023-11-09 15:59:42 +01:00
let g:presence_client_id = "1172122807501594644"
2021-03-01 18:34:30 +01:00
let g:presence_log_level
2021-05-22 21:46:41 +02:00
let g:presence_debounce_timeout = 10
let g:presence_enable_line_number = 0
2021-08-08 08:28:03 +02:00
let g:presence_blacklist = []
2024-05-14 15:33:20 +02:00
let g:presence_blacklist_repos = []
2021-08-11 04:51:57 +02:00
let g:presence_buttons = 1
2022-01-16 09:06:15 +01:00
let g:presence_file_assets = {}
2022-09-10 01:04:11 +02:00
let g:presence_show_time = 1
2021-05-20 07:38:26 +02:00
" Rich Presence text options
let g:presence_editing_text = "Editing %s"
2021-05-20 08:23:15 +02:00
let g:presence_file_explorer_text = "Browsing %s"
2021-05-20 07:38:26 +02:00
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"
2021-05-22 21:46:41 +02:00
let g:presence_line_number_text = "Line %s out of %s"
2021-03-01 18:34:30 +01:00
```
2021-05-06 08:18:04 +02:00
## Troubleshooting
2023-09-28 22:19:36 +02:00
- 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
- Set the [`log_level` ](#lua ) setup option or [`g:presence_log_level` ](#viml )
to `"debug"`
- Load a file and inspect the logs with `:messages`
- If there is a `Failed to determine Discord IPC socket` error, your particular
OS may not yet be supported
2024-02-28 18:37:44 +01:00
- If you don't see an existing
[issue ](https://github.com/jiriks74/presence.nvim/issues )
2023-09-28 22:19:36 +02:00
or [card ](https://github.com/jiriks74/presence.nvim/projects/1#column-14183588 )
2024-02-28 18:37:44 +01:00
for your OS, create a prefixed
[issue ](https://github.com/jiriks74/presence.nvim/issues/new )
2023-09-28 22:19:36 +02:00
(e.g. `[Void Linux]` )
2024-02-28 18:37:44 +01:00
- Still not working and need help? Create a new
[issue ](https://github.com/jiriks74/presence.nvim/issues )!
2021-05-14 04:57:38 +02:00
## Development
2023-09-28 22:19:36 +02:00
- Clone the repo: `git clone https://github.com/jiriks74/presence.nvim.git`
2024-04-18 18:52:51 +02:00
- Enable [logging ](#configuration ) and ensure that `presence.nvim` is **not**
2023-09-28 22:19:36 +02:00
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`
2024-04-18 18:52:51 +02:00
- Make sure that your contribution follows
[CONTRIBUTING.md ](https://github.com/jiriks74/presence.nvim/blob/main/CONTRIBUTING.md )
guidelines before creating a PR.
2021-05-06 08:18:04 +02:00
2021-03-01 18:34:30 +01:00
## Contributing
2024-04-18 18:52:51 +02:00
**Please read [CONTRIBUTING.md ](https://github.com/jiriks74/presence.nvim/blob/main/CONTRIBUTING.md )
before creating a PR or an issue.**
2023-09-29 01:57:42 +02:00
2023-09-28 22:19:36 +02:00
Pull requests are very welcome, feel free to open an issue to work on
2024-04-18 18:52:51 +02:00
or [message me directly (@jiriks74) ](https://discordapp.com/users/517810049360461837 )
on my [Discord server ](https://discord.gg/cCq3qcB4jB )!