Deprecated. Please use guider.nvim
popup.vim可以让vim在底部弹出你自己定义的菜单,并通过按键触发相应的命令。
演示视频:
call popup#reg('window', pmenu#new('Window & Buffer',
\ ['o:', 'New tabpage', 'tabe'],
\ ['x:', 'Close tabpage', 'tabc'],
\ ['p!', 'Prev tabpage', 'gT'],
\ ['n!', 'Next tabpage', 'gt'],
\ '------------------------------',
\ ['w', 'Wipe', "\<c-w>\<c-u>"],
\ ['s:', 'Resize', 'call ResizeWindow()'],
\ ['c', 'Copy buffer', "ggVGy:bot sp ene!\<cr>Vp"]
\ ))
call popup#reg('util#n', pmenu#new('Util',
\ [' ', 'Common', [
\ ["\t:", 'NERDTreeToggle', 'NERDTreeToggle'],
\ ["\r:", 'NERDTreeFind', 'NERDTreeFind'],
\ [' !', 'No hilight', ":noh\<cr>"],
\ ['.!', 'Do last command', '@:'],
\ ['l', 'Open URL', 'gx'],
\ ]],
\ ["\t:", 'Tools', [
\ ['c', 'cmd.exe', "call open#cmd()"],
\ ['b', 'bash', "call open#bash()"],
\ ['d', 'File directory', "call open#curdir()"],
\ ['r', 'Reopen vim', "call open#reopen()"],
\ ['e', 'Explorer', "call open#explorer(expand('%:p'))"],
\ ['.', 'File under cursor', "call open#cur_file()"],
\ [',', 'Bash', has('nvim') ? 'winc s | term bash': 'terminal bash'],
\ ]],
\ ))
More documents: Popup's doc
nmap <expr><m-f> popup#('file')
nmap <expr><space> popup#('util')
" 只为特定的buffer绑定
nmap <buffer><expr><m-,> popup#('mdutil')
map <expr><m-.> popup#last()