@@ -11,7 +11,6 @@ local uv = vim.uv
11
11
--- @field status pack.Status ?
12
12
--- @field hash string ?
13
13
--- @field pin boolean ?
14
- --- @field opt boolean ?
15
14
--- @field build string ? | function ?
16
15
--- @field url string ?
17
16
@@ -41,14 +40,11 @@ local Packages = {}
41
40
local Path = {
42
41
lock = vim .fs .joinpath (vim .fn .stdpath (' state' ), ' pack-lock.json' ),
43
42
log = vim .fs .joinpath (vim .fn .stdpath (' log' ), ' pack.log' ),
44
- pack = vim .fs .joinpath (vim .fn .stdpath (' data' ), ' site ' , ' pack' , ' packs ' ),
43
+ pack = vim .fs .joinpath (vim .fn .stdpath (' data' ), ' pack' ),
45
44
}
46
45
47
46
--- @class pack.Opts
48
47
---
49
- --- (default: `false`)
50
- --- @field opt boolean
51
- ---
52
48
--- (default: `https://github.com/%s.git`)
53
49
--- @field url_format string
54
50
---
@@ -60,7 +56,6 @@ local Path = {
60
56
local Config = {
61
57
-- Using '--tags --force' means conflicting tags will be synced with remote
62
58
clone_args = { ' --depth=1' , ' --recurse-submodules' , ' --shallow-submodules' , ' --no-single-branch' },
63
- opt = false ,
64
59
pull_args = { ' --tags' , ' --force' , ' --recurse-submodules' , ' --update-shallow' },
65
60
url_format = ' https://github.com/%s.git' ,
66
61
}
@@ -107,18 +102,15 @@ local function file_read(path)
107
102
return data
108
103
end
109
104
110
- --- @return pack.Package
105
+ --- @return pack.Package[]
111
106
local function find_unlisted ()
112
107
local unlisted = {}
113
- for _ , packdir in ipairs { ' start' , ' opt' } do
114
- local path = vim .fs .joinpath (Path .pack , packdir )
115
- for name , type in vim .fs .dir (path ) do
116
- if type == ' directory' and name ~= ' pack.nvim' then
117
- local dir = vim .fs .joinpath (path , name )
118
- local pkg = Packages [name ]
119
- if not pkg or pkg .dir ~= dir then
120
- table.insert (unlisted , { name = name , dir = dir })
121
- end
108
+ for name , type in vim .fs .dir (Path .pack ) do
109
+ if type == ' directory' and name ~= ' pack.nvim' then
110
+ local dir = vim .fs .joinpath (Path .pack , name )
111
+ local pkg = Packages [name ]
112
+ if not pkg or pkg .dir ~= dir then
113
+ table.insert (unlisted , { name = name , dir = dir })
122
114
end
123
115
end
124
116
end
@@ -363,10 +355,10 @@ local function resolve(pkg, counter, build_queue)
363
355
end
364
356
end
365
357
366
- --- @param pkg pack.Package
358
+ --- @param pkg string | pack.Package
359
+ --- @return pack.Package ?
367
360
local function register (pkg )
368
361
if type (pkg ) == ' string' then
369
- --- @diagnostic disable-next-line : missing-fields
370
362
pkg = { pkg }
371
363
end
372
364
@@ -376,14 +368,14 @@ local function register(pkg)
376
368
377
369
local name = pkg .as or url :gsub (' %.git$' , ' ' ):match (' /([%w-_.]+)$' ) -- Infer name from `url`
378
370
if not name then
379
- return vim . notify ( ' Paq : Failed to parse ' .. vim .inspect (pkg ), vim . log . levels . ERROR )
371
+ error ( ' Pack : Failed to parse ' .. vim .inspect (pkg ))
380
372
end
381
- local opt = pkg . opt or Config . opt and pkg . opt == nil
382
- local dir = vim .fs .joinpath (Path .pack , ( opt and ' opt ' or ' start ' ), name )
373
+
374
+ local dir = vim .fs .joinpath (Path .pack , name )
383
375
local ok , hash = pcall (get_git_hash , dir )
384
376
hash = ok and hash or ' '
385
377
386
- Packages [ name ] = {
378
+ return {
387
379
name = name ,
388
380
branch = pkg .branch ,
389
381
dir = dir ,
@@ -437,7 +429,7 @@ local function exe_op(op, fn, pkgs, silent)
437
429
local function after (ok , err , nop )
438
430
local summary = ' Pack: %s complete. %d ok; %d errors;' .. (nop > 0 and ' %d no-ops' or ' ' )
439
431
vim .notify (string.format (summary , op , ok , err , nop ))
440
- vim .cmd (' packloadall! | silent! helptags ALL' )
432
+ vim .cmd (' silent! helptags ALL' )
441
433
if # build_queue ~= 0 then
442
434
exe_op (' build' , run_build , build_queue )
443
435
end
@@ -463,7 +455,6 @@ local function calculate_diffs()
463
455
local pack_pkg = Packages [name ]
464
456
if pack_pkg and Filter .not_removed (lock_pkg ) and not vim .deep_equal (lock_pkg , pack_pkg ) then
465
457
for k , v in pairs {
466
- dir = M .status .TO_MOVE ,
467
458
branch = M .status .TO_RECLONE ,
468
459
url = M .status .TO_RECLONE ,
469
460
} do
@@ -495,10 +486,20 @@ end
495
486
--- @param pkgs pack.Package[]
496
487
function M .register (pkgs )
497
488
vim .validate (' pkgs' , pkgs , ' table' , true )
498
- Package = {}
499
- vim .tbl_map (register , pkgs )
489
+ Packages = {}
490
+ pkgs = vim .tbl_map (register , pkgs )
491
+
492
+ for _ , pkg in ipairs (pkgs ) do
493
+ Packages [pkg .name ] = pkg
494
+ vim .opt .runtimepath :prepend (pkg .dir )
495
+ end
496
+
500
497
lock_load ()
501
498
exe_op (' resolve' , resolve , calculate_diffs (), true )
499
+
500
+ for _ , pkg in ipairs (find_unlisted ()) do
501
+ vim .opt .runtimepath :remove (pkg .dir )
502
+ end
502
503
end
503
504
504
505
function M .install () exe_op (' install' , clone , vim .tbl_filter (Filter .to_install , Packages )) end
0 commit comments