Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a750dc8
wip: context bar
sudo-tee Sep 25, 2025
50f922d
fix: issues with backmerge
sudo-tee Oct 16, 2025
472b69e
fix: main rebase
sudo-tee Oct 27, 2025
3a95eee
fix(context_completion): get key for new keymaps
sudo-tee Oct 28, 2025
ae9f106
fix(context): load context on opening
sudo-tee Oct 28, 2025
75c093e
fix(context): toggle items was not working anymore
sudo-tee Oct 28, 2025
f8ba46d
fix(context): state subscription were not registered
sudo-tee Oct 28, 2025
6230e7f
feat(context_bar): add highlights
sudo-tee Oct 28, 2025
9b99ac3
fix(context): add missing function after rebase
sudo-tee Oct 28, 2025
df552dd
fix(mention): remove dead code
sudo-tee Oct 28, 2025
c06dfc5
fix(context-completion): remove agent/files
sudo-tee Oct 28, 2025
dab53b6
refactor(context-completion): cleanup the menu creation
sudo-tee Oct 28, 2025
81daac4
feat(core): load context when opening the window
sudo-tee Oct 28, 2025
a7e4abf
fix(context): don't add selection if empty
sudo-tee Oct 28, 2025
7be67e1
feat(context-completion): selections are now multiple like files
sudo-tee Oct 28, 2025
681d263
chore(context):fix warnings
sudo-tee Oct 28, 2025
5fffbfb
feat(input_window): add context legend to input
sudo-tee Oct 28, 2025
7b50203
feat(context): persist config from cmd arguments
sudo-tee Oct 28, 2025
210e69a
test(core): add test for persisting options when sending a message
sudo-tee Oct 28, 2025
6309ed2
test(core): fix invalid win errors in tests
sudo-tee Oct 28, 2025
b9d5401
test(context-bar): add unit tests for context-bar rendering
sudo-tee Oct 28, 2025
d7a38f3
feat(completion): make it work with vim_complete
sudo-tee Oct 29, 2025
2756615
test(context_completion): add tests for context completion
sudo-tee Oct 29, 2025
133f74f
feat(selection-context): add better description for selection menu
sudo-tee Oct 29, 2025
292ce5a
docs(context-bar): add docs for the context-bar/completion
sudo-tee Oct 29, 2025
ebeea1d
fix(highlight): fix highlight for context-bar file
sudo-tee Oct 29, 2025
f8163da
feat(completion): add icons to sources
sudo-tee Oct 30, 2025
86e4802
feat(completion): rely on kind_icon instead of deducing it
sudo-tee Oct 30, 2025
617dd6c
feat(completion): better sorting for context items
sudo-tee Oct 30, 2025
64baa57
fix(completion): fix wrong icons import
sudo-tee Oct 30, 2025
79c0519
feat(completion): add context trigger to nvim_cmp engine
sudo-tee Oct 30, 2025
504255c
fix(completion): remove text/trigger after context completion
sudo-tee Oct 30, 2025
8d8849a
chore(completion): general cleanup
sudo-tee Oct 30, 2025
eef92b8
fix(context): add actual line content in cursor_data
sudo-tee Oct 30, 2025
828ba0e
feat(context): display cursor_data with the user prompt
sudo-tee Oct 30, 2025
bea323b
fix(context): fix diagnostics overwrites
sudo-tee Oct 30, 2025
0c7f72e
feat(completion): add highlight to switches in context completion
sudo-tee Oct 31, 2025
c1d3f9e
chore(mention): escape chars in mention pattern
sudo-tee Oct 31, 2025
428a046
chore(types): fix config typings
sudo-tee Oct 31, 2025
2fceec7
chore(context): add augroup to autocmds
sudo-tee Oct 31, 2025
5a322a6
chore: remove uneeded file
sudo-tee Oct 31, 2025
e53aeaa
chore(state): remove unused field
sudo-tee Oct 31, 2025
f173ffc
feat(context-bar): align the bar to the right
sudo-tee Oct 31, 2025
8585f5e
feat(docs): update README with new screenshots
sudo-tee Oct 31, 2025
a6df8a2
feat(context-bar): move prompt-guard icon to the context bar
sudo-tee Oct 31, 2025
ee89d25
feat(formatter): display diagnostics sent in user prompt
sudo-tee Nov 2, 2025
81fd96a
fix(context): merge context config properly before sending message
sudo-tee Nov 3, 2025
c70b858
test(diagnostics): add snapshot test for diagnostics
sudo-tee Nov 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ require('opencode').setup({
['~'] = { 'mention_file', mode = 'i' }, -- Pick a file and add to context. See File Mentions section
['@'] = { 'mention', mode = 'i' }, -- Insert mention (file/agent)
['/'] = { 'slash_commands', mode = 'i' }, -- Pick a command to run in the input window
['#'] = { 'context_items', mode = 'i' }, -- Manage context items (current file, selection, diagnostics, mentioned files)
['<C-i>'] = { 'focus_input', mode = { 'n', 'i' } }, -- Focus on input window and enter insert mode at the end of the input from the output window
['<tab>'] = { 'toggle_pane', mode = { 'n', 'i' } }, -- Toggle between input and output panes
['<up>'] = { 'prev_prompt_history', mode = { 'n', 'i' } }, -- Navigate to previous prompt in history
['<down>'] = { 'next_prompt_history', mode = { 'n', 'i' } }, -- Navigate to next prompt in history
Expand Down Expand Up @@ -425,6 +427,34 @@ The following editor context is automatically captured and included in your conv
You can reference files in your project directly in your conversations with Opencode. This is useful when you want to ask about or provide context about specific files. Type `@` in the input window to trigger the file picker.
Supported pickers include [`fzf-lua`](https://github.com/ibhagwan/fzf-lua), [`telescope`](https://github.com/nvim-telescope/telescope.nvim), [`mini.pick`](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-pick.md), [`snacks`](https://github.com/folke/snacks.nvim/blob/main/docs/picker.md)

### Context bar

You can quiclkly see the current context items in the context bar at the top of the input window:

<div align="center">
<img src="https://i.imgur.com/vGgu6br.png" alt="Opencode.nvim context bar" width="90%" />
</div>

### Context Items Completion

You can quickly reference available context items by typing `#` in the input window. This will show a completion menu with all available context items:

- **Current File** - The currently focused file in the editor
- **Selection** - Currently selected text in visual mode
- **Diagnostics** - LSP diagnostics from the current file
- **Cursor Data** - Current cursor position and line content
- **[filename]** - Files that have been mentioned in the conversation
- **Agents** - Available agents to switch to
- **Selections** - Previously made selections in visual mode

Context items that are not currently available will be shown as disabled in the completion menu.

You should also see the list of files agents and selections in the menu, selecting them in the menu will remove them from the context.

<div align="center">
<img src="https://i.imgur.com/UqQKW33.png" alt="Opencode.nvim context items completion" width="90%" />
</div>

## 🔄 Agents

Opencode provides two built-in agents and supports custom ones:
Expand Down
7 changes: 7 additions & 0 deletions lua/opencode/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,13 @@ function M.mention()
require('opencode.ui.completion').trigger_completion(char)()
end

function M.context_items()
local config = require('opencode.config')
local char = config.get_key_for_function('input_window', 'context_items')
ui.focus_input({ restore_position = true, start_insert = true })
require('opencode.ui.completion').trigger_completion(char)()
end

function M.slash_commands()
local config = require('opencode.config')
local char = config.get_key_for_function('input_window', 'slash_commands')
Expand Down
7 changes: 6 additions & 1 deletion lua/opencode/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ M.defaults = {
['~'] = { 'mention_file', mode = 'i' },
['@'] = { 'mention', mode = 'i' },
['/'] = { 'slash_commands', mode = 'i' },
['#'] = { 'context_items', mode = 'i' },
['<tab>'] = { 'toggle_pane', mode = { 'n', 'i' } },
['<up>'] = { 'prev_prompt_history', mode = { 'n', 'i' } },
['<down>'] = { 'next_prompt_history', mode = { 'n', 'i' } },
Expand Down Expand Up @@ -148,6 +149,7 @@ M.defaults = {
enabled = false,
},
diagnostics = {
enabled = true,
info = false,
warning = true,
error = true,
Expand All @@ -163,6 +165,9 @@ M.defaults = {
selection = {
enabled = true,
},
agents = {
enabled = true,
},
},
debug = {
enabled = false,
Expand Down Expand Up @@ -300,4 +305,4 @@ return setmetatable(M, {
__tostring = function(_)
return vim.inspect(M.values)
end,
})
}) --[[@as OpencodeConfig & OpencodeConfigModule]]
Loading