grace/dots
dotfiles/nix configs
git clone https://git.gae.moe/grace/dots
70a1581
old_stow_config
1-- 2-- Packed: a single file, somewhat compatible Packer replacement 3-- Written by grace 4-- 5 6local function resolve_src ( s ) 7if s : match ( "^https?://" ) then 8return s 9end 10if s : match ( "^[%w%-]+/[%w%-_.]+$" ) then 11return "https://github.com/" .. s 12end 13return s 14end 15 16local function normalize_plugin ( p ) 17if type ( p ) == "string" then 18return { 19src = resolve_src ( p ) , 20name = p : match ( ".*/(.*)" ) , 21} 22end 23 24if type ( p [ 1 ]) == "string" then 25p . src = resolve_src ( p [ 1 ]) 26p [ 1 ] = nil 27end 28 29if p . src then 30p . src = resolve_src ( p . src ) 31end 32 33if not p . name and p . as then 34p . name = p . as 35end 36 37if not p . version then 38if p . commit then 39p . version = p . commit 40elseif p . tag then 41p . version = p . tag 42elseif p . branch then 43p . version = p . branch 44end 45end 46 47 48 49local unsupported = { 50'disable' , 'installer' , 'updater' , 'after' , 'rtp' , 51'opt' , 'bufread' , 'lock' , 'run' , 'requires' , 'rocks' , 'setup' 52} 53 54for _ , field in ipairs ( unsupported ) do 55if p [ field ] then 56vim . notify ( "Packed does not support `" .. field .. "`: " .. ( p . name or p . src ) , vim . log . levels . WARN ) 57vim . api . nvim_echo ({ { "Press Enter to continue..." , "MoreMsg" } } , false , {}) 58vim . fn . getchar () 59end 60end 61 62if p . cmd or p . ft or p . keys or p . event or p . fn or p . cond or p . module or p . module_pattern then 63vim . notify ( "Packed does not support lazy loading: " .. ( p . name or p . src ) , vim . log . levels . WARN ) 64vim . api . nvim_echo ({ { "Press Enter to continue..." , "MoreMsg" } } , false , {}) 65vim . fn . getchar () 66end 67 68 69 70return p 71end 72 73local function setup_plugins ( plugs ) 74local plugins = {} 75 76if type ( plugs ) == "function" then 77local function use ( p ) 78table . insert ( plugins , p ) 79end 80 81plugs ( use ) 82else 83plugins = plugs 84end 85local specs = {} 86 87for _ , p in ipairs ( plugins ) do 88p = normalize_plugin ( p ) 89 90local spec = vim . deepcopy ( p ) 91spec . config = nil 92 93table . insert ( specs , spec ) 94end 95 96vim . pack . add ( specs , { confirm = true , load = true }) 97 98 99for _ , p in ipairs ( plugins ) do 100if type ( p ) ~= "string" and p . config then 101local ok = pcall ( p . config ) 102if not ok then 103vim . notify ( "Config failed: " .. ( p . name or p . src ) , vim . log . levels . ERROR ) 104vim . api . nvim_echo ({ { "Press Enter to continue..." , "MoreMsg" } } , false , {}) 105vim . fn . getchar () 106end 107end 108end 109 110 111local unused = vim . iter ( vim . pack . get ()) 112: filter ( function ( p ) 113return not p . active 114end ) 115: map ( function ( p ) 116return p . spec . name 117end ) 118: totable () 119 120vim . pack . del ( unused ) 121end 122 123 124local r = {} 125r . setup = setup_plugins 126 127return r