11local M = {}
2-
3- local function get_best_picker ()
4- local config = require (' opencode.config' )
5-
6- local preferred_picker = config .preferred_picker
7- if preferred_picker and preferred_picker ~= ' ' then
8- return preferred_picker
9- end
10-
11- if pcall (require , ' telescope' ) then
12- return ' telescope'
13- end
14- if pcall (require , ' fzf-lua' ) then
15- return ' fzf'
16- end
17- if pcall (require , ' mini.pick' ) then
18- return ' mini.pick'
19- end
20- if pcall (require , ' snacks' ) then
21- return ' snacks'
22- end
23- return nil
24- end
2+ local picker = require (' opencode.ui.picker' )
253
264local function format_file (path )
275 -- when path is something like: file.extension dir1/dir2 -> format to dir1/dir2/file.extension
@@ -146,9 +124,9 @@ local function snacks_picker_ui(callback, path)
146124end
147125
148126function M .pick (callback , path )
149- local picker = get_best_picker ()
127+ local picker_type = picker . get_best_picker ()
150128
151- if not picker then
129+ if not picker_type then
152130 return
153131 end
154132
@@ -158,13 +136,13 @@ function M.pick(callback, path)
158136 end
159137
160138 vim .schedule (function ()
161- if picker == ' telescope' then
139+ if picker_type == ' telescope' then
162140 telescope_ui (wrapped_callback , path )
163- elseif picker == ' fzf' then
141+ elseif picker_type == ' fzf' then
164142 fzf_ui (wrapped_callback , path )
165- elseif picker == ' mini.pick' then
143+ elseif picker_type == ' mini.pick' then
166144 mini_pick_ui (wrapped_callback , path )
167- elseif picker == ' snacks' then
145+ elseif picker_type == ' snacks' then
168146 snacks_picker_ui (wrapped_callback , path )
169147 else
170148 callback (nil )
0 commit comments