Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions .github/wiki/Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,4 @@
```bash
git clone https://github.com/vyfor/cord.nvim
```
2. Build the server binary and place it under the Neovim data directory
**Linux:**
```bash
cargo install --path . --root ~/.local/share/nvim/cord --force
```

**Windows (PowerShell):**
```powershell
cargo install --path . --root $env:LOCALAPPDATA/nvim-data/cord --force
```
2. Build the server binary using `:Cord update build` which will place the built binary under the Neovim data directory
63 changes: 46 additions & 17 deletions .github/wiki/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ If you want a fresh start, you can copy the default config and tweak it. I sugge
display = {
theme = 'default',
flavor = 'dark',
view = 'full',
swap_fields = false,
swap_icons = false,
},
Expand Down Expand Up @@ -118,6 +119,7 @@ If you want a fresh start, you can copy the default config and tweak it. I sugge
timeout = 300000,
},
discord = {
pipe_paths = nil,
reconnect = {
enabled = false,
interval = 5000,
Expand Down Expand Up @@ -166,12 +168,20 @@ With this option set to true, the plugin **will not start automatically**. Inste
| --------------------- | --------- | --------- | --------------------------------------------------------------------------- |
| `display.theme` | `string` | `default` | Choose between different icon themes; 'default', 'atom', 'catppuccin' |
| `display.flavor` | `string` | `dark` | Choose between different theme flavors; typically 'dark', 'light', 'accent' |
| `display.view` | `string` | `full` | Control what shows up as the large and small images |
| `display.swap_fields` | `boolean` | `false` | Show workspace name before filename |
| `display.swap_icons` | `boolean` | `false` | Use editor icon as large image |

>[!TIP]
> [!TIP]
> Check out our icon [showcase](https://github.com/vyfor/icons#showcase)!

### View

- `full` - always shows both of the icons
- `editor` - only shows the editor icon
- `asset` - only shows the asset (language, file browser, plugin manager, etc.) icon
- `auto` - shows both icons, but drops the language icon if in a new/empty buffer

## ⏰ Timestamp

| Option | Type | Default | Description |
Expand All @@ -190,7 +200,7 @@ With this option set to true, the plugin **will not start automatically**. Inste
| `idle.show_status` | `boolean` | `true` | Show idle status in presence, or hide the presence if `false` |
| `idle.ignore_focus` | `boolean` | `true` | Show idle despite Neovim having focus |
| `idle.unidle_on_focus` | `boolean` | `true` | Unidle the session when Neovim gains focus |
| `idle.smart_idle` | `boolean` | `true` | Enable [smart idle](#smart-idle) feature |
| `idle.smart_idle` | `boolean` | `true` | Enable smart idle feature. See below |
| `idle.details` | `string \| function(opts)` | `'Idling'` | Details shown when idle |
| `idle.state` | `string \| function(opts)` | `nil` | State shown when idle |
| `idle.tooltip` | `string \| function(opts)` | `'💤'` | Tooltip shown when hovering over idle icon |
Expand Down Expand Up @@ -376,20 +386,38 @@ require('cord').setup {

## ⚙️ Advanced

| Option | Type | Default | Description |
| ------------------------------------- | --------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `advanced.plugin.autocmds` | `boolean` | `true` | Enable autocmds |
| `advanced.plugin.cursor_update` | `string` | `'on_hold'` | When to update cursor position: `'on_move'`, `'on_hold'`, or `'none'`. See [Cursor Update Mode](#cursor-update-mode) |
| `advanced.plugin.match_in_mappings` | `boolean` | `true` | Whether to match against file extensions in mappings |
| `advanced.server.update` | `string` | `'fetch'` | Default way to acquire the server executable either if the executable is not found or a manual update is requested: `'fetch'` - fetch from GitHub, `'build'` - build from source, `'none'` - no-op |
| `advanced.server.pipe_path` | `string \| nil` | `nil` | Custom IPC pipe path |
| `advanced.server.executable_path` | `string \| nil` | `nil` | Custom server executable path |
| `advanced.server.timeout` | `number` | `300000` | Server shutdown timeout (ms) |
| `advanced.discord.reconnect.enabled` | `boolean` | `false` | Whether reconnection is enabled. Has minimal impact on performance |
| `advanced.discord.reconnect.interval` | `number` | `5000` | Reconnection interval in milliseconds, 0 to disable |
| `advanced.discord.reconnect.initial` | `boolean` | `true` | Whether to reconnect if initial connection fails |
| `advanced.workspace.root_markers` | `string[]` | `string[]` | List of root markers to use when determining the workspace directory |
| `advanced.workspace.limit_to_cwd` | `boolean` | `false` | Limits workspace detection to the working directory (vim.fn.getcwd()). When true, workspace detection stops at the CWD if no marker is found, making the search more efficient |
### Plugin Settings

| Option | Type | Default | Description |
| ----------------------------------- | --------- | ----------- | -------------------------------------------------------------------------------------------------------------------- |
| `advanced.plugin.autocmds` | `boolean` | `true` | Enable autocmds |
| `advanced.plugin.cursor_update` | `string` | `'on_hold'` | When to update cursor position: `'on_move'`, `'on_hold'`, or `'none'`. See [Cursor Update Mode](#cursor-update-mode) |
| `advanced.plugin.match_in_mappings` | `boolean` | `true` | Whether to match against file extensions in mappings |

### Server Settings

| Option | Type | Default | Description |
| --------------------------------- | --------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `advanced.server.update` | `string` | `'fetch'` | Default way to acquire the server executable either if the executable is not found or a manual update is requested: `'fetch'` - fetch from GitHub, `'install'` - install from crates.io, `'build'` - build from source, `'none'` - no-op |
| `advanced.server.pipe_path` | `string \| nil` | `nil` | Custom IPC pipe path |
| `advanced.server.executable_path` | `string \| nil` | `nil` | Custom server executable path |
| `advanced.server.timeout` | `number` | `300000` | Server shutdown timeout (ms) |

### Discord Settings

| Option | Type | Default | Description |
| ------------------------------------- | ---------- | ------- | ------------------------------------------------------------------ |
| `advanced.discord.pipe_paths` | `string[]` | `nil` | Custom IPC pipe paths to use when connecting to Discord |
| `advanced.discord.reconnect.enabled` | `boolean` | `false` | Whether reconnection is enabled. Has minimal impact on performance |
| `advanced.discord.reconnect.interval` | `number` | `5000` | Reconnection interval in milliseconds, 0 to disable |
| `advanced.discord.reconnect.initial` | `boolean` | `true` | Whether to reconnect if initial connection fails |

### Workspace Settings

| Option | Type | Default | Description |
| --------------------------------- | ---------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `advanced.workspace.root_markers` | `string[]` | `string[]` | List of root markers to use when determining the workspace directory |
| `advanced.workspace.limit_to_cwd` | `boolean` | `false` | Limits workspace detection to the working directory (vim.fn.getcwd()). When true, workspace detection stops at the CWD if no marker is found, making the search more efficient |

### Cursor Update Mode

Expand Down Expand Up @@ -424,7 +452,8 @@ The `advanced.cursor_update_mode` option controls how cursor position updates ar
- `:Cord update` - Update the server executable using the configured update mode (fetch by default)
- `:Cord update check` - Check for server updates
- `:Cord update fetch` - Fetch the server executable from GitHub using `curl`
- `:Cord update build` - Build the server executable using `cargo`
- `:Cord update install` - Install the server executable from crates.io using `cargo`
- `:Cord update build` - Build the server executable locally using `cargo`
- `:Cord status` - Show connection status
- `:Cord version` - Show current server version
- `:Cord restart` - Restart the server
Expand Down
4 changes: 2 additions & 2 deletions .github/wiki/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require 'cord'.setup {
}
```

2. Set the `CORD_LOG_FILE` environment variable to a file path. This will redirect all logs to that file, but note that doing so will bypass the `log_level` setting and log everything. This is useful for debugging as trace and debug logs can be very verbose and overwhelming in the editor.
1. Set the `CORD_LOG_FILE` environment variable to a file path. This will redirect all logs to that file. This is useful for debugging as trace and debug logs can be very verbose and overwhelming in the editor.

> ### Q: Can I use a custom name in my Rich Presence?

Expand All @@ -44,7 +44,7 @@ Cord's server keeps running intentionally. In fact, this is one of the key desig

> ### Q: I'm using a custom Discord client. Will Cord work with it?

Yes, although we do not endorse custom clients, and cannot guarantee that they will work. The main issue is that custom clients often cannot/do not expose the IPC pipe at the same path as the official client, so you might need to create a symlink to make it work.
Yes, although we do not endorse custom clients, and cannot guarantee that they will work. The main issue is that custom clients often cannot/do not expose the IPC pipe at the same path as the official client, so you might need to create a symlink to make it work. You can also override the defaults by setting the `advanced.discord.pipe_paths` field to a list of absolute paths to use when connecting to Discord.

> ### Q: Is X plugin or X language supported?

Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
> Cord no longer requires Rust to be installed. Server component will be automatically downloaded from GitHub Releases.

## 💎 Features
- ⚡ Fast, lightweight, and batteries-included.
- 🚀 Event-based architecture with instant presence updates.
- ⚡ Fast, lightweight, and batteries included.
- 🚀 Event-driven architecture with instant presence updates.
- 🎨 Dynamic string templates with custom variables.
- 🗃️ Customizable assets for any file/buffer type.
- 🔧 Flexible configuration with rich API, function-based fields, hook system and user commands.
- 🔧 Flexible configuration with rich API, function-based fields, hooks, user commands and support for custom IPC paths.
- 🔌 Plugin system of its own, with many plugins out-of-the-box.
- 🛠️ Finds repositories and workspaces based on VCS files without relying on command-line tools.
- 🧠 Manages activities across all instances with a single connection to Discord.
Expand Down Expand Up @@ -121,9 +121,15 @@ Invoke `:Cord update` whenever the plugin is updated.
<details>
<summary><strong>Considerations</strong></summary>

Cord requires the server executables to be present. By default, the plugin automatically fetches them from GitHub, which requires a dependency on [**`curl`**](https://curl.se). Alternatively, either:
- **Download from GitHub**: Get latest release from https://github.com/vyfor/cord.nvim/releases/latest, rename it to cord[.exe] and place it under `nvim-data-dir/cord/bin`
- [**Build from source**](https://github.com/vyfor/cord.nvim/wiki/Build)
Cord requires the **server executable** to be present. By default, the plugin automatically fetches it from GitHub, which requires a dependency on [**`curl`**](https://curl.se).

Alternatively, you can provide the executable manually:

- **Download from GitHub:**
Get the latest release from [https://github.com/vyfor/cord.nvim/releases/latest](https://github.com/vyfor/cord.nvim/releases/latest), rename it to `cord` (or `cord.exe` on Windows), and place it under `nvim-data-dir/cord/bin`. This is essentially what `:Cord update fetch` does.

- **Build from source:**
Run `:Cord update install` to install from crates.io or `:Cord update build` to build from source locally.

</details>

Expand Down
10 changes: 8 additions & 2 deletions lua/cord/api/command.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
local M = {}

M.build = function()
require('cord.core.async').run(function() require('cord.server.update').build():await() end)
M.install = function()
require('cord.core.async').run(function() require('cord.server.update').install():await() end)
end
M.fetch = function()
require('cord.core.async').run(function() require('cord.server.update').fetch():await() end)
end
M.build = function()
require('cord.core.async').run(function() require('cord.server.update').build():await() end)
end
M.update = function()
local mode = require('cord.plugin.config').advanced.server.update

if mode == 'fetch' then
M.fetch()
elseif mode == 'install' then
M.install()
elseif mode == 'build' then
M.build()
elseif mode ~= 'none' then
Expand Down Expand Up @@ -198,6 +203,7 @@ M.commands = {
subcommands = {
check = M.check,
fetch = M.fetch,
install = M.install,
build = M.build,
},
},
Expand Down
3 changes: 3 additions & 0 deletions lua/cord/api/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local validation_rules = {
['display'] = { 'table' },
['display.theme'] = { 'string' },
['display.flavor'] = { 'string' },
['display.view'] = { 'string' },
['display.swap_fields'] = { 'boolean' },
['display.swap_icons'] = { 'boolean' },

Expand Down Expand Up @@ -81,6 +82,7 @@ local validation_rules = {
['advanced.server.executable_path'] = { 'string' },
['advanced.server.timeout'] = { 'number' },
['advanced.discord'] = { 'table' },
['advanced.discord.pipe_paths'] = { 'table' },
['advanced.discord.reconnect'] = { 'table' },
['advanced.discord.reconnect.enabled'] = { 'boolean' },
['advanced.discord.reconnect.interval'] = { 'number' },
Expand All @@ -93,6 +95,7 @@ local validation_rules = {
local array_paths = {
['buttons'] = true,
['plugins'] = true,
['advanced.discord.pipe_paths'] = true,
['advanced.workspace.root_markers'] = true,
}

Expand Down
Loading