Skip to content

Commit f30c47a

Browse files
Danilo Verde RibeiroDanilo Verde Ribeiro
authored andcommitted
Merge branch 'enhanced-context'
2 parents 34edf5d + 0d102c0 commit f30c47a

6 files changed

Lines changed: 230 additions & 74 deletions

File tree

README.md

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ require('opencode').setup({
115115
diff_revert_this_last_prompt = '<leader>ort', -- Revert current file changes since the last opencode prompt
116116
diff_revert_all = '<leader>orA', -- Revert all file changes since the last opencode session
117117
diff_revert_this = '<leader>orT', -- Revert current file changes since the last opencode session
118+
diff_restore_snapshot_file = '<leader>orr', -- Restore file to snapshot
119+
diff_restore_snapshot_all = '<leader>orR', -- Restore all files to snapshot
120+
open_configuration_file = '<leader>oC', -- Open opencode configuration file
118121
swap_position = '<leader>ox', -- Swap Opencode pane left/right
119122
},
120123
window = {
@@ -135,6 +138,7 @@ require('opencode').setup({
135138
select_child_session = '<leader>oS', -- Select and load a child session
136139
debug_message = '<leader>oD', -- Open raw message in new buffer for debugging
137140
debug_output = '<leader>oO', -- Open raw output in new buffer for debugging
141+
debug_session = '<leader>ods', -- Debug session info
138142
},
139143
},
140144
ui = {
@@ -147,7 +151,7 @@ require('opencode').setup({
147151
display_cost = true, -- Display cost in the footer
148152
window_highlight = 'Normal:OpencodeBackground,FloatBorder:OpencodeBorder', -- Highlight group for the opencode window
149153
icons = {
150-
preset = 'emoji', -- 'emoji' | 'text'. Choose UI icon style (default: 'emoji')
154+
preset = 'nerdfonts', -- 'emoji' | 'nerdfonts' | 'text'. Choose UI icon style (default: 'nerdfonts')
151155
overrides = {}, -- Optional per-key overrides, see section below
152156
},
153157
output = {
@@ -157,11 +161,12 @@ require('opencode').setup({
157161
},
158162
input = {
159163
text = {
160-
wrap = false, -- Wraps text inside input window
164+
wrap = true, -- Wraps text inside input window
161165
},
162166
},
163167
completion = {
164168
file_sources = {
169+
cache_timeout = 300, -- seconds
165170
enabled = true,
166171
preferred_cli_tool = 'fd', -- 'fd','fdfind','rg','git' if nil, it will use the best available tool
167172
ignore_patterns = {
@@ -197,89 +202,99 @@ require('opencode').setup({
197202
},
198203
context = {
199204
enabled = true, -- Enable automatic context capturing
205+
plugin_versions = {
206+
enabled = false, -- Include plugin versions in context
207+
limit = 20, -- Max number of plugins to include
208+
},
200209
cursor_data = {
201210
enabled = false, -- Include cursor position and line content in the context
202211
},
203212
diagnostics = {
204-
info = false, -- Include diagnostics info in the context (default to false
205-
warn = true, -- Include diagnostics warnings in the context
213+
info = false, -- Include diagnostics info in the context (default to false)
214+
warning = true, -- Include diagnostics warnings in the context
206215
error = true, -- Include diagnostics errors in the context
207216
},
208217
current_file = {
209218
enabled = true, -- Include current file path and content in the context
219+
show_full_path = true, -- Show full file path instead of relative
220+
},
221+
files = {
222+
enabled = true, -- Include mentioned files in context
223+
show_full_path = true, -- Show full file path instead of relative
210224
},
211225
selection = {
212226
enabled = true, -- Include selected text in the context
213227
},
214-
-- Enhanced context options (all disabled by default)
228+
-- Enhanced context options (enabled by default where applicable)
215229
marks = {
216-
enabled = false, -- Include the 10 most recently accessed marks
217-
limit = 10,
230+
enabled = true, -- Include the most recently accessed marks
231+
limit = 5,
218232
},
219233
jumplist = {
220-
enabled = false, -- Include the last 10 jumps
221-
limit = 10,
234+
enabled = true, -- Include the last jumps
235+
limit = 5,
222236
},
223237
recent_buffers = {
224-
enabled = false, -- Include the 10 most recently accessed buffers
225-
limit = 10,
238+
enabled = true, -- Include the most recently accessed buffers
239+
symbols_only = true, -- Include only buffers with symbols (functions, classes, etc.)
240+
limit = 3,
226241
},
227242
undo_history = {
228-
enabled = false, -- Include the last 10 undo branches/changesets
229-
limit = 10,
243+
enabled = true, -- Include the last undo branches/changesets
244+
limit = 3,
230245
},
231246
windows_tabs = {
232-
enabled = false, -- Include active windows and tabs information
247+
enabled = true, -- Include active windows and tabs information
233248
},
234249
highlights = {
235-
enabled = false, -- Include buffer line highlights in current viewport
250+
enabled = true, -- Include buffer line highlights in current viewport
236251
},
237252
session_info = {
238253
enabled = false, -- Include current session name if active
239254
},
240255
registers = {
241-
enabled = false, -- Include contents of specified registers
242-
include = { '"', '/', 'q' }, -- Registers to include
256+
enabled = true, -- Include contents of specified registers
257+
include = { '"', '/', 'q', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '%', '#', '.' }, -- Registers to include
243258
},
244259
command_history = {
245-
enabled = false, -- Include the last 5 executed commands
246-
limit = 5,
260+
enabled = true, -- Include the last executed commands
261+
limit = 3,
247262
},
248263
search_history = {
249-
enabled = false, -- Include the last 5 search patterns
250-
limit = 5,
264+
enabled = true, -- Include the last search patterns
265+
limit = 3,
251266
},
252267
debug_data = {
253-
enabled = false, -- Include active nvim-dap debugging sessions and breakpoints
268+
enabled = true, -- Include active nvim-dap debugging sessions and breakpoints
254269
},
255270
lsp_context = {
256271
enabled = false, -- Include LSP diagnostics and code actions
257272
diagnostics_limit = 10, -- Max diagnostics to include
258273
code_actions = false, -- Include available code actions at cursor
259274
},
260275
git_info = {
261-
enabled = false, -- Include git branch, file diff, and recent changes
276+
enabled = true, -- Include git branch, file diff, and recent changes
262277
diff_limit = 10, -- Max lines of file diff to include
263278
changes_limit = 5, -- Number of recent commits to include
264279
},
265280
fold_info = {
266-
enabled = false, -- Include visible fold information in viewport
281+
enabled = true, -- Include visible fold information in viewport
267282
},
268283
cursor_surrounding = {
269-
enabled = false, -- Include lines around cursor position
270-
lines_above = 3, -- Lines to include above cursor
271-
lines_below = 3, -- Lines to include below cursor
284+
enabled = true, -- Include lines around cursor position
285+
lines_above = 4, -- Lines to include above cursor
286+
lines_below = 4, -- Lines to include below cursor
272287
},
273288
quickfix_loclist = {
274-
enabled = false, -- Include quickfix and location list entries
289+
enabled = true, -- Include quickfix and location list entries
275290
limit = 5,
276291
},
277292
macros = {
278293
enabled = false, -- Include recorded macro content
279294
register = 'q', -- Macro register to include
280295
},
281296
terminal_buffers = {
282-
enabled = false, -- Include most recently used terminal buffer details
297+
enabled = true, -- Include most recently used terminal buffer details
283298
},
284299
session_duration = {
285300
enabled = false, -- Include time spent in current Neovim session
@@ -289,6 +304,7 @@ require('opencode').setup({
289304
enabled = false, -- Enable debug messages in the output window
290305
},
291306
})
307+
292308
```
293309

294310
### UI icons (disable emojis or customize)

lua/opencode/config.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ M.defaults = {
131131
},
132132
context = {
133133
enabled = true,
134+
-- Idle threshold in milliseconds for automatic context updates
135+
-- Context will be updated after this period of user inactivity
136+
idle_threshold = 10000, -- 10 seconds
137+
-- Cache TTL in milliseconds for expensive context operations
138+
-- Set to 0 to disable caching
139+
cache_ttl = {
140+
git_info = 5000, -- 5 seconds
141+
plugin_versions = 60000, -- 60 seconds
142+
highlights = 2000, -- 2 seconds
143+
lsp_symbols = 10000, -- 10 seconds
144+
},
134145
plugin_versions = {
135146
enabled = false,
136147
limit = 20,
@@ -175,7 +186,7 @@ M.defaults = {
175186
enabled = true,
176187
},
177188
highlights = {
178-
enabled = true,
189+
enabled = false,
179190
},
180191
session_info = {
181192
enabled = false,
@@ -201,8 +212,8 @@ M.defaults = {
201212
code_actions = false,
202213
},
203214
git_info = {
204-
enabled = true,
205-
diff_limit = 10,
215+
enabled = false,
216+
diff_limit = 5,
206217
changes_limit = 5,
207218
},
208219
fold_info = {

0 commit comments

Comments
 (0)