Skip to content

kamykn/popup-menu.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

popup-menu.nvim

1 Installation

vim-plug

Plug 'kamykn/popup-menu.nvim'

NeoBundle

NeoBundle 'kamykn/popup-menu.nvim'

2 Usage

2.1 Simple usage

" This is a sample callback function
function! s:callback(selected) abort
	echo a:selected
endfunction

let list = ['aaa', 'bbb', 'ccc', 'ddd', 'eee']
call popup_menu#open(list, {selected -> s:my_callback(selected)})

2.2 Floating window options

It can use 3rd argument as same settings as nvim_open_win().

call popup_menu#open(
		\ list,
		\ {selected -> s:my_callback(selected)},
		\ {
		\ 	'relative': 'editor',
		\ 	'width': 30,
		\ 	'height': 7,
		\ 	'col': 5,
		\ 	'row': 5
		\ })

2.3 Sample of popup-menu.nvim with using popup_menu() of Vim8

" list for popup menu.
let list = [apple, banana, orange]

if exists('*popup_menu')
    " Vim
    let callback_fn = {win_id, index -> s:my_callback_idx(index)}
    call popup_menu(list, #{
        \ callback: callback_fn,
        \ ...
        \ })
elseif has('nvim') && exists('g:loaded_popup_menu_plugin')
    " Neovim
    " g:loaded_popup_menu_plugin is defined by popup-menu.nvim.
    let callback_fn = {selected_str -> s:my_callback_str(selected_str)}
    call popup_menu#open(list, callback_fn)
else
    " Old vim/neovim
    let index = inputlist(...)
    call s:my_callback_idx(index)
endif

2.4 Style

The style is same as PMenu and PMenuSel. However, only ctermbg and ctermfg are used.

" sample settings
hi Pmenu ctermfg=254 ctermbg=237 cterm=NONE guifg=#e1e1e1 guibg=#383838 gui=NONE
hi PmenuSel ctermfg=135 ctermbg=239 cterm=NONE guifg=#b26eff guibg=#4e4e4e gui=NONE

About

Popup-menu for Neovim!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published