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, and more) as a rich presence on Discord.
- 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.
- Improve customization. (wip, added ability to change the action placeholder and better image handling)
- Fix change state not becoming viewing state after exiting insert mode. (added a view timer, after 1 minute of detecting no changes it will switch to viewing)
- Add diagnostics to the discord activity, best guess (zk way): refreshDiagnosticsOfDocument
- Go (version 1.21 or higher)
- Git
- Discord (with Rich Presence enabled)
-
Clone the Repository
git clone https://github.com/zerootoad/discord-rpc-lsp.git cd discord-rpc-lsp
-
Initialize Go module
go mod init github.com/zerootoad/discord-rpc-lsp
-
Download Dependencies
go mod tidy
-
Build the Project
go build
-
Run the LSP Server
./discord-rpc-lsp
This LSP works with any editor that supports the Language Server Protocol (LSP). Below are instructions for a few popular editors.
-
Install a plugin like nvim-lspconfig if you don't already have it.
-
Add the following configuration to your
init.lua
:local lspconfig = require('lspconfig') local configs = require('lspconfig.configs') configs.discord_rpc = { default_config = { cmd = { "path/to/discord-rpc-lsp" }, filetypes = {"*"}, -- Add relevant filetypes if needed root_dir = function(fname) return lspconfig.util.root_pattern('.git')(fname) or vim.fn.getcwd() end, settings = {}, }, }
-
Replace
path/to/discord-rpc-lsp
with the actual path to the built binary.
-
Open your
languages.toml
file (usually located at~/.config/helix/languages.toml
for linux). -
Add the following configuration:
[language-server.discord-rpc] command = "path/to/discord-rpc-lsp"
-
Replace
path/to/discord-rpc-lsp
with the actual path to the built binary. -
Add
"discord-rpc"
for the choosen languages:[[language]] name = "go" # or any language of choice language-servers = [ "discord-rpc" ]
For other editors, refer to their documentation on how to configure LSP servers. The process is similar: specify the path to the discord-rpc-lsp
binary in your editor's LSP configuration.
Configuration is done by editing the config.toml
file located in the configuration directory. The configuration directory is automatically created in the following locations based on your operating system:
- Unix-based systems (Linux, macOS):
~/.discord-rpc-lsp/
- Windows:
%APPDATA%\Roaming\.discord-rpc-lsp\
Make sure to make reference to the discord rich presence documentation for the fields. discord rpc docs
By default, if the config.toml file does not exist, it will be created with the following default values:
[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, if no workspace was found u it will use the fallback_details.
details = 'In {workspace}'
fallback_details = 'In {editor}'
# 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").
timeout = '5m'
[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'
Before opening an issue make sure to check for these known problems:
- cant see "show repository button": refer to this existing issue #3
If you'd like to add custom assets (e.g., editor icons), follow these steps:
- Add your asset (e.g.,
my-editor.png
) to theassets/icons/
directory via a pull request. - Wait for the repository maintaners to merge it.
Contributions are welcome! If you'd like to contribute, please:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request.
This project is licensed under the GNU 3.0 License. See the LICENSE file for details.
- zed-discord-presence for bare understanding and implementation.
- rich-go for Discord Rich Presence.
- glsp lsp stuff
- LSP Specification for the LSP implementation.