sponsor Vim development Vim logo Vim Book Ad

Popcorn : You can define your own pop-up menu.

 script karma  Rating 4/1, Downloaded by 587  Comments, bugs, improvements  Vim wiki

created by
Shuhei Kubota
 
script type
utility
 
description
Prerequisites:

- Vim9
- `+popupwin`


Usage:

:Popcorn

<normal mode>

- j, k: up, down
- h, l(enter): menu level (h: go up, l: go down)
- enter: execute
- q, esc: quit
- /: search mode
- upper case: search mode when g:PopcornSearchOnUpper

<search mode>

- ctrl-n, ctrl-p: up, down
- enter: execute
- esc: normal mode
- backspace, ctrl-h: backspace
- alpha nuberic: search


Customize:

```
# vim9script

g:PopcornItems = [
    {name: 'LSP', sub: [
        {name: 'Hover', execute: 'LspHover', default: true},
        {name: 'Definition', execute: 'LspDefinition'},
        {name: 'Rename', execute: 'LspRename'},
    ]},
    {name: 'Window', sub: [
        {name: 'Alt', executeeval: '"buffer " .. bufnr("#")', default: true},
        {name: '-'},
        {name: 'Split(--)', execute: 'split'},
        {name: 'Split(|)', execute: 'vsplit'},
    ]},
    {name: '-'},
    {name: 'Time', nameeval: 'strftime("%Y-%m-%d %H:%M:%S")', skip: true},
]
```

You can set menu items directly to g:PopcornItems.

You can also use g:Popcorn_clear(), g:Popcorn_add() and g:Popcorn_remove().


Rule:

1. Each item must have `name`
2. Must have one of (`execute`, `executeeval`, `sub`)
3. `nameeval` is eval()-ed when displayed (priority: `nameeval` > `name`)
4. `executeeval` is eval()-ed when executed (priority: `executeeval` > `execute`)
5. 'execute' (and 'executeeval') can be a string or a list of strings
6. 'default' item is executed when enter is pressed on its parent
7. A separator is {name: '-'}
8. 'skip' is true if the cursor skips the item

Highlights:

- g:PopcornGroupHighlight = 'Comment'
- g:PopcornSeparatorHighlight = 'Comment'
- g:PopcornSearchOnUpper = false


https://github.com/shu-vim/Popcorn
 
install details
Put this plugin in your plugin directory(e.g. $VIMRUNTIME/plugin).
Then restart Vim.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
popcorn.zip 0.5.2 2024-04-16 9.0 Shuhei Kubota * execute nested default item
* skipped items are highlighted Comment and centered
popcorn.zip 0.5.0 2024-04-14 9.0 Shuhei Kubota add skip
popcorn.zip 0.4.0 2023-10-23 9.0 Shuhei Kubota search mode
popcorn.zip 0.3.0 2023-10-21 9.0 Shuhei Kubota separator, highlights
popcorn.zip 0.2.0 2023-10-21 9.0 Shuhei Kubota 'execute' (and 'executeeval') can be a string or a list of strings.
popcorn.vim 0.1.0 2023-10-18 9.0 Shuhei Kubota Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github