@@ -124,6 +124,31 @@ require('opencode').setup({
124124 [' <leader>opa' ] = { ' permission_accept' }, -- Accept permission request once
125125 [' <leader>opA' ] = { ' permission_accept_all' }, -- Accept all (for current tool)
126126 [' <leader>opd' ] = { ' permission_deny' }, -- Deny permission request once
127+ global = {
128+ toggle = ' <leader>og' , -- Open opencode. Close if opened
129+ open_input = ' <leader>oi' , -- Opens and focuses on input window on insert mode
130+ open_input_new_session = ' <leader>oI' , -- Opens and focuses on input window on insert mode. Creates a new session
131+ open_output = ' <leader>oo' , -- Opens and focuses on output window
132+ toggle_focus = ' <leader>ot' , -- Toggle focus between opencode and last window
133+ close = ' <leader>oq' , -- Close UI windows
134+ select_session = ' <leader>os' , -- Select and load a opencode session
135+ configure_provider = ' <leader>op' , -- Quick provider and model switch from predefined list
136+ diff_open = ' <leader>od' , -- Opens a diff tab of a modified file since the last opencode prompt
137+ diff_next = ' <leader>o]' , -- Navigate to next file diff
138+ diff_prev = ' <leader>o[' , -- Navigate to previous file diff
139+ diff_close = ' <leader>oc' , -- Close diff view tab and return to normal editing
140+ diff_revert_all_last_prompt = ' <leader>ora' , -- Revert all file changes since the last opencode prompt
141+ diff_revert_this_last_prompt = ' <leader>ort' , -- Revert current file changes since the last opencode prompt
142+ diff_revert_all = ' <leader>orA' , -- Revert all file changes since the last opencode session
143+ diff_revert_this = ' <leader>orT' , -- Revert current file changes since the last opencode session
144+ diff_restore_snapshot_file = ' <leader>orr' , -- Restore file to snapshot
145+ diff_restore_snapshot_all = ' <leader>orR' , -- Restore all files to snapshot
146+ open_configuration_file = ' <leader>oC' , -- Open opencode configuration file
147+ swap_position = ' <leader>ox' , -- Swap Opencode pane left/right
148+ permission_accept = ' <leader>opa' , -- Accept permission request once
149+ permission_accept_all = ' <leader>opA' , -- Accept all (for current tool)
150+ permission_deny = ' <leader>opd' ,-- Accept permission request once
151+ debug_session = ' <leader>ods' , -- Debug session info
127152 },
128153 input_window = {
129154 [' <cr>' ] = { ' submit_input_prompt' , mode = { ' n' , ' i' } }, -- Submit prompt (normal mode and insert mode)
@@ -153,6 +178,28 @@ require('opencode').setup({
153178 accept = ' a' , -- Accept permission request once (only available when there is a pending permission request)
154179 accept_all = ' A' , -- Accept all (for current tool) permission request once (only available when there is a pending permission request)
155180 deny = ' d' , -- Deny permission request once (only available when there is a pending permission request)
181+ window = {
182+ submit = ' <cr>' , -- Submit prompt (normal mode)
183+ submit_insert = ' <cr>' , -- Submit prompt (insert mode)
184+ close = ' <esc>' , -- Close UI windows
185+ stop = ' <C-c>' , -- Stop opencode while it is running
186+ next_message = ' ]]' , -- Navigate to next message in the conversation
187+ prev_message = ' [[' , -- Navigate to previous message in the conversation
188+ mention = ' @' , -- Insert mention (file/agent)
189+ mention_file = ' ~' , -- Pick a file and add to context. See File Mentions section
190+ slash_commands = ' /' , -- Pick a command to run in the input window
191+ toggle_pane = ' <tab>' , -- Toggle between input and output panes
192+ prev_prompt_history = ' <up>' , -- Navigate to previous prompt in history
193+ next_prompt_history = ' <down>' , -- Navigate to next prompt in history
194+ switch_mode = ' <M-m>' , -- Switch between modes (build/plan)
195+ focus_input = ' <C-i>' , -- Focus on input window and enter insert mode at the end of the input from the output window
196+ select_child_session = ' <leader>oS' , -- Select and load a child session
197+ debug_message = ' <leader>oD' , -- Open raw message in new buffer for debugging
198+ debug_output = ' <leader>oO' , -- Open raw output in new buffer for debugging
199+ permission_accept = ' a' , -- Accept permission request once (only available when there is a pending permission request)
200+ permission_accept_all = ' A' , -- Accept all (for current tool) permission request once (only available when there is a pending permission request)
201+ permission_deny = ' d' ,-- Accept permission request once (only available when there is a pending permission request)
202+ debug_session = ' <leader>ods' , -- Debug session info
156203 },
157204 },
158205 ui = {
@@ -165,8 +212,8 @@ require('opencode').setup({
165212 display_cost = true , -- Display cost in the footer
166213 window_highlight = ' Normal:OpencodeBackground,FloatBorder:OpencodeBorder' , -- Highlight group for the opencode window
167214 icons = {
168- preset = ' emoji ' , -- 'emoji' | 'text'. Choose UI icon style (default: 'emoji ')
169- overrides = {}, -- Optional per-key overrides, see section below
215+ preset = ' nerdfonts ' , -- 'emoji' | 'nerdfonts' | ' text'. Choose UI icon style (default: 'nerdfonts ')
216+ overrides = {}, -- Optional per-key overrides, see section below
170217 },
171218 output = {
172219 tools = {
@@ -175,11 +222,12 @@ require('opencode').setup({
175222 },
176223 input = {
177224 text = {
178- wrap = false , -- Wraps text inside input window
225+ wrap = true , -- Wraps text inside input window
179226 },
180227 },
181228 completion = {
182229 file_sources = {
230+ cache_timeout = 300 , -- seconds
183231 enabled = true ,
184232 preferred_cli_tool = ' fd' , -- 'fd','fdfind','rg','git' if nil, it will use the best available tool
185233 ignore_patterns = {
@@ -215,25 +263,109 @@ require('opencode').setup({
215263 },
216264 context = {
217265 enabled = true , -- Enable automatic context capturing
266+ plugin_versions = {
267+ enabled = false , -- Include plugin versions in context
268+ limit = 20 , -- Max number of plugins to include
269+ },
218270 cursor_data = {
219271 enabled = false , -- Include cursor position and line content in the context
220272 },
221273 diagnostics = {
222- info = false , -- Include diagnostics info in the context (default to false
223- warn = true , -- Include diagnostics warnings in the context
274+ info = false , -- Include diagnostics info in the context (default to false)
275+ warning = true , -- Include diagnostics warnings in the context
224276 error = true , -- Include diagnostics errors in the context
225277 },
226278 current_file = {
227279 enabled = true , -- Include current file path and content in the context
280+ show_full_path = true , -- Show full file path instead of relative
281+ },
282+ files = {
283+ enabled = true , -- Include mentioned files in context
284+ show_full_path = true , -- Show full file path instead of relative
228285 },
229286 selection = {
230287 enabled = true , -- Include selected text in the context
231288 },
289+ -- Enhanced context options (enabled by default where applicable)
290+ marks = {
291+ enabled = true , -- Include the most recently accessed marks
292+ limit = 5 ,
293+ },
294+ jumplist = {
295+ enabled = true , -- Include the last jumps
296+ limit = 5 ,
297+ },
298+ recent_buffers = {
299+ enabled = true , -- Include the most recently accessed buffers
300+ symbols_only = true , -- Include only buffers with symbols (functions, classes, etc.)
301+ limit = 3 ,
302+ },
303+ undo_history = {
304+ enabled = true , -- Include the last undo branches/changesets
305+ limit = 3 ,
306+ },
307+ windows_tabs = {
308+ enabled = true , -- Include active windows and tabs information
309+ },
310+ highlights = {
311+ enabled = true , -- Include buffer line highlights in current viewport
312+ },
313+ session_info = {
314+ enabled = false , -- Include current session name if active
315+ },
316+ registers = {
317+ enabled = true , -- Include contents of specified registers
318+ include = { ' "' , ' /' , ' q' , ' 0' , ' 1' , ' 2' , ' 3' , ' 4' , ' 5' , ' 6' , ' 7' , ' 8' , ' 9' , ' %' , ' #' , ' .' }, -- Registers to include
319+ },
320+ command_history = {
321+ enabled = true , -- Include the last executed commands
322+ limit = 3 ,
323+ },
324+ search_history = {
325+ enabled = true , -- Include the last search patterns
326+ limit = 3 ,
327+ },
328+ debug_data = {
329+ enabled = true , -- Include active nvim-dap debugging sessions and breakpoints
330+ },
331+ lsp_context = {
332+ enabled = false , -- Include LSP diagnostics and code actions
333+ diagnostics_limit = 10 , -- Max diagnostics to include
334+ code_actions = false , -- Include available code actions at cursor
335+ },
336+ git_info = {
337+ enabled = true , -- Include git branch, file diff, and recent changes
338+ diff_limit = 10 , -- Max lines of file diff to include
339+ changes_limit = 5 , -- Number of recent commits to include
340+ },
341+ fold_info = {
342+ enabled = true , -- Include visible fold information in viewport
343+ },
344+ cursor_surrounding = {
345+ enabled = true , -- Include lines around cursor position
346+ lines_above = 4 , -- Lines to include above cursor
347+ lines_below = 4 , -- Lines to include below cursor
348+ },
349+ quickfix_loclist = {
350+ enabled = true , -- Include quickfix and location list entries
351+ limit = 5 ,
352+ },
353+ macros = {
354+ enabled = false , -- Include recorded macro content
355+ register = ' q' , -- Macro register to include
356+ },
357+ terminal_buffers = {
358+ enabled = true , -- Include most recently used terminal buffer details
359+ },
360+ session_duration = {
361+ enabled = false , -- Include time spent in current Neovim session
362+ },
232363 },
233364 debug = {
234365 enabled = false , -- Enable debug messages in the output window
235366 },
236367})
368+
237369```
238370
239371### Keymap Configuration
@@ -400,15 +532,59 @@ Opencode can issue permission requests for potentially destructive operations (f
400532
401533The following editor context is automatically captured and included in your conversations.
402534
403- | Context Type | Description |
404- | --------------- | ---------------------------------------------------- |
405- | Current file | Path to the focused file before entering opencode |
406- | Selected text | Text and lines currently selected in visual mode |
407- | Mentioned files | File info added through [ mentions] ( #file-mentions ) |
408- | Diagnostics | Diagnostics from the current file (if any) |
409- | Cursor position | Current cursor position and line content in the file |
535+ ### Core Context (Enabled by Default)
536+
537+ | Context Type | Description | Configuration Key |
538+ | --------------- | ---------------------------------------------------- | ---------------------- |
539+ | Current file | Path to the focused file before entering opencode | ` current_file.enabled ` |
540+ | Selected text | Text and lines currently selected in visual mode | ` selection.enabled ` |
541+ | Mentioned files | File info added through [ mentions] ( #file-mentions ) | N/A (always available) |
542+ | Diagnostics | Diagnostics from the current file (if any) | ` diagnostics ` |
543+ | Cursor position | Current cursor position and line content in the file | ` cursor_data.enabled ` |
544+
545+ ### Enhanced Context (Disabled by Default)
546+
547+ These additional context types can be enabled to provide even more information to the AI:
548+
549+ | Context Type | Description | Configuration Key |
550+ | ------------------ | ----------------------------------------------------- | ---------------------------- |
551+ | Marks | 10 most recently accessed marks | ` marks.enabled ` |
552+ | Jumplist | Last 10 jumps in the jump list | ` jumplist.enabled ` |
553+ | Recent Buffers | 10 most recently accessed buffers | ` recent_buffers.enabled ` |
554+ | Undo History | Last 10 undo branches or changesets | ` undo_history.enabled ` |
555+ | Windows & Tabs | Information about active windows and tabs | ` windows_tabs.enabled ` |
556+ | Highlights | Buffer line highlights in current viewport | ` highlights.enabled ` |
557+ | Session Info | Current Neovim session name if active | ` session_info.enabled ` |
558+ | Registers | Contents of specified registers (e.g., ` " ` , ` / ` , ` q ` ) | ` registers.enabled ` |
559+ | Command History | Last 5 executed Vim commands | ` command_history.enabled ` |
560+ | Search History | Last 5 search patterns | ` search_history.enabled ` |
561+ | Debug Data | Active nvim-dap debugging sessions and breakpoints | ` debug_data.enabled ` |
562+ | LSP Context | LSP diagnostics and available code actions | ` lsp_context.enabled ` |
563+ | Git Info | Current branch, file diff, and recent commits | ` git_info.enabled ` |
564+ | Fold Info | Visible folds in current viewport | ` fold_info.enabled ` |
565+ | Cursor Surrounding | Lines above and below cursor position | ` cursor_surrounding.enabled ` |
566+ | Quickfix/Loclist | Quickfix and location list entries | ` quickfix_loclist.enabled ` |
567+ | Macros | Recorded macro content from specified register | ` macros.enabled ` |
568+ | Terminal Buffers | Most recently used terminal buffer details | ` terminal_buffers.enabled ` |
569+ | Session Duration | Time spent in current Neovim session | ` session_duration.enabled ` |
570+
571+ To enable any of these enhanced context types, add them to your configuration:
572+
573+ ``` lua
574+ require (' opencode' ).setup ({
575+ context = {
576+ -- Enable specific enhanced context types
577+ marks = { enabled = true , limit = 10 },
578+ jumplist = { enabled = true , limit = 10 },
579+ git_info = { enabled = true , diff_limit = 10 , changes_limit = 5 },
580+ lsp_context = { enabled = true , diagnostics_limit = 10 , code_actions = true },
581+ cursor_surrounding = { enabled = true , lines_above = 3 , lines_below = 3 },
582+ -- ... enable others as needed
583+ },
584+ })
585+ ```
410586
411- < a id = " file-mentions " ></ a >
587+ ** Note: ** Enhanced context types are disabled by default to minimize token usage and API costs. Enable only the context types that are relevant to your workflow.
412588
413589### Adding more files to context through file mentions
414590
0 commit comments