Skip to content

Commit b882a01

Browse files
committed
refactor(config): move on_data_rendered
So it's under ui.output.rendering
1 parent fb420c8 commit b882a01

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ require('opencode').setup({
174174
},
175175
rendering = {
176176
markdown_debounce_ms = 250, -- Debounce time for markdown rendering on new data (default: 250ms)
177+
on_data_rendered = nil, -- Called when new data is rendered; set to false to disable default RenderMarkdown/Markview behavior
177178
},
178179
},
179180
input = {
@@ -214,7 +215,7 @@ require('opencode').setup({
214215
max_files = 10,
215216
max_display_length = 50, -- Maximum length for file path display in completion, truncates from left with "..."
216217
},
217-
on_data_rendered = nil, -- Called when new data is rendered (debounced to 250ms), useful to trigger markdown rendering. Set to false to disable default behavior of checking for RenderMarkdown and Markview
218+
218219
},
219220
},
220221
context = {

lua/opencode/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ M.defaults = {
9393
output = {
9494
rendering = {
9595
markdown_debounce_ms = 250,
96+
on_data_rendered = nil,
9697
},
9798
tools = {
9899
show_output = true,
@@ -102,7 +103,6 @@ M.defaults = {
102103
text = {
103104
wrap = false,
104105
},
105-
on_data_rendered = nil,
106106
},
107107
completion = {
108108
file_sources = {

lua/opencode/types.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@
9595
---@field output OpencodeUIOutputConfig
9696
---@field input { text: { wrap: boolean } }
9797
---@field completion OpencodeCompletionConfig
98-
---@field on_data_rendered fun(ctx: { buf: integer, win: integer })|nil
98+
9999

100100
---@class OpencodeUIOutputConfig
101101
---@field tools { show_output: boolean }
102-
---@field rendering { markdown_debounce_ms: number }
102+
---@field rendering { markdown_debounce_ms: number, on_data_rendered: (fun(buf: integer, win: integer)|boolean)|nil }
103103

104104
---@class OpencodeContextConfig
105105
---@field enabled boolean

lua/opencode/ui/renderer.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ M._render_state = RenderState.new()
1313
M._disable_auto_scroll = false
1414

1515
local trigger_on_data_rendered = require('opencode.util').debounce(function()
16-
local cb_type = type(config.ui.on_data_rendered)
16+
local cb_type = type(config.ui.output.rendering.on_data_rendered)
1717

1818
if cb_type == 'boolean' then
1919
return
@@ -24,7 +24,7 @@ local trigger_on_data_rendered = require('opencode.util').debounce(function()
2424
end
2525

2626
if cb_type == 'function' then
27-
pcall(config.ui.on_data_rendered, state.windows.output_buf, state.windows.output_win)
27+
pcall(config.ui.output.rendering.on_data_rendered, state.windows.output_buf, state.windows.output_win)
2828
elseif vim.fn.exists(':RenderMarkdown') > 0 then
2929
vim.cmd(':RenderMarkdown')
3030
elseif vim.fn.exists(':Markview') > 0 then

0 commit comments

Comments
 (0)