Zed discord presence is an extension for Zed that adds support for Discord Rich Presence using LSP
Using LSP is a workaround for now (yeah, it's a bit hacky) but once Zed has proper extension support, I'll rewrite it.
rust is required for installing this extension.
The easiest way to get rust is by using rustup
Since zed-industries/extensions#1217 has been merged, you can simply download the extension in zed: extensions. Don't forget to give at least a ⭐ if you like this project :D
Dev installation
- Clone this repository
- CTRL + SHIFT + P and select zed: install dev extension
- Choose the directory where you cloned this repository
- Enjoy :)
You can configure state, details and git integration by changing Discord Presence LSP settings. This can be done in zed: open settings with following configuration:
The application_id is required for the rich presence to work. It should be kept as is unless you have a specific reason to change it.
The base_icons_url is the base URL for all language icons. This URL points to the location where the icons are stored.
"base_icons_url": "https://raw.githubusercontent.com/xhyrom/zed-discord-presence/main/assets/icons/"The state option allows you to set the state message displayed in Discord. You can use placeholders like {filename} which will be replaced with the current file name.
"state": "Working on {filename}"The details option allows you to set the details message displayed in Discord. You can use placeholders like {workspace} which will be replaced with the current workspace name.
"details": "In {workspace}"The large_image option specifies the URL for the large image displayed in Discord. You can use placeholders like {base_icons_url} and {language} which will be replaced accordingly.
The :lo modifier is used to convert the language name to lowercase.
"large_image": "{base_icons_url}/{language:lo}.png"The large_text option specifies the text displayed when hovering over the large image. You can use placeholders like {language} with the :u modifier to capitalize the first letter.
"large_text": "{language:u}"The small_image option specifies the URL for the small image displayed in Discord. You can use placeholders here as well.
"small_image": "{base_icons_url}/zed.png"The small_text option specifies the text displayed when hovering over the small image. You can use placeholders here as well.
"small_text": "Zed"The idle settings configure the behavior when you are inactive.
The timeout specifies the idle timeout in seconds (300 seconds = 5 minutes).
The action determines what happens when you go idle:
change_activitychanges the activity to idle with the specified detailsclear_activityhides the activity
The state, details, large_image, large_text, small_image, and small_text options specify the messages and images to display when idle. All of these can use placeholders.
"idle": {
"timeout": 300,
"action": "change_activity",
"state": "Idling",
"details": "In Zed",
"large_image": "{base_icons_url}/zed.png",
"large_text": "Zed",
"small_image": "{base_icons_url}/idle.png",
"small_text": "Idle"
}The rules option allows you to disable presence in specific workspaces. The mode can be set to blacklist
or whitelist, and the paths array should contain the absolute paths to apply the rule to.
"rules": {
"mode": "blacklist",
"paths": ["absolute path"]
}The git_integration option enables or disables Git integration. When enabled, the extension
will display a button to open the Git repository.
"git_integration": trueThe languages field allows you to override the default activity settings for specific languages.
Each key must be the language name in lowercase, and the value is an object containing options state, details, large_image, large_text, small_image and small_text. All of these can use placeholders.
"languages": {
"rust": {
"state": "Hacking on {filename}",
"details": "Rustacean at work",
"large_image": "{base_icons_url}/rust.png",
"large_text": "RUST !!!!",
"small_image": "{base_icons_url}/zed.png",
"small_text": "Zed"
},
"python": {
// haha i'm cool
"large_image": "{base_icons_url}/c.png",
"large_text": "C"
}
}If a language is not specified in the languages map, the default top-level activity settings will be used instead.
{
"lsp": {
"discord_presence": {
"initialization_options": {
// Application ID for the rich presence (don't touch it unless you know what you're doing)
"application_id": "1263505205522337886",
// Base URL for all language icons
"base_icons_url": "https://raw.githubusercontent.com/xhyrom/zed-discord-presence/main/assets/icons/",
"state": "Working on {filename}",
"details": "In {workspace}",
// URL for the large image
"large_image": "{base_icons_url}/{language:lo}.png", // :lo lowercase the language name
"large_text": "{language:u}", // :u capitalizes the first letter
// URL for the small image
"small_image": "{base_icons_url}/zed.png",
"small_text": "Zed",
// Idle settings - when you're inactive
"idle": {
"timeout": 300, // Idle timeout in seconds (300 seconds = 5 minutes)
// Action to take when idle
// `change_activity` - changes the activity to idle with the following details
// `clear_activity` - clears the activity (hides it)
"action": "change_activity",
"state": "Idling",
"details": "In Zed",
"large_image": "{base_icons_url}/zed.png",
"large_text": "Zed",
"small_image": "{base_icons_url}/idle.png",
"small_text": "Idle",
},
// Rules to disable presence in specific workspaces
"rules": {
"mode": "blacklist", // Can also be "whitelist"
"paths": ["absolute path"],
},
"git_integration": true,
// Per-language overrides
"languages": {
"rust": {
"state": "Hacking on {filename}",
"details": "Rustacean at work",
},
},
},
},
},
}You can also set any option to null to unset it, except for base_icons_url, rules, and git_integration.
You can use the following placeholders in your configuration:
{filename}- Current file name (e.g., "main.rs"){workspace}- Current workspace name (e.g., "my-project"){language}- Programming language (e.g., "rust"){base_icons_url}- Base URL for icons (from configuration){relative_file_path}- File path relative to workspace root (e.g., "src/main.rs"){folder_and_file}- Parent directory and file name (e.g., "src/main.rs"){directory_name}- Name of parent directory (e.g., "src"){full_directory_name}- Full path of parent directory (e.g., "/home/user/project/src")
Modifiers can be applied to any placeholder:
:u- Capitalizes the first letter (e.g.,{language:u}→ "Rust"):lo- Converts to lowercase (e.g.,{language:lo}→ "rust")
Example: "Working on {filename} in {directory_name:u}"