Skip to content

Add or change file icons

vyfor edited this page Jun 24, 2024 · 7 revisions

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:

require('cord').setup {
  assets = {
    -- Configuration details here
  },
}

Icon Configuration Options

Key/Option Description Type Example
(key) The key can be a Vim filetype (like lua), a filename (like Cargo.toml), or a file extension (like .rs) String lua, Cargo.toml, .rs
icon The name of the rich presence asset (in case you use your own application) or a direct URL to the icon image String 'lua', 'https://example.com/rust.png'
tooltip Text that appears when hovering over the icon. Defaults to the icon name if this field is not specified String 'Managing dependencies'
name An optional override for the icon name. Redundant for language types String 'Lazy'
type Specifies the context of the asset (0 = language, 1 = file browser, 2 = plugin manager, 3 = lsp manager, 4 = vcs) Integer 0, 1, 2

Examples:

['.rs'] = 'rust_icon'
lazy = {
  name = 'Lazy', -- "Managing plugins in Lazy"
  icon = 'https://example.com/lazy.png',
  tooltip = 'lazy.nvim',
  type = 2
}

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 = {
  tooltip = '.lua file'  -- Overrides default tooltip only
}

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:

['Cord.new'] = 'default_icon'
['Cord.unknown'] = 'unknown_icon'
['Cord.override'] = 'rust' -- Rust... Rust everywhere...
Clone this wiki locally