Skip to content

Commit a644755

Browse files
committed
feat: add intelligent model picker with favorites, recent usage, and persistent sorting
- Adds <C-f> keybinding to toggle model favorite state in the picker (configurable) - UI shows star for favorites and clock for recent
1 parent 32063f4 commit a644755

File tree

4 files changed

+276
-41
lines changed

4 files changed

+276
-41
lines changed

README.md

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,10 @@
22

33
> neovim frontend for opencode - a terminal-based AI coding agent
44
5-
## Main Features
6-
7-
### Chat Panel
8-
95
<div align="center">
106
<img src="https://raw.githubusercontent.com/sst/opencode/dev/packages/web/src/assets/logo-ornate-dark.svg" alt="Opencode logo" width="30%" />
117
</div>
128

13-
### Quick buffer chat (<leader>o/) EXPERIMENTAL
14-
15-
This is an experimental feature that allows you to chat with the AI using the current buffer context. In visual mode, it captures the selected text as context, while in normal mode, it uses the current line. The AI will respond with quick edits to the files that are applied by the plugin.
16-
17-
Don't hesitate to give it a try and provide feedback!
18-
19-
Refer to the [Quick Chat](#-quick-chat) section for more details.
20-
21-
<div align="center">
22-
<img src="https://i.imgur.com/5JNlFZn.png">
23-
</div>
24-
259
<div align="center">
2610

2711
![Neovim](https://img.shields.io/badge/NeoVim-%2357A143.svg?&style=for-the-badge&logo=neovim&logoColor=white)
@@ -34,10 +18,26 @@ Refer to the [Quick Chat](#-quick-chat) section for more details.
3418

3519
This plugin provides a bridge between neovim and the [opencode](https://github.com/sst/opencode) AI agent, creating a chat interface while capturing editor context (current file, selections) to enhance your prompts. It maintains persistent sessions tied to your workspace, allowing for continuous conversations with the AI assistant similar to what tools like Cursor AI offer.
3620

21+
## Main Features
22+
3723
<div align="center">
3824
<img src="https://github.com/user-attachments/assets/197d69ba-6db9-4989-97ff-557c89000cf5">
3925
</div>
4026

27+
### Chat Panel
28+
29+
### Quick buffer chat (<leader>o/) EXPERIMENTAL
30+
31+
This is an experimental feature that allows you to chat with the AI using the current buffer context. In visual mode, it captures the selected text as context, while in normal mode, it uses the current line. The AI will respond with quick edits to the files that are applied by the plugin.
32+
33+
Don't hesitate to give it a try and provide feedback!
34+
35+
Refer to the [Quick Chat](#-quick-chat) section for more details.
36+
37+
<div align="center">
38+
<img src="https://i.imgur.com/5JNlFZn.png">
39+
</div>
40+
4141
## 📑 Table of Contents
4242

4343
- [⚠️Caution](#caution)
@@ -109,7 +109,6 @@ Install the plugin with your favorite package manager. See the [Configuration](#
109109
require('opencode').setup({
110110
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
111111
preferred_completion = nil, -- 'blink', 'nvim-cmp','vim_complete' if nil, it will use the best available completion
112-
preferred_model = nil, -- 'provider/model' (e.g., 'github-copilot/claude-sonnet-4') to highlight and sort to top of provider list
113112
default_global_keymaps = true, -- If false, disables all default global keymaps
114113
default_mode = 'build', -- 'build' or 'plan' or any custom configured. @see [OpenCode Agents](https://opencode.ai/docs/modes/)
115114
keymap_prefix = '<leader>o', -- Default keymap prefix for global keymaps change to your preferred prefix and it will be applied to all keymaps starting with <leader>o
@@ -191,6 +190,9 @@ require('opencode').setup({
191190
delete_entry = { '<C-d>', mode = { 'i', 'n' } }, -- Delete selected entry in the history picker
192191
clear_all = { '<C-X>', mode = { 'i', 'n' } }, -- Clear all entries in the history picker
193192
}
193+
model_picker = {
194+
toggle_favorite = { '<C-f>', mode = { 'i', 'n' } },
195+
},
194196
},
195197
ui = {
196198
position = 'right', -- 'right' (default), 'left' or 'current'. Position of the UI split. 'current' uses the current window for the output.
@@ -348,6 +350,28 @@ require('opencode').setup({
348350
})
349351
```
350352

353+
### Model Sorting and Favorites
354+
355+
The provider/model picker supports intelligent sorting based on your favorites and usage history:
356+
357+
#### Sorting Priority
358+
359+
When you open the model picker (`<leader>op`), models are sorted in the following order:
360+
361+
1. **Favorite models** - shown with a ⭐ icon and sorted by the order they were favorited
362+
2. **Recently accessed models** - sorted by most recent usage
363+
3. **Other models** - sorted alphabetically
364+
365+
#### Managing Favorites
366+
367+
In the model picker, press **`<C-f>`** to toggle the currently selected model as a favorite. Favorite models will:
368+
369+
- Display with a ⭐ star icon prefix
370+
- Always appear at the top of the list
371+
- Persist across Neovim sessions
372+
373+
No configuration is needed - the plugin respects and updates the OpenCode CLI format automatically.
374+
351375
### UI icons (disable emojis or customize)
352376

353377
By default, opencode.nvim uses emojis for icons in the UI. If you prefer a plain, emoji-free interface, you can switch to the `text` preset or override icons individually.
@@ -444,6 +468,7 @@ You can configure a custom action in Snacks pickers to send selected files direc
444468
```
445469

446470
This allows you to:
471+
447472
1. Open any Snacks file picker (`:Snacks picker files`, `:Snacks picker git_files`, etc.)
448473
2. Select one or more files using multi-select
449474
3. Press `<localleader>o` to send those files to opencode as context

lua/opencode/config.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ local M = {}
88
M.defaults = {
99
preferred_picker = nil,
1010
preferred_completion = nil,
11-
preferred_model = nil,
1211
default_global_keymaps = true,
1312
default_mode = 'build',
1413
legacy_commands = true,
@@ -99,6 +98,9 @@ M.defaults = {
9998
delete_entry = { '<C-d>', mode = { 'i', 'n' } },
10099
clear_all = { '<C-X>', mode = { 'i', 'n' } },
101100
},
101+
model_picker = {
102+
toggle_favorite = { '<C-f>', mode = { 'i', 'n' } },
103+
},
102104
quick_chat = {
103105
cancel = { '<C-c>', mode = { 'i', 'n' } },
104106
},

0 commit comments

Comments
 (0)