robin/ivy
my custom neovim config
git clone https://git.robinwobin.dev/robin/ivy
37c60ce
main
1if vim . g . loaded_guicursor then 2return 3end 4 5vim . g . loaded_guicursor =true 6 7local mode_lookup ={ 8normal ="n-v" , 9insert ="i-c-ci-ve" , 10replace ="r-cr" , 11operator ="o" , 12showmatch ="sm" , 13} 14 15local type_lookup ={ 16block ="block" , 17vertical ="ver" , 18horizontal ="hor" , 19} 20 21local function validate ( mode , opts ) 22vim . validate ( "mode" , mode , function ( v ) 23return vim . tbl_contains ( { "normal" , "insert" , "replace" , "operator" , "showmatch" } , v ) 24end , "valid mode" ) 25vim . validate ( "opts" , opts , function ( v ) 26vim . validate ( "type" , v . type , function ( t ) 27return vim . tbl_contains ( { "block" , "vertical" , "horizontal" } , t ) 28end , "valid type" ) 29if v . type ~= "block" then 30vim . validate ( "size" , v . size , function ( s ) 31return type ( s ) == "number" 32end , "valid size with type ~= block" ) 33end 34 35vim . validate ( "animate" , v . animate , function ( anim ) 36vim . validate ( "wait" , anim . wait , "number" ) 37vim . validate ( "on" , anim . on , "number" ) 38vim . validate ( "off" , anim . off , "number" ) 39return true 40end , true , "valid animation" ) 41 42return true 43end , "valid opts" ) 44end 45 46vim . once ( function () 47if not vim . g . guicursor_config or vim . tbl_isempty ( vim . g . guicursor_config ) then 48return 49end 50 51local guicursorset =vim 52. iter ( pairs ( vim . g . guicursor_config )) 53: map ( function ( mode , opts ) 54validate ( mode , opts ) 55 56local s =string . format ( 57"%s:%s" , 58mode_lookup [ mode ], 59opts . type ~= "block" and string . format ( "%s%d" , type_lookup [ opts . type ], opts . size ) or type_lookup [ opts . type ] 60) 61 62if opts . animate then 63local anim =opts . animate 64local anim_str =string . format ( "blinkwait%d-blinkon%d-blinkoff%d" , anim . wait , anim . on , anim . off ) 65s =s .. "-" .. anim_str 66end 67 68return s 69end ) 70: totable () 71 72vim . opt . guicursor =table . concat ( guicursorset , "," ) .. ",a:Cursor/lCursor" 73end )