https://github.com/zerootoad/discord-rpc-lsp
A Language Server Protocol (LSP) to share your discord rich presence.
https://github.com/zerootoad/discord-rpc-lsp
discord discord-presence discord-rich-presence go golang helix nvim
Last synced: about 2 months ago
JSON representation
A Language Server Protocol (LSP) to share your discord rich presence.
- Host: GitHub
- URL: https://github.com/zerootoad/discord-rpc-lsp
- Owner: zerootoad
- License: gpl-3.0
- Created: 2025-03-16T11:42:06.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-04-09T12:53:48.000Z (8 months ago)
- Last Synced: 2025-04-09T13:43:53.649Z (8 months ago)
- Topics: discord, discord-presence, discord-rich-presence, go, golang, helix, nvim
- Language: Go
- Homepage:
- Size: 4.22 MB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Discord Rich Presence LSP
A Language Server Protocol (LSP) to share what you're coding on Discord. This LSP integrates with your editor to display your current coding activity (file, language, Git info, etc.) as a rich presence on Discord.


---
## Features
* Displays the file you're currently editing.
* Shows the programming language you're using.
* Includes Git repository information (branch and remote URL).
* Customizable rich presence with editor-specific icons.
* Supports multiple editors via LSP.
---
## TODO
* [x] Implement zerolog for logging.
* [x] Create tagged releases on GitHub (e.g., v1.0.0).
* [ ] Improve project code.
* [ ] Improve customization options.
---
## Installation
### Prerequisites
* Go 1.21+
* Git
* Discord (with Rich Presence enabled)
---
### Linux
**AUR (Arch/Manjaro)**
```bash
yay -S discord-rpc-lsp-git
```
**Manual via Go**
```bash
go install github.com/zerootoad/discord-rpc-lsp@latest
```
Binary installs to `$(go env GOPATH)/bin` (usually `~/go/bin`). Add to PATH:
```bash
export PATH=$PATH:$(go env GOPATH)/bin
```
---
### macOS
**Manual via Go**
```bash
go install github.com/zerootoad/discord-rpc-lsp@latest
```
Binary installs to `$(go env GOPATH)/bin` (usually `~/go/bin`). Add to PATH:
```bash
export PATH=$PATH:$(go env GOPATH)/bin
```
---
### Windows
**Manual via Go**
```powershell
go install github.com/zerootoad/discord-rpc-lsp@latest
```
Binary installs to `%USERPROFILE%\go\bin`. Add this to your **Environment Variables → PATH**.
---
### Build from Source (Optional)
```bash
git clone https://github.com/zerootoad/discord-rpc-lsp.git
cd discord-rpc-lsp
go mod tidy
go build
```
Run the server:
```bash
# Linux/macOS
./discord-rpc-lsp
# Windows
discord-rpc-lsp.exe
```
---
## Adding to Editors
### Supported Editors
This LSP works with any editor that supports the Language Server Protocol (LSP).
---
### Neovim
1. Install `nvim-lspconfig`.
2. Add to your `init.lua`:
```lua
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
if not configs.discord_rpc then
configs.discord_rpc = {
default_config = {
cmd = { "discord-rpc-lsp" }, -- Make sure this is in your PATH
filetypes = { "*" }, -- Attach to all filetypes
root_dir = function(fname)
return lspconfig.util.root_pattern('.git')(fname) or vim.loop.cwd()
end,
settings = {},
},
}
end
lspconfig.discord_rpc.setup({
on_attach = function(client, bufnr)
print("DiscordRPC started!")
end,
})
```
---
### Helix
`~/.config/helix/languages.toml`:
```toml
[language-server.discord-rpc]
command = "discord-rpc-lsp" # full path if needed
[[language]]
name = "go"
language-servers = ["discord-rpc"]
[[language]]
name = "python"
language-servers = ["discord-rpc"]
```
Add additional languages as needed.
---
## Configuration
Configuration is done via `config.toml` in the configuration directory:
* **Linux/macOS:** `~/.discord-rpc-lsp/`
* **Windows:** `%APPDATA%\Roaming\.discord-rpc-lsp\`
Default configuration includes:
```toml
[discord]
# Custom Discord Application ID for the Rich Presence.
# This is optional, as the lsp handles it based on the editor being used.
application_id = ''
# Determines what is displayed in the small icon.
# Valid values: "language" or "editor".
small_usage = 'language'
# Determines what is displayed in the large icon.
# Valid values: "language" or "editor".
large_usage = 'editor'
# retry_after is the duration to wait before retrying in case it fails to create the discord rpc client.
# Must be a valid duration string (e.g., "1m", "30s").
retry_after = '1m'
[discord.activity]
# The discord activity is customizable via placeholders.
#
# List of avaible placeholder:
# {action} : holds the action being executed, can be customized below.
# {filename} : holds the name of current file.
# {workspace} : holds the workspace name.
# {editor} : holds the editor name (e.g., "helix", "neovim")
# {language} : holds the language name of the current file.
# These 3 fields define the {action} placeholder based on the current action.
idle_action = 'Idle in {workspace}'
view_action = 'Viewing {filename}'
edit_action = 'Editing {filename}'
# state is the first line of the activity status.
state = '{action}'
# Details hold the current workspace.
details = 'In {workspace}'
# OPTIONAL: field only fill it if u would like to overwrite the default picked one. (MUST BE A URL TAKING TO THE IMAGE)
large_image = ''
# Large icon text for when u hover over it.
large_text = '{editor}'
# OPTIONAL: field only fill it if u would like to overwrite the default picked one. (MUST BE A URL TAKING TO THE IMAGE)
small_image = ''
# Small icon text for when u hover over it.
small_text = 'Coding in {language}'
# If true, the time since the activity started will be shown.
timestamp = true
# If true, additional information on the file being edited will be shown
editing_info = true
[git]
# If true, will show the repository and branch information
git_info = true
[lsp]
# The duration after which the LSP will enable idling if no activity is detected.
# Must be a valid duration string (e.g., "5m", "30s").
idle_after = '5m'
# The duration after which the editing mode will go in viewing if no changes are applied.
# Must be a valid duration string (e.g., "5m", "30s").
view_after = '30s'
# This indicates how much u should offset the line for, this is a fix incase ur line index isnt right.
# Must be a valid expression ("+1", "+ 2", "-3", "- 4").
# If ur line is off by one, change this to "+0" or "-0".
line_offset = '+1'
[language_maps]
# The URL to a JSON file containing mappings of file extensions to programming languages.
url = 'https://raw.githubusercontent.com/zerootoad/discord-rich-presence-lsp/main/assets/languages.json'
[logging]
# level is the logging level.
# Valid values: "debug", "info", "warn", "error".
# Make sure to use debug if you're sumbitting an issue.
level = 'info'
# output is the output destination for logs.
# Valid values: "file" (logs to a file) or "stdout" (logs to the console).
output = 'file'
```
---
## Known Issues
1. “Show repository” button may not appear: check [issue #3](https://github.com/zerootoad/discord-rpc-lsp/issues/3).
2. issues with the package: "github.com/tliron/kutil/terminal". Please refer to [issue #6](https://github.com/zerootoad/discord-rpc-lsp/issues/6)
3. LSP exiting/not working: check editor logs and LSP output logs for runtime errors and open an issue.
---
## Assets
To add custom assets (icons, etc.):
1. Add your asset to `assets/icons/`.
2. Open a pull request.
3. Wait for merge.
---
## Contributing
1. Fork the repository.
2. Create a branch for your feature or bugfix.
3. Submit a pull request.
---
## License
GNU 3.0 License — see [LICENSE](LICENSE).
---
## Resources
* [zed-discord-presence](https://github.com/xHyroM/zed-discord-presence)
* [rich-go](https://github.com/hugolgst/rich-go)
* [glsp](https://github.com/tliron/glsp)
* [LSP Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/)
---