1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

refactor: load colorschemes randomly

In Emacs, there is `seq-random-elt` which randomly selects an element from
a sequence. We mimic it here in Neovim.

Ref: https://www.gnu.org/software/emacs/manual/html_node/elisp/Sequence-Functions.html.
This commit is contained in:
jdhao
2021-10-15 23:20:35 +08:00
parent b4f58504a7
commit 421111f474
2 changed files with 19 additions and 4 deletions

View File

@@ -49,6 +49,13 @@ function! utils#RandInt(Low, High) abort
return v:lua.math.random(a:Low, a:High)
endfunction
" Selection a random element from a sequence/list
function! utils#RandElement(seq) abort
let l:idx = utils#RandInt(0, len(a:seq)-1)
return a:seq[l:idx]
endfunction
" Custom fold expr, adapted from https://vi.stackexchange.com/a/9094/15292
function! utils#VimFolds(lnum) abort
" get content of current line and the line below