Home

Awesome

<img src="https://github.com/echasnovski/media/blob/main/mini.nvim/logo/logo_pick.png" style="width: 100%"> <!-- badges: start -->

GitHub license

<!-- badges: end -->

Pick anything

See more details in Features and help file.


⦿ This is a part of mini.nvim library. Please use this link if you want to mention this module.

⦿ All contributions (issues, pull requests, discussions, etc.) are done inside of 'mini.nvim'.

⦿ See the repository page to learn about common design principles and configuration recipes.


If you want to help this project grow but don't know where to start, check out contributing guides of 'mini.nvim' or leave a Github star for 'mini.nvim' project and/or any its standalone Git repositories.

Demo

https://github.com/echasnovski/mini.nvim/assets/24854248/65849d1e-3f96-4085-a4cf-f9962cfdbdfd

Features

Notes:

Read more information, see these tags in help file:

Dependencies

For full experience needs (still works without any of suggestions):

Overview

General idea is to take array of objects, display them with interactive filter/sort/navigate/preview, and allow to choose one or more items.

How to start a picker

User interface

UI consists from a single window capable of displaying three different views:

Current prompt is displayed (in Neovim>=0.9) at the top left of the window border with vertical line indicating caret (current input position).

Bottom part of window border displays (in Neovim>=0.10) extra visual feedback:

When picker is busy (like if there are no items yet set or matching is active) window border changes color to be MiniPickBorderBusy after config.delay.busy milliseconds of idle time.

Life cycle

Installation

This plugin can be installed as part of 'mini.nvim' library (recommended) or as a standalone Git repository.

There are two branches to install from:

Here are code snippets for some common installation methods (use only one):

<details> <summary>With <a href="https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-deps.md">mini.deps</a></summary> <table> <thead> <tr> <th>Github repo</th> <th>Branch</th> <th>Code snippet</th> </tr> </thead> <tbody> <tr> <td rowspan=2>'mini.nvim' library</td> <td>Main</td> <td rowspan=2><i>Follow recommended 'mini.deps' installation</i></td> </tr> <tr> <td>Stable</td> </tr> <tr> <td rowspan=2>Standalone plugin</td> <td>Main</td> <td><code>add('echasnovski/mini.pick')</code></td> </tr> <tr> <td>Stable</td> <td><code>add({ source = 'echasnovski/mini.pick', checkout = 'stable' })</code></td> </tr> </tbody> </table> </details> <details> <summary>With <a href="https://github.com/folke/lazy.nvim">folke/lazy.nvim</a></summary> <table> <thead> <tr> <th>Github repo</th> <th>Branch</th> <th>Code snippet</th> </tr> </thead> <tbody> <tr> <td rowspan=2>'mini.nvim' library</td> <td>Main</td> <td><code>{ 'echasnovski/mini.nvim', version = false },</code></td> </tr> <tr> <td>Stable</td> <td><code>{ 'echasnovski/mini.nvim', version = '*' },</code></td> </tr> <tr> <td rowspan=2>Standalone plugin</td> <td>Main</td> <td><code>{ 'echasnovski/mini.pick', version = false },</code></td> </tr> <tr> <td>Stable</td> <td><code>{ 'echasnovski/mini.pick', version = '*' },</code></td> </tr> </tbody> </table> </details> <details> <summary>With <a href="https://github.com/junegunn/vim-plug">junegunn/vim-plug</a></summary> <table> <thead> <tr> <th>Github repo</th> <th>Branch</th> <th>Code snippet</th> </tr> </thead> <tbody> <tr> <td rowspan=2>'mini.nvim' library</td> <td>Main</td> <td><code>Plug 'echasnovski/mini.nvim'</code></td> </tr> <tr> <td>Stable</td> <td><code>Plug 'echasnovski/mini.nvim', { 'branch': 'stable' }</code></td> </tr> <tr> <td rowspan=2>Standalone plugin</td> <td>Main</td> <td><code>Plug 'echasnovski/mini.pick'</code></td> </tr> <tr> <td>Stable</td> <td><code>Plug 'echasnovski/mini.pick', { 'branch': 'stable' }</code></td> </tr> </tbody> </table> </details> <br>

Important: don't forget to call require('mini.pick').setup() to enable its functionality.

Note: if you are on Windows, there might be problems with too long file paths (like error: unable to create file <some file name>: Filename too long). Try doing one of the following:

Default config

-- No need to copy this inside `setup()`. Will be used automatically.
{
  -- Delays (in ms; should be at least 1)
  delay = {
    -- Delay between forcing asynchronous behavior
    async = 10,

    -- Delay between computation start and visual feedback about it
    busy = 50,
  },

  -- Keys for performing actions. See `:h MiniPick-actions`.
  mappings = {
    caret_left  = '<Left>',
    caret_right = '<Right>',

    choose            = '<CR>',
    choose_in_split   = '<C-s>',
    choose_in_tabpage = '<C-t>',
    choose_in_vsplit  = '<C-v>',
    choose_marked     = '<M-CR>',

    delete_char       = '<BS>',
    delete_char_right = '<Del>',
    delete_left       = '<C-u>',
    delete_word       = '<C-w>',

    mark     = '<C-x>',
    mark_all = '<C-a>',

    move_down  = '<C-n>',
    move_start = '<C-g>',
    move_up    = '<C-p>',

    paste = '<C-r>',

    refine        = '<C-Space>',
    refine_marked = '<M-Space>',

    scroll_down  = '<C-f>',
    scroll_left  = '<C-h>',
    scroll_right = '<C-l>',
    scroll_up    = '<C-b>',

    stop = '<Esc>',

    toggle_info    = '<S-Tab>',
    toggle_preview = '<Tab>',
  },

  -- General options
  options = {
    -- Whether to show content from bottom to top
    content_from_bottom = false,

    -- Whether to cache matches (more speed and memory on repeated prompts)
    use_cache = false,
  },

  -- Source definition. See `:h MiniPick-source`.
  source = {
    items = nil,
    name  = nil,
    cwd   = nil,

    match   = nil,
    show    = nil,
    preview = nil,

    choose        = nil,
    choose_marked = nil,
  },

  -- Window related options
  window = {
    -- Float window config (table or callable returning it)
    config = nil,

    -- String to use as cursor in prompt
    prompt_cursor = '▏',

    -- String to use as prefix in prompt
    prompt_prefix = '> ',
  },
}

Similar plugins