@@ -745,6 +745,26 @@ T['pickers'] = new_set({
745745 },
746746})
747747
748+ local validate_global_source_options = function (picker_start , check_preview , check_choose )
749+ child .lua ([[
750+ MiniPick.config.source.preview = function(buf_id, item)
751+ vim.api.nvim_buf_set_lines(buf_id, 0, -1, false, { "My preview" })
752+ _G.custom_preview = true
753+ end
754+ MiniPick.config.source.choose = function(item)
755+ _G.custom_choose = true
756+ end
757+ ]] )
758+ picker_start ()
759+ local ref_custom_preview = check_preview == false and vim .NIL or true
760+ type_keys (' <Tab>' )
761+ eq (child .lua_get (' _G.custom_preview' ), ref_custom_preview )
762+ local ref_custom_choose = check_choose == false and vim .NIL or true
763+ type_keys (' <CR>' )
764+ eq (child .lua_get (' _G.custom_choose' ), ref_custom_choose )
765+ type_keys (' <C-c>' )
766+ end
767+
748768T [' pickers' ][" validate no 'mini.pick'" ] = function ()
749769 child .lua ([[ require = function(module) error() end]] )
750770
@@ -898,6 +918,10 @@ T['pickers']['buf_lines()']['respects `opts`'] = function()
898918 validate_picker_name (' My name' )
899919end
900920
921+ T [' pickers' ][' buf_lines()' ][' respects global source options' ] = function ()
922+ validate_global_source_options (pick_buf_lines , true , true )
923+ end
924+
901925T [' pickers' ][' buf_lines()' ][' validates arguments' ] = function ()
902926 local validate = function (local_opts , error_pattern )
903927 expect .error (function () child .lua (' MiniExtra.pickers.buf_lines(...)' , { local_opts }) end , error_pattern )
@@ -959,6 +983,10 @@ T['pickers']['commands()']['respects `opts`'] = function()
959983 validate_picker_name (' My name' )
960984end
961985
986+ T [' pickers' ][' commands()' ][' respects global source options' ] = function ()
987+ validate_global_source_options (pick_commands , false , false )
988+ end
989+
962990T [' pickers' ][' diagnostic()' ] = new_set ({
963991 hooks = {
964992 pre_case = function ()
@@ -1098,6 +1126,10 @@ T['pickers']['diagnostic()']['respects `opts`'] = function()
10981126 validate_picker_name (' My name' )
10991127end
11001128
1129+ T [' pickers' ][' diagnostic()' ][' respects global source options' ] = function ()
1130+ validate_global_source_options (pick_diagnostic , true , false )
1131+ end
1132+
11011133T [' pickers' ][' diagnostic()' ][' does not modify diagnostic table' ] = function ()
11021134 local diagnostic_current = child .lua_get (' vim.diagnostic.get()' )
11031135 pick_diagnostic ()
@@ -1292,6 +1324,10 @@ T['pickers']['explorer()']['respects `opts`'] = function()
12921324 validate_picker_name (' My name' )
12931325end
12941326
1327+ T [' pickers' ][' explorer()' ][' respects global source options' ] = function ()
1328+ validate_global_source_options (pick_explorer , true , false )
1329+ end
1330+
12951331T [' pickers' ][' explorer()' ][' validates arguments' ] = function ()
12961332 local validate = function (local_opts , error_pattern )
12971333 expect .error (function () child .lua (' MiniExtra.pickers.explorer(...)' , { local_opts }) end , error_pattern )
@@ -1415,6 +1451,10 @@ T['pickers']['git_branches()']['respects `opts`'] = function()
14151451 validate_picker_name (' My name' )
14161452end
14171453
1454+ T [' pickers' ][' git_branches()' ][' respects global source options' ] = function ()
1455+ validate_global_source_options (pick_git_branches , false , false )
1456+ end
1457+
14181458T [' pickers' ][' git_branches()' ][' validates git' ] = function ()
14191459 -- CLI
14201460 mock_fn_executable ({})
@@ -1539,6 +1579,10 @@ T['pickers']['git_commits()']['respects `opts`'] = function()
15391579 validate_picker_name (' My name' )
15401580end
15411581
1582+ T [' pickers' ][' git_commits()' ][' respects global source options' ] = function ()
1583+ validate_global_source_options (pick_git_branches , false , false )
1584+ end
1585+
15421586T [' pickers' ][' git_commits()' ][' validates git' ] = function ()
15431587 -- CLI
15441588 mock_fn_executable ({})
@@ -1670,6 +1714,14 @@ T['pickers']['git_files()']['respects `opts`'] = function()
16701714 validate_picker_name (' My name' )
16711715end
16721716
1717+ T [' pickers' ][' git_files()' ][' respects global source options' ] = function ()
1718+ local repo_dir = test_dir_absolute
1719+ child .fn .chdir (repo_dir )
1720+ mock_git_repo (repo_dir )
1721+ mock_cli_return ({ ' git-files/git-file-1' , ' git-files/git-file-2' })
1722+ validate_global_source_options (pick_git_files , true , true )
1723+ end
1724+
16731725T [' pickers' ][' git_files()' ][' validates git' ] = function ()
16741726 -- CLI
16751727 mock_fn_executable ({})
@@ -1859,6 +1911,15 @@ T['pickers']['git_hunks()']['respects `opts`'] = function()
18591911 validate_picker_name (' My name' )
18601912end
18611913
1914+ T [' pickers' ][' git_hunks()' ][' respects global source options' ] = function ()
1915+ local repo_dir = test_dir_absolute
1916+ child .fn .chdir (repo_dir )
1917+ mock_git_repo (repo_dir )
1918+ local diff_lines = child .fn .readfile (join_path (' mocks' , ' git-diff' ))
1919+ mock_cli_return (diff_lines )
1920+ validate_global_source_options (pick_git_hunks , false , true )
1921+ end
1922+
18621923T [' pickers' ][' git_hunks()' ][' validates git' ] = function ()
18631924 -- CLI
18641925 mock_fn_executable ({})
@@ -1996,6 +2057,11 @@ T['pickers']['hipatterns()']['respects `opts`'] = function()
19962057 validate_picker_name (' My name' )
19972058end
19982059
2060+ T [' pickers' ][' hipatterns()' ][' respects global source options' ] = function ()
2061+ setup_hipatterns ()
2062+ validate_global_source_options (pick_hipatterns , true , true )
2063+ end
2064+
19992065T [' pickers' ][' hipatterns()' ][" checks for present 'mini.hipatterns'" ] = function ()
20002066 child .lua ([[
20012067 local require_orig = require
@@ -2153,6 +2219,10 @@ T['pickers']['history()']['respects `opts`'] = function()
21532219 validate_picker_name (' My name' )
21542220end
21552221
2222+ T [' pickers' ][' history()' ][' respects global source options' ] = function ()
2223+ validate_global_source_options (pick_history , false , false )
2224+ end
2225+
21562226T [' pickers' ][' history()' ][' validates arguments' ] = function ()
21572227 local validate = function (local_opts , error_pattern )
21582228 expect .error (function () child .lua (' MiniExtra.pickers.history(...)' , { local_opts }) end , error_pattern )
@@ -2213,6 +2283,10 @@ T['pickers']['hl_groups()']['respects `opts`'] = function()
22132283 validate_picker_name (' My name' )
22142284end
22152285
2286+ T [' pickers' ][' hl_groups()' ][' respects global source options' ] = function ()
2287+ validate_global_source_options (pick_hl_groups , false , false )
2288+ end
2289+
22162290T [' pickers' ][' keymaps()' ] = new_set ()
22172291
22182292local pick_keymaps = forward_lua_notify (' MiniExtra.pickers.keymaps' )
@@ -2352,6 +2426,10 @@ T['pickers']['keymaps()']['respects `opts`'] = function()
23522426 validate_picker_name (' My name' )
23532427end
23542428
2429+ T [' pickers' ][' keymaps()' ][' respects global source options' ] = function ()
2430+ validate_global_source_options (pick_keymaps , false , false )
2431+ end
2432+
23552433T [' pickers' ][' keymaps()' ][' validates arguments' ] = function ()
23562434 local validate = function (local_opts , error_pattern )
23572435 expect .error (function () child .lua (' MiniExtra.pickers.keymaps(...)' , { local_opts }) end , error_pattern )
@@ -2498,6 +2576,14 @@ T['pickers']['list()']['respects `opts`'] = function()
24982576 validate_picker_name (' My name' )
24992577end
25002578
2579+ T [' pickers' ][' list()' ][' respects global source options' ] = function ()
2580+ local path = real_file (' a.lua' )
2581+ child .cmd (' edit ' .. path )
2582+ type_keys (' G' )
2583+ type_keys (' gg' )
2584+ validate_global_source_options (function () pick_list ({ scope = ' jump' }) end , true , false )
2585+ end
2586+
25012587T [' pickers' ][' list()' ][' validates arguments' ] = function ()
25022588 local validate = function (local_opts , error_pattern )
25032589 expect .error (function () child .lua (' MiniExtra.pickers.list(...)' , { local_opts }) end , error_pattern )
@@ -2740,6 +2826,11 @@ T['pickers']['lsp()']['respects `opts`'] = function()
27402826 validate_picker_name (' My name' )
27412827end
27422828
2829+ T [' pickers' ][' lsp()' ][' respects global source options' ] = function ()
2830+ setup_lsp ()
2831+ validate_global_source_options (function () pick_lsp ({ scope = ' document_symbol' }) end , true , false )
2832+ end
2833+
27432834T [' pickers' ][' lsp()' ][' validates arguments' ] = function ()
27442835 local validate = function (local_opts , error_pattern )
27452836 expect .error (function () child .lua (' MiniExtra.pickers.lsp(...)' , { local_opts }) end , error_pattern )
@@ -2836,6 +2927,11 @@ T['pickers']['marks()']['respects `opts`'] = function()
28362927 validate_picker_name (' My name' )
28372928end
28382929
2930+ T [' pickers' ][' marks()' ][' respects global source options' ] = function ()
2931+ setup_marks ()
2932+ validate_global_source_options (pick_marks , true , true )
2933+ end
2934+
28392935T [' pickers' ][' marks()' ][' validates arguments' ] = function ()
28402936 local validate = function (local_opts , error_pattern )
28412937 expect .error (function () child .lua (' MiniExtra.pickers.marks(...)' , { local_opts }) end , error_pattern )
@@ -2924,6 +3020,13 @@ T['pickers']['oldfiles()']['respects `opts`'] = function()
29243020 validate_picker_name (' My name' )
29253021end
29263022
3023+ T [' pickers' ][' oldfiles()' ][' respects global source options' ] = function ()
3024+ local path_1 , path_2 = real_file (' LICENSE' ), make_testpath (' mocks' , ' diagnostic.lua' )
3025+ local ref_oldfiles = { full_path (path_1 ), full_path (path_2 ), ' not-existing' }
3026+ child .v .oldfiles = ref_oldfiles
3027+ validate_global_source_options (pick_oldfiles , true , true )
3028+ end
3029+
29273030T [' pickers' ][' oldfiles()' ][' respects `opts.source.cwd`' ] = function ()
29283031 child .set_size (10 , 70 )
29293032 local ref_oldfiles = { full_path (real_file (' LICENSE' )), full_path (make_testpath (' mocks' , ' diagnostic.lua' )) }
@@ -3035,6 +3138,10 @@ T['pickers']['options()']['respects `opts`'] = function()
30353138 validate_picker_name (' My name' )
30363139end
30373140
3141+ T [' pickers' ][' options()' ][' respects global source options' ] = function ()
3142+ validate_global_source_options (pick_options , false , false )
3143+ end
3144+
30383145T [' pickers' ][' options()' ][' validates arguments' ] = function ()
30393146 local validate = function (local_opts , error_pattern )
30403147 expect .error (function () child .lua (' MiniExtra.pickers.options(...)' , { local_opts }) end , error_pattern )
@@ -3160,6 +3267,11 @@ T['pickers']['registers()']['respects `opts`'] = function()
31603267 validate_picker_name (' My name' )
31613268end
31623269
3270+ T [' pickers' ][' registers()' ][' respects global source options' ] = function ()
3271+ setup_registers ()
3272+ validate_global_source_options (pick_registers , false , false )
3273+ end
3274+
31633275T [' pickers' ][' spellsuggest()' ] = new_set ()
31643276
31653277local pick_spellsuggest = forward_lua_notify (' MiniExtra.pickers.spellsuggest' )
@@ -3203,6 +3315,11 @@ T['pickers']['spellsuggest()']['respects `opts`'] = function()
32033315 validate_picker_name (' My name' )
32043316end
32053317
3318+ T [' pickers' ][' spellsuggest()' ][' respects global source options' ] = function ()
3319+ setup_spell ()
3320+ validate_global_source_options (pick_spellsuggest , false , false )
3321+ end
3322+
32063323T [' pickers' ][' spellsuggest()' ][' validates arguments' ] = function ()
32073324 local validate = function (local_opts , error_pattern )
32083325 expect .error (function () child .lua (' MiniExtra.pickers.spellsuggest(...)' , { local_opts }) end , error_pattern )
@@ -3265,6 +3382,11 @@ T['pickers']['treesitter()']['respects `opts`'] = function()
32653382 validate_picker_name (' My name' )
32663383end
32673384
3385+ T [' pickers' ][' treesitter()' ][' respects global source options' ] = function ()
3386+ setup_treesitter ()
3387+ validate_global_source_options (pick_treesitter , true , true )
3388+ end
3389+
32683390local setup_visits = function ()
32693391 -- NOTE: 'mini.visits' uses forward slashes in index
32703392 local dir = test_dir_absolute :gsub (' \\ ' , ' /' )
@@ -3366,6 +3488,11 @@ T['pickers']['visit_paths()']['respects `opts`'] = function()
33663488 validate_picker_name (' My name' )
33673489end
33683490
3491+ T [' pickers' ][' visit_paths()' ][' respects global source options' ] = function ()
3492+ setup_visits ()
3493+ validate_global_source_options (pick_visit_paths , true , true )
3494+ end
3495+
33693496T [' pickers' ][' visit_paths()' ][" checks for present 'mini.visits'" ] = function ()
33703497 child .lua ([[
33713498 local require_orig = require
@@ -3448,6 +3575,11 @@ T['pickers']['visit_labels()']['respects `opts`'] = function()
34483575 validate_picker_name (' My name' )
34493576end
34503577
3578+ T [' pickers' ][' visit_labels()' ][' respects global source options' ] = function ()
3579+ setup_visits ()
3580+ validate_global_source_options (pick_visit_labels , false , false )
3581+ end
3582+
34513583T [' pickers' ][' visit_labels()' ][" checks for present 'mini.visits'" ] = function ()
34523584 child .lua ([[
34533585 local require_orig = require
0 commit comments