Skip to content

Instantly share code, notes, and snippets.

@rbtnn
Created November 20, 2019 14:23
Show Gist options
  • Save rbtnn/d8f03f572f6765d5c0567e25f6d56b9d to your computer and use it in GitHub Desktop.
Save rbtnn/d8f03f572f6765d5c0567e25f6d56b9d to your computer and use it in GitHub Desktop.
function! s:main() abort
call popup_menu(['aaa', 'bbb', 'ccc'], {
\ 'filter' : function('s:filter'),
\ 'callback' : function('s:callback'),
\ })
endfunction
function! s:filter(id, key) abort
if a:key == 't'
" タブページで開くフラグを設定して、
" スペースが押されたようにして閉じる。
call setwinvar(a:id, 'open_tabpage', 1)
return popup_filter_menu(a:id, ' ')
else
return popup_filter_menu(a:id, a:key)
endif
endfunction
function! s:callback(id, key) abort
if -1 != a:key
if getwinvar(a:id, 'open_tabpage', 0)
" tキーが押された時の挙動
tabnew
else
" スペースキーが押された時の挙動
new
endif
else
" Ctrl-Cでキャンセルした場合の挙動
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment