robin/lynn.nvim
native-first neovim plugin manager with charm
git clone https://git.robinwobin.dev/robin/lynn.nvim
a8dc88a
main
1local utils ={} 2 3local aliases ={ 4[ "github" ] ="https://github.com" , 5[ "gitlab" ] ="https://gitlab.com" , 6[ "srht" ] ="https://git.sr.ht" , 7[ "codeberg" ] ="https://codeberg.org" , 8} 9 10---@param str string 11---@return string 12function utils . norm_url ( str ) 13local s , n =string . gsub ( str , "%w+:" , function ( s ) 14local m , repl =vim . iter ( pairs ( aliases )): find ( function ( v , _ ) 15return ( v .. ":" ) == s 16end ) 17if not m then 18return 19end 20return repl .. "/" 21end , 1 ) 22if n == 0 then 23return utils . norm_url ( "github:" .. s ) 24end 25local protocol =string . match ( s , "^(%w+)://" ) 26if protocol == "git" and string . sub ( s , - 4 ) ~= ".git" then 27s =s .. ".git" 28end 29 30return s 31end 32 33---@param str string 34---@return string 35function utils . norm_name ( str ) 36do 37local m =string . match ( str , "^n?vim[-](.+)" ) 38if m then 39str =m 40end 41end 42do 43local m =string . match ( str , "(.+)%.n?vim$" ) 44if not m then 45m =string . match ( str , "(.+)[.-]lua$" ) 46end 47if m then 48str =m 49end 50end 51return str 52end 53 54---@param url string 55---@return string 56function utils . get_name ( url ) 57local bud =string . match ( url , "([^/]+)$" ) 58if string . sub ( bud , - 4 ) == ".git" then 59bud =string . sub ( bud , 1 , - 5 ) 60end 61return utils . norm_name ( bud ) 62end 63 64function utils . get_inactive () 65return vim 66. iter ( ipairs ( vim . pack . get ())) 67: map ( function ( _ , v ) 68-- assumes that all plugins are added to vim.pack even if not currently loaded 69if not v . active then 70return v 71end 72end ) 73: totable () 74end 75 76return utils