@@ -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,45 @@ 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
+ if child .fn .has (' nvim-0.9' ) == 0 then MiniTest .skip (' Neovim<0.9 has different sourcing behavior.' ) end
323
+
324
+ add ({ name = ' plugin_1' , depends = { ' plugin_2' } })
325
+ -- stylua: ignore
326
+ local ref_plugin_log = {
327
+ ' plugin/plug_2.lua' ,
328
+ ' plugin/plug_1.vim' , ' plugin/plug_1.lua' , ' plugin/subdir/plug_1_sub.lua' ,
329
+ ' after/plugin/plug_2.lua' ,
330
+ ' after/plugin/plug_1.lua' , ' after/plugin/plug_1.vim' , ' after/plugin/subdir/plug_1_sub.lua' ,
331
+ }
332
+ eq (child .lua_get (' _G.plugin_log' ), ref_plugin_log )
333
+ end
334
+
335
+ T [' add()' ][" does not source 'after/plugin/' when not needed" ] = function ()
336
+ -- During startup
337
+ local setup_cmd =
338
+ string.format (" lua require('mini.deps').setup({ path = { package = %s } })" , vim .inspect (test_dir_absolute ))
339
+ child .restart ({ ' -u' , ' NONE' , ' --cmd' , ' set rtp+=.' , ' --cmd' , setup_cmd , ' --cmd' , " lua MiniDeps.add('plugin_1')" })
340
+
341
+ -- stylua: ignore
342
+ eq (child .lua_get (' _G.plugin_log' ), {
343
+ -- 'plugin/' directory gets sourced both as part of startup and `:packadd`
344
+ ' plugin/plug_1.vim' , ' plugin/plug_1.lua' , ' plugin/subdir/plug_1_sub.lua' ,
345
+ ' plugin/plug_1.vim' , ' plugin/plug_1.lua' , ' plugin/subdir/plug_1_sub.lua' ,
346
+ -- But sourcing 'after/plugin/' in 'mini.deps' should not duplicate startup
347
+ ' after/plugin/plug_1.vim' , ' after/plugin/plug_1.lua' , ' after/plugin/subdir/plug_1_sub.lua' ,
348
+ })
349
+
350
+ -- When 'loadplugins = false'
351
+ child .restart ({ ' -u' , ' NONE' , ' --cmd' , ' set rtp+=.' , ' --cmd' , setup_cmd })
352
+ child .o .loadplugins = false
353
+ add (' plugin_1' )
354
+
355
+ -- - `:packadd` does not recognize 'loadplugins' and thus sources them
356
+ -- But 'after/plugin/' should not be sourced
357
+ eq (child .lua_get (' _G.plugin_log' ), { ' plugin/plug_1.vim' , ' plugin/plug_1.lua' , ' plugin/subdir/plug_1_sub.lua' })
358
+ end
359
+
316
360
T [' add()' ][' can update session data' ] = function ()
317
361
add (' plugin_1' )
318
362
add (' plugin_2' )
440
484
441
485
T [' add()' ][' respects `opts.bang`' ] = function ()
442
486
add (' plugin_1' , { bang = true })
443
- eq (child .lua_get (' _G.plugin_1_plugin_dir_was_sourced ' ), vim .NIL )
487
+ eq (child .lua_get (' _G.plugin_log ' ), vim .NIL )
444
488
end
445
489
446
490
T [' add()' ][' does not modify input' ] = function ()
0 commit comments