Skip to content

Instantly share code, notes, and snippets.

@heavenshell
Created March 11, 2016 16:27
Show Gist options
  • Save heavenshell/e6cf261d28bf8ead9a9f to your computer and use it in GitHub Desktop.
Save heavenshell/e6cf261d28bf8ead9a9f to your computer and use it in GitHub Desktop.
let s:save_cpo = &cpo
set cpo&vim
function! s:rand(list)
let s:choice = ''
py << endpy
def _choice(l):
import random
import vim
ret = random.choice(l)
vim.command('let s:choice = "%s"' % ret)
endpy
python _choice(vim.eval('a:list'))
return s:choice
endfunction
function! Zundoko()
let success = 'ズンズンズンズンドコ'
let zundoko = ['ズン', 'ドコ']
let zd = []
while 1
let word = s:rand(zundoko)
call add(zd, word)
if join(zd, '') == success
break
endif
if len(zd) == 5
let zd = []
endif
endwhile
echomsg printf('%s キ・ヨ・シ!', success)
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment