aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/utils.vim5
1 files changed, 3 insertions, 2 deletions
diff --git a/autoload/utils.vim b/autoload/utils.vim
index 8ea37d3..34ba3fc 100644
--- a/autoload/utils.vim
+++ b/autoload/utils.vim
@@ -44,8 +44,9 @@ endfunction
" Generate random integers in the range [Low, High] in pure vimscrpt,
" adapted from https://stackoverflow.com/a/12739441/6064933
function! utils#RandInt(Low, High) abort
- let l:milisec = str2nr(matchstr(reltimestr(reltime()), '\v\.\zs\d+'), 10)
- return l:milisec % (a:High - a:Low + 1) + a:Low
+ " Use lua to generate random int. It is faster. Ref: https://stackoverflow.com/a/20157671/6064933
+ call luaeval('math.randomseed(os.time())')
+ return luaeval(printf('math.random(%s, %s)', a:Low, a:High))
endfunction
" Custom fold expr, adapted from https://vi.stackexchange.com/a/9094/15292