diff --git a/README.md b/README.md index 481544da..23bfe27c 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ Install the plugin with your favorite package manager. See the [Configuration](# ```lua -- Default configuration with all available options require('opencode').setup({ - preferred_picker = nil, -- 'telescope', 'fzf', 'mini.pick', 'snacks', if nil, it will use the best available picker. Note mini.pick does not support multiple selections + preferred_picker = nil, -- 'telescope', 'fzf', 'mini.pick', 'snacks', 'select', if nil, it will use the best available picker. Note mini.pick does not support multiple selections preferred_completion = nil, -- 'blink', 'nvim-cmp','vim_complete' if nil, it will use the best available completion default_global_keymaps = true, -- If false, disables all default global keymaps default_mode = 'build', -- 'build' or 'plan' or any custom configured. @see [OpenCode Agents](https://opencode.ai/docs/modes/) diff --git a/lua/opencode/types.lua b/lua/opencode/types.lua index 724cf924..4b9d0bc1 100644 --- a/lua/opencode/types.lua +++ b/lua/opencode/types.lua @@ -150,7 +150,7 @@ ---@field get_key_for_function fun(scope: 'editor'|'input_window'|'output_window', function_name: string): string|nil ---@class OpencodeConfig ----@field preferred_picker 'telescope' | 'fzf' | 'mini.pick' | 'snacks' | nil +---@field preferred_picker 'telescope' | 'fzf' | 'mini.pick' | 'snacks' | 'select' | nil ---@field preferred_completion 'blink' | 'nvim-cmp' | 'vim_complete' | nil -- Preferred completion strategy for mentons and commands ---@field default_global_keymaps boolean ---@field default_mode 'build' | 'plan' | string -- Default mode diff --git a/lua/opencode/ui/picker.lua b/lua/opencode/ui/picker.lua index 29c0cd3b..e4803820 100644 --- a/lua/opencode/ui/picker.lua +++ b/lua/opencode/ui/picker.lua @@ -4,7 +4,11 @@ function M.get_best_picker() local config = require('opencode.config') local preferred_picker = config.preferred_picker - if preferred_picker and preferred_picker ~= '' then + if preferred_picker and type(preferred_picker) == 'string' and preferred_picker ~= '' then + if preferred_picker == 'select' then + return nil + end + return preferred_picker end diff --git a/lua/opencode/ui/ui.lua b/lua/opencode/ui/ui.lua index 61b1ba96..c6626a37 100644 --- a/lua/opencode/ui/ui.lua +++ b/lua/opencode/ui/ui.lua @@ -200,14 +200,12 @@ function M.select_session(sessions, cb) vim.ui.select(sessions, { prompt = '', format_item = function(session) - local parts = { { session.id } } + local parts = {} - if session.description then - table.insert(parts, session.description) - end - - if session.message_count then - table.insert(parts, session.message_count .. ' messages') + if session.title then + table.insert(parts, session.title) + else + table.insert(parts, session.id) end local modified = util.format_time(session.modified)