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
42 changes: 27 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ With a minimal `lazy.nvim` / `packer.nvim` setup, Neovim loads the plugin from `
| `:ClipRing` | Always available (no keymap required) |
| Your `open_mapping` | After you set one in `setup()` (e.g. `<leader>y`) |

The picker opens as two side-by-side floats: a wide **history list** (newest first, one line per entry with register type `c` / `l` / `b`) and a narrower **preview pane** showing the selected yank with real line breaks (up to `preview_max_lines`).
The picker opens as two side-by-side floats when there are yanks to show: a **history list** (height follows entry count) and a **preview pane** that resizes to fit the selected entry. With an empty ring, only the list is shown.

### Inside the picker

Expand Down Expand Up @@ -93,21 +93,22 @@ With `persist = true`, history is restored after you restart Neovim (stored unde

```lua
require("clipring").setup({
max_entries = 100, -- max items in ring
persist = false, -- save history to disk
-- Ring
max_entries = 100,
persist = false,
persist_path = vim.fn.stdpath("data") .. "/clipring/history.json",
preview_length = 80, -- chars shown per line in popup
deduplicate = true, -- move duplicates to top instead of re-adding
min_length = 1, -- ignore yanks shorter than this (chars)
open_mapping = "<leader>y", -- string, list of strings, or false (nil = no keymap)
reorder_down_mapping = "<C-j>", -- picker: move entry down in history (false to disable)
reorder_up_mapping = "<C-k>", -- picker: move entry up in history (false to disable)
copy_mapping = "y", -- picker: copy to system clipboard (false to disable)
picker_width = 80, -- total inner width of list + preview (0 = editor width minus margin)
list_width = 0, -- history list columns (0 = remaining width after preview)
preview_max_width = 80, -- max width of the preview pane (columns)
picker_max_height = 18, -- max height of both floats (lines)
preview_max_lines = 16, -- max lines shown per entry in the preview pane
deduplicate = true,

-- Open & picker keys
open_mapping = "<leader>y",
reorder_down_mapping = "<C-j>",
reorder_up_mapping = "<C-k>",
copy_mapping = "y",

-- Layout (list and preview auto-size within these limits)
picker_width = 80, -- total inner width; 0 = nearly full editor width
picker_max_height = 18, -- max height for list and preview
preview_max_lines = 16, -- max lines per entry in the preview pane
})
```

Expand All @@ -119,6 +120,17 @@ Copy uses Neovim’s `+` and `*` registers (and the unnamed `"` register). You n

If `<C-j>` / `<C-k>` conflict with global maps (e.g. `:move`), use different keys: `reorder_down_mapping = "<A-j>"`.

### Advanced

```lua
require("clipring").setup({
min_length = 1, -- ignore yanks shorter than this (chars)
preview_length = 80, -- max chars in each one-line list label
preview_max_width = 120, -- cap preview width; 0 = up to screen edge (default)
list_width = 0, -- fixed list width in columns; 0 = auto (recommended)
})
```

## Tests

Specs run on every push to `main` and on pull requests via [GitHub Actions](https://github.com/alexesba/clipring.nvim/actions/workflows/test.yml).
Expand Down
10 changes: 5 additions & 5 deletions lua/clipring/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ local M = {}
---@field max_entries number
---@field persist boolean
---@field persist_path string
---@field preview_length number
---@field preview_length number max chars in each one-line list label
---@field deduplicate boolean
---@field min_length number
---@field open_mapping string|string[]|false|nil keymap(s) to open picker (`nil` = `:ClipRing` only)
---@field reorder_down_mapping string|false|nil move selected entry down in picker (default `<C-j>`)
---@field reorder_up_mapping string|false|nil move selected entry up in picker (default `<C-k>`)
---@field copy_mapping string|false|nil copy selected entry to system clipboard in picker (default `y`)
---@field picker_width number total inner width of list + preview (`0` = nearly full editor width)
---@field list_width number width of the history list (columns; `0` = fill space not used by preview)
---@field preview_max_width number max width of the preview pane (columns)
---@field picker_max_height number max height of picker windows (lines)
---@field list_width number width of the history list (`0` = auto; fixed width is advanced)
---@field preview_max_width number max preview width (`0` = content width up to screen edge)
---@field picker_max_height number max height of list and preview panes (lines)
---@field preview_max_lines number max lines shown in the preview pane for one entry

M.defaults = {
Expand All @@ -30,7 +30,7 @@ M.defaults = {
copy_mapping = "y",
picker_width = 80,
list_width = 0,
preview_max_width = 80,
preview_max_width = 0,
picker_max_height = 18,
preview_max_lines = 16,
}
Expand Down
Loading