Dialogs & Pickers
Build confirmation, input, quick-pick, menu, and multi-select interactions in coc.nvim extensions.
Dialogs & Pickers
Dialogs are floating windows or popups that respond to user input. Neovim can focus and click bottom buttons; Vim popup buttons are activated with their highlighted shortcut character.
Choose the right API
| Need | API | Result |
|---|---|---|
| Custom text and buttons | window.showDialog() | Dialog or null; callback index is -1 on close. |
| Yes/no confirmation | window.showPrompt() | boolean. |
| Text input | window.requestInput() | Entered text; falls back to Vim input() when dialogs are unavailable. |
| Filterable single/multi choice | window.showQuickPick() | Selected item(s) or undefined. |
| Cursor-position menu | window.showMenuPicker() | Zero-based index, or -1 on cancel. |
| Centered multi-select | window.showPickerDialog() | Selected item(s), or undefined. |
Basic dialog
| 1 | import { window } from 'coc.nvim' |
| 2 | |
| 3 | await window.showDialog({ |
| 4 | title: 'Apply edits?', |
| 5 | content: 'Three files will be changed.', |
| 6 | buttons: [{ index: 0, text: 'Apply' }, { index: 1, text: 'Cancel' }], |
| 7 | callback: index => { |
| 8 | if (index === 0) window.showInformationMessage('Applied') |
| 9 | } |
| 10 | }) |
Confirm and input
window.showPrompt() uses <Esc>/n to reject and y to accept. window.requestInput() accepts with <CR> and cancels with <Esc>; Neovim insert-mode mappings can still apply inside its floating input.
Quick Pick
window.showQuickPick() provides fuzzy filtering and can return one or many QuickPickItem values. Use createQuickPick() only when you need lower-level lifecycle and input events.
| 1 | const item = await window.showQuickPick(['Vim', 'Neovim'], { |
| 2 | title: 'Choose an editor', |
| 3 | placeHolder: 'Type to filter', |
| 4 | }) |
Menu and picker keys
Menus and pickers accept <CR>, cancel with <Esc>/<C-c>, move with j/k, arrows, <Tab>/<S-Tab>, and <C-n>/<C-p>, and scroll with <C-f>/<C-b>. Picker dialogs use <Space> to toggle selection.
Configuration
Search dialog settings for confirm keys, rounded borders, maximum size, picker buttons, shortcuts, and highlight groups.
Source of truth: :h coc-dialog and the TypeScript API.