Skip to content

Commit ba1ba56

Browse files
committed
feat(config): add configurable server timeout
Make the promise timeout for the server start configurable This should fix #79
1 parent 4b7187d commit ba1ba56

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ require('opencode').setup({
237237
enabled = true, -- Include selected text in the context
238238
},
239239
},
240+
server = {
241+
startup_timeout_ms = 5000, -- Timeout for starting opencode server before raisong an error(in milliseconds)},
242+
},
240243
debug = {
241244
enabled = false, -- Enable debug messages in the output window
242245
},

lua/opencode/config.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ M.defaults = {
163163
enabled = true,
164164
},
165165
},
166+
server = {
167+
startup_timeout_ms = 5000,
168+
},
166169
debug = {
167170
enabled = false,
168171
capture_streamed_events = false,

lua/opencode/server_job.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ function M.stream_api(url, method, body, on_chunk)
129129
end
130130

131131
function M.ensure_server()
132+
local config = require('opencode.config') --[[@as OpencodeConfig]]
132133
if state.opencode_server and state.opencode_server:is_running() then
133134
return state.opencode_server
134135
end
@@ -148,7 +149,7 @@ function M.ensure_server()
148149
end,
149150
})
150151

151-
return promise:wait()
152+
return promise:wait(config.server.startup_timeout_ms or 5000)
152153
end
153154

154155
return M

lua/opencode/types.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@
118118
---@field current_file { enabled: boolean, show_full_path: boolean }
119119
---@field selection { enabled: boolean }
120120

121+
---@class OpencodeConfigServerConfig
122+
---@field startup_timeout_ms integer,
123+
121124
---@class OpencodeDebugConfig
122125
---@field enabled boolean
123126

@@ -140,6 +143,7 @@
140143
---@field keymap OpencodeKeymap
141144
---@field ui OpencodeUIConfig
142145
---@field context OpencodeContextConfig
146+
---@field server OpencodeConfigServerConfig
143147
---@field debug OpencodeDebugConfig
144148

145149
---@class MessagePartState

0 commit comments

Comments
 (0)