Skip to content

Commit

Permalink
docs: update wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Jan 10, 2025
1 parent 2bf334e commit 019b467
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 9 deletions.
74 changes: 74 additions & 0 deletions .github/wiki/Add-or-change-file-icons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
## Configuration Structure

Cord allows the customization of the appearance of a file icon. To do so, you need to modify the `assets` table in the setup configuration of the plugin:

```lua
require('cord').setup {
assets = {
-- key: string = value: string or table
},
}
```

## Icon Configuration Options

| Option | Type | Description |
| ----------- | ----------------- | ------------------------------------------------------------------------------------------------------------ |
| **(key)** | `string` | The key can be a Vim filetype (like `lua`), a filename (like `Cargo.toml`), or a file extension (like `.rs`) |
| **(value)** | `string \| table` | This can either be a string pointing to the icon or a table with options below |
| `icon` | `string` | A direct URL to the icon image or the name of the rich presence asset (in case you use your own application) |
| `tooltip` | `string` | Text that appears when hovering over the icon |
| `name` | `string` | An optional override for the icon name. Redundant for `language` types |
| `text` | `string` | An optional override for the icon text. Unlike other options, this will fully override the text |
| `type` | `string` | Specifies the context of the asset. |

Available types:
- `language` (default)
- `docs`
- `plugin_manager`
- `lsp_manager`
- `file_browser`
- `vcs`
- `workspace`
- `dashboard`
- `notes`

**Examples**:
```lua
['.rs'] = 'rust_icon'
```
```lua
lazy = {
name = 'Lazy', -- `config.text.plugin_manager + name` = "Managing plugins in Lazy"
icon = 'https://example.com/lazy.png',
tooltip = 'lazy.nvim',
type = 'plugin_manager'
}
```
> Use Cord's existing icon
```lua
['.settings'] = require('cord.api.icon').get('gear') -- or { icon = require(...) }
```
> In the below configuration, only the tooltip for Lua files is changed, while the icon and name remain as provided by Cord's defaults.
```lua
lua = {
-- Overrides default tooltip and text only
tooltip = '.lua file',
text = 'Writing in Lua' -- `config.text.editing` is ignored
}
```

## Overriding Default Icons

In addition to setting icons for specific filetypes or extensions, you can also define icons for generic scenarios:

- `['Cord.new']`: Sets the icon for a new buffer when Neovim is opened without any file arguments.
- `['Cord.unknown']`: Used when the filetype is not detected by the editor or not supported in Cord at the moment.
- `['Cord.override']`: Overrides all of the existing icons.

**Example**:
```lua
['Cord.new'] = 'default_icon'
['Cord.unknown'] = 'unknown_icon'
['Cord.override'] = 'rust' -- Rust... Rust everywhere...
```
19 changes: 10 additions & 9 deletions .github/wiki/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,22 @@ require('cord').setup {

### Text Options

The `text` table supports both static strings and functions for dynamic content:
The `text` table supports both static strings and functions for dynamic content. These are simplified placeholders, the default configuration uses a function to dynamically set the context.

```lua
text = {
editing = function(opts)
return string.format('Editing %s', opts.filename)
end,
viewing = 'Viewing a file', -- Simple string with filename placeholder
file_browser = 'Browsing files', -- Shown in file explorer
plugin_manager = 'Managing plugins', -- Shown in plugin manager
lsp_manager = 'Configuring LSP', -- Shown in LSP manager
docs = 'Reading docs', -- Shown in help buffers
vcs = 'Committing changes', -- Shown in VCS related filetypes
notes = 'Taking notes', -- Shown in notes-taking related filetypes
dashboard = 'Home', -- Shown in dashboard buffers
viewing = 'Viewing a file', -- Simple string with filename placeholder
file_browser = 'Browsing files', -- Shown in file explorer
plugin_manager = 'Managing plugins', -- Shown in plugin manager
lsp_manager = 'Configuring LSP', -- Shown in LSP manager
docs = 'Reading docs', -- Shown in help buffers
vcs = 'Committing changes', -- Shown in VCS related filetypes
notes = 'Taking notes', -- Shown in notes-taking related filetypes
dashboard = 'Home', -- Shown in dashboard buffers
workspace = 'Workspace: ${workspace_name}', -- `variables` must be set in order to use string templates `${}`
}
```

Expand Down
9 changes: 9 additions & 0 deletions .github/wiki/Home.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Welcome to the **cord.nvim** wiki!

- [Migration from v1](Migration.md)
- [Configuration](Configuration.md)
- [Examples](Examples.md)
- [Add or change file icons](Add-or-change-file-icons.md)
- [FAQ](FAQ.md)
- [Troubleshooting](Troubleshooting.md)
- [Contributing](Contributing.md)
42 changes: 42 additions & 0 deletions .github/wiki/Troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 🔧 Troubleshooting

### Rich Presence is not shown in Discord
1. Ensure that `cord.nvim` is loaded (try running a user command, e.g. `:Cord status`)
2. Confirm that your Activity Privacy settings are [enabled](https://github.com/vyfor/cord.nvim/assets/92883017/c0c8c410-e90e-425e-bf10-8b59f04f15ce)
3. Set [`advanced.plugin.log_level`](./Configuration.md#️-advanced) to `vim.log.levels.TRACE` and check `:messages` for logs
4. Verify that the Discord IPC pipe exists:

**Windows:**
```pwsh
Test-Path \\.\pipe\discord-ipc-0
```

**Unix:**
```sh
find /tmp /var/run /run -type s -name 'discord-ipc-*' 2>/dev/null
```

### No buttons are shown in the Rich Presence
- After the recent UI update related to user profiles, there's a client-sided bug on Discord where you yourself can't see the buttons on your own rich presence. You can either join a voice channel and hover over it to see the buttons, or ask somebody else to confirm if they can see them

### Rich Presence timer is stuck at 00:00
- This issue is usually resolved by syncing your system date and timezone

### Running inside WSL
- WSL doesn't expose Windows pipes by default. In order to do so, install [socat](https://www.kali.org/tools/socat) and [npiperelay](https://github.com/jstarks/npiperelay/), then alias nvim to expose the pipe as done in this [guide](https://gist.github.com/mousebyte/af45cbecaf0028ea78d0c882c477644a#aliasing-nvim):
> ```sh
> nvim () {
> pidof socat > /dev/null 2>&1
> if ! $? -eq 0; then
> socat UNIX-LISTEN:/tmp/discord-ipc-0,fork \
> EXEC:"npiperelay.exe //./pipe/discord-ipc-0"&
> fi
> command nvim "$@"
> }
> ```
### Running on a remote server
- Expose the Discord IPC socket over SSH using this [guide](https://carlosbecker.com/posts/discord-rpc-ssh/)
### Is your issue not listed?
- Please open a new [issue](https://github.com/vyfor/cord.nvim/issues/new/choose)

0 comments on commit 019b467

Please sign in to comment.