robin/ivy
my custom neovim config
git clone https://git.robinwobin.dev/robin/ivy
4fb7125
main
1local function findfile ( fname ) 2local ftype =string . sub ( fname , - 1 ) == "/" and "directory" or "file" 3 4if fname : sub ( 0 , 1 ) == "/" then 5return fname 6end 7 8if ftype == "directory" then 9fname =fname : sub ( 0 , - 2 ) 10end 11 12local currentfile =vim . api . nvim_buf_get_name ( 0 ) 13local root =vim . fn . isdirectory ( currentfile ) == 1 and currentfile 14or vim . fs . dirname ( currentfile ) 15local stop =vim . fs . dirname ( vim . fn . getcwd ( 0 )) 16 17local matches =vim . fs . find ( fname , { 18type =ftype , 19upward =true , 20path =root , 21stop =stop , 22} ) 23if # matches > 0 then 24return matches [ 1 ] 25end 26 27return vim . fs . joinpath ( root , fname ) 28end 29vim . keymap . set ( "n" , "gf" , function () 30local fname =vim . fn . expand ( "<cfile>" ) 31---@cast fname string? 32if not fname then 33return 34end 35local path =findfile ( fname ) 36vim . cmd . edit ( { path , magic ={ file =false , bar =false } } ) 37end )