@@ -289,8 +289,13 @@ T['add()']['works for present plugins'] = new_set({ parametrize = { { 'plugin_1'
289
289
-- No CLI process should be run as plugin is already present
290
290
eq (get_spawn_log (), {})
291
291
292
- -- Should use `:packadd`, i.e. load 'plugin/', 'ftdetect/', etc.
293
- eq (child .lua_get (' _G.plugin_1_plugin_dir_was_sourced' ), true )
292
+ -- Should add plugin to 'runtimepath'
293
+ local rtp = vim .split (child .o .runtimepath , ' ,' )
294
+ eq (vim .tbl_contains (rtp , ref_path ), true )
295
+ eq (vim .tbl_contains (rtp , ref_path .. ' /after' ), true )
296
+
297
+ -- Should load 'plugin/', 'after/plugin/', etc.
298
+ eq (child .lua_get (' type(_G.plugin_log)' ), ' table' )
294
299
end ,
295
300
})
296
301
@@ -313,6 +318,47 @@ T['add()']['infers name from source'] = new_set({
313
318
end ,
314
319
})
315
320
321
+ T [' add()' ][" properly sources 'plugin/' and 'after/plugin/'" ] = function ()
322
+ add ({ name = ' plugin_1' , depends = { ' plugin_2' } })
323
+ local after_paths = { ' after/plugin/plug_1.lua' , ' after/plugin/plug_1.vim' , ' after/plugin/subdir/plug_1_sub.lua' }
324
+ if child .fn .has (' nvim-0.9' ) == 0 then
325
+ after_paths = { ' after/plugin/plug_1.vim' , ' after/plugin/plug_1.lua' , ' after/plugin/subdir/plug_1_sub.lua' }
326
+ end
327
+ -- stylua: ignore
328
+ local ref_plugin_log = {
329
+ ' plugin/plug_2.lua' ,
330
+ ' plugin/plug_1.vim' , ' plugin/plug_1.lua' , ' plugin/subdir/plug_1_sub.lua' ,
331
+ ' after/plugin/plug_2.lua' ,
332
+ unpack (after_paths )
333
+ }
334
+ eq (child .lua_get (' _G.plugin_log' ), ref_plugin_log )
335
+ end
336
+
337
+ T [' add()' ][" does not source 'after/plugin/' when not needed" ] = function ()
338
+ -- During startup
339
+ local setup_cmd =
340
+ string.format (" lua require('mini.deps').setup({ path = { package = %s } })" , vim .inspect (test_dir_absolute ))
341
+ child .restart ({ ' -u' , ' NONE' , ' --cmd' , ' set rtp+=.' , ' --cmd' , setup_cmd , ' --cmd' , " lua MiniDeps.add('plugin_1')" })
342
+
343
+ -- stylua: ignore
344
+ eq (child .lua_get (' _G.plugin_log' ), {
345
+ -- 'plugin/' directory gets sourced both as part of startup and `:packadd`
346
+ ' plugin/plug_1.vim' , ' plugin/plug_1.lua' , ' plugin/subdir/plug_1_sub.lua' ,
347
+ ' plugin/plug_1.vim' , ' plugin/plug_1.lua' , ' plugin/subdir/plug_1_sub.lua' ,
348
+ -- But sourcing 'after/plugin/' in 'mini.deps' should not duplicate startup
349
+ ' after/plugin/plug_1.vim' , ' after/plugin/plug_1.lua' , ' after/plugin/subdir/plug_1_sub.lua' ,
350
+ })
351
+
352
+ -- When 'loadplugins = false'
353
+ child .restart ({ ' -u' , ' NONE' , ' --cmd' , ' set rtp+=.' , ' --cmd' , setup_cmd })
354
+ child .o .loadplugins = false
355
+ add (' plugin_1' )
356
+
357
+ -- - `:packadd` does not recognize 'loadplugins' and thus sources them
358
+ -- But 'after/plugin/' should not be sourced
359
+ eq (child .lua_get (' _G.plugin_log' ), { ' plugin/plug_1.vim' , ' plugin/plug_1.lua' , ' plugin/subdir/plug_1_sub.lua' })
360
+ end
361
+
316
362
T [' add()' ][' can update session data' ] = function ()
317
363
add (' plugin_1' )
318
364
add (' plugin_2' )
440
486
441
487
T [' add()' ][' respects `opts.bang`' ] = function ()
442
488
add (' plugin_1' , { bang = true })
443
- eq (child .lua_get (' _G.plugin_1_plugin_dir_was_sourced ' ), vim .NIL )
489
+ eq (child .lua_get (' _G.plugin_log ' ), vim .NIL )
444
490
end
445
491
446
492
T [' add()' ][' does not modify input' ] = function ()
0 commit comments