Created
November 20, 2019 14:23
-
-
Save rbtnn/d8f03f572f6765d5c0567e25f6d56b9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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