Skip to content

Commit 081ba07

Browse files
Danilo Verde RibeiroDanilo Verde Ribeiro
authored andcommitted
Merge branch 'upstream/main' into feat/extended
Resolved merge conflicts: - api_client.lua: accept upstream version (cleaner error handling) - config.lua: accept upstream version (removed unused get() function) - context.lua: accept upstream version (direct config import) - core.lua: accept upstream version (corrected state field names) - autocmds.lua: accept HEAD version (better performance with cached requires) - renderer.lua: accept HEAD version (improved synthetic part handling) - ui.lua: accept HEAD version (retain scroll_to_bottom and autocmd cleanup) - Deleted output_renderer.lua and session_formatter.lua (no longer referenced)
1 parent e555075 commit 081ba07

11 files changed

Lines changed: 196 additions & 3345 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ require('opencode').setup({
205205
session_picker = {
206206
delete_session = { '<C-d>' }, -- Delete selected session in the session picker
207207
},
208+
session_picker = {
209+
delete_session = { '<C-d>' }, -- Delete selected session in the session picker
210+
},
208211
},
209212
ui = {
210213
position = 'right', -- 'right' (default) or 'left'. Position of the UI split
@@ -217,7 +220,7 @@ require('opencode').setup({
217220
window_highlight = 'Normal:OpencodeBackground,FloatBorder:OpencodeBorder', -- Highlight group for the opencode window
218221
icons = {
219222
preset = 'nerdfonts', -- 'emoji' | 'nerdfonts' | 'text'. Choose UI icon style (default: 'nerdfonts')
220-
overrides = {}, -- Optional per-key overrides, see section below
223+
overrides = {}, -- Optional per-key overrides, see section below
221224
},
222225
output = {
223226
tools = {

lua/opencode/api.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ end
7777
---@param opts? SendMessageOpts
7878
function M.run_new_session(prompt, opts)
7979
opts = vim.tbl_deep_extend('force', { new_session = true, focus = 'output' }, opts or {})
80-
core.send_message(prompt, { new_session = true, focus = 'output' })
80+
core.send_message(prompt, opts)
8181
end
8282

8383
---@param parent_id? string

lua/opencode/api_client.lua

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ function OpencodeApiClient:_call(endpoint, method, body, query)
5151
if not self:_ensure_base_url() then
5252
return nil
5353
end
54-
if not self.base_url then
55-
error("OpenCode server URL is not available. Ensure the server is running.")
56-
end
57-
if not self.base_url then
58-
error("OpenCode server URL is not available. Ensure the server is running.")
59-
end
6054
local url = self.base_url .. endpoint
6155

6256
if query then
@@ -388,14 +382,6 @@ end
388382
--- @param on_event fun(event: table) Event callback
389383
--- @return Job The streaming job handle
390384
function OpencodeApiClient:subscribe_to_events(directory, on_event)
391-
if not self.base_url then
392-
local state = require('opencode.state')
393-
self.base_url = state.opencode_server_job.url:gsub('/$', '')
394-
end
395-
if not self.base_url then
396-
error("API client base_url is nil. Call OpencodeApiClient.new() after server startup.")
397-
return nil
398-
end
399385
self:_ensure_base_url()
400386
local url = self.base_url .. '/event'
401387
if directory then

lua/opencode/config.lua

Lines changed: 7 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,11 @@
1-
--- @field get fun(key: "preferred_completion"): 'blink' | 'nvim-cmp' | 'vim_complete' | nil
2-
--- @field get fun(key: "default_mode"): 'build' | 'plan'
3-
--- @field get fun(key: "default_global_keymaps"): boolean
4-
--- @field get fun(key: "keymap"): OpencodeKeymap
5-
--- @field get fun(key: "ui"): OpencodeUIConfig
6-
--- @field get fun(key: "providers"): OpencodeProviders
7-
--- @field get fun(key: "context"): OpencodeContextConfig
8-
--- @field get fun(key: "debug"): OpencodeDebugConfig
9-
10-
local M = {} ---@type OpencodeConfigModule
11-
12-
--- @class OpencodeConfigModule
13-
--- @field defaults OpencodeConfig
14-
--- @field values OpencodeConfig
15-
--- @field setup fun(opts?: OpencodeConfig): nil
16-
--- @field get fun(key: nil): OpencodeConfig
17-
--- @field get fun(key: "preferred_picker"): 'mini.pick' | 'telescope' | 'fzf' | 'snacks' | nil
18-
--- @field get fun(key: "preferred_completion"): 'blink' | 'nvim-cmp' | 'vim_complete' | nil
19-
--- @field get fun(key: "default_mode"): 'build' | 'plan' |
20-
--- @field get fun(key: "default_global_keymaps"): boolean
21-
--- @field get fun(key: "keymap"): OpencodeKeymap
22-
--- @field get fun(key: "ui"): OpencodeUIConfig
23-
--- @field get fun(key: "providers"): OpencodeProviders
24-
--- @field get fun(key: "context"): OpencodeContextConfig
25-
--- @field get fun(key: "debug"): OpencodeDebugConfig
26-
27-
local M = {} ---@type OpencodeConfigModule
1+
-- Default and user-provided settings for opencode.nvim
282

3+
---@type OpencodeConfigModule
4+
---@diagnostic disable-next-line: missing-fields
5+
local M = {}
296
-- Default configuration
307
---@type OpencodeConfig
318
M.defaults = {
32-
providers = {},
33-
custom_commands = {},
349
preferred_picker = nil,
3510
preferred_completion = nil,
3611
default_global_keymaps = true,
@@ -128,12 +103,11 @@ M.defaults = {
128103
},
129104
input = {
130105
text = {
131-
wrap = true,
106+
wrap = false,
132107
},
133108
},
134109
completion = {
135110
file_sources = {
136-
cache_timeout = 300, -- seconds
137111
enabled = true,
138112
preferred_cli_tool = 'server',
139113
ignore_patterns = {
@@ -169,27 +143,12 @@ M.defaults = {
169143
},
170144
context = {
171145
enabled = true,
172-
-- Idle threshold in milliseconds for automatic context updates
173-
-- Context will be updated after this period of user inactivity
174-
idle_threshold = 10000, -- 10 seconds
175-
-- Cache TTL in milliseconds for expensive context operations
176-
-- Set to 0 to disable caching
177-
cache_ttl = {
178-
git_info = 5000, -- 5 seconds
179-
plugin_versions = 60000, -- 60 seconds
180-
highlights = 2000, -- 2 seconds
181-
lsp_symbols = 10000, -- 10 seconds
182-
},
183-
plugin_versions = {
184-
enabled = false,
185-
limit = 20,
186-
},
187146
cursor_data = {
188-
enabled = true,
147+
enabled = false,
189148
},
190149
diagnostics = {
191150
info = false,
192-
warning = false,
151+
warning = true,
193152
error = true,
194153
},
195154
current_file = {
@@ -203,86 +162,6 @@ M.defaults = {
203162
selection = {
204163
enabled = true,
205164
},
206-
jumplist = {
207-
enabled = true,
208-
limit = 5,
209-
},
210-
recent_buffers = {
211-
enabled = true,
212-
limit = 3,
213-
symbols_only = true,
214-
},
215-
undo_history = {
216-
enabled = true,
217-
limit = 3,
218-
},
219-
windows_tabs = {
220-
enabled = true,
221-
},
222-
highlights = {
223-
enabled = true,
224-
},
225-
session_info = {
226-
enabled = false,
227-
},
228-
registers = {
229-
enabled = true,
230-
include = { '"', '/', 'q', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '%', '#', '.' },
231-
},
232-
command_history = {
233-
enabled = true,
234-
limit = 3,
235-
},
236-
search_history = {
237-
enabled = true,
238-
limit = 3,
239-
},
240-
debug_data = {
241-
enabled = true,
242-
},
243-
lsp_context = {
244-
enabled = false,
245-
diagnostics_limit = 10,
246-
code_actions = false,
247-
},
248-
git_info = {
249-
enabled = true,
250-
diff_limit = 10,
251-
changes_limit = 5,
252-
},
253-
fold_info = {
254-
enabled = true,
255-
},
256-
cursor_surrounding = {
257-
enabled = true,
258-
lines_above = 4,
259-
lines_below = 4,
260-
},
261-
quickfix_loclist = {
262-
enabled = true,
263-
limit = 5,
264-
},
265-
macros = {
266-
enabled = false,
267-
register = 'q',
268-
},
269-
terminal_buffers = {
270-
enabled = true,
271-
},
272-
session_duration = {
273-
enabled = false,
274-
},
275-
-- Remove duplicate configurations above - keeping only the final instances
276-
-- All configurations below this point are unique and should be kept as-is
277-
vectorcode_snippets = {
278-
enabled = false,
279-
n = 3,
280-
query_strategy = 'auto', -- 'auto', 'selection', 'line', 'filename'
281-
timeout = 5000, -- Timeout for async queries in milliseconds
282-
batch_mode = false, -- Enable batch querying for multiple snippets
283-
cache_results = true, -- Cache VectorCode results for performance
284-
background_refresh = true, -- Refresh snippets in background
285-
},
286165
},
287166
debug = {
288167
enabled = false,
@@ -408,11 +287,6 @@ function M.normalize_keymap(legacy_config, filter_functions)
408287
return converted
409288
end
410289

411-
---@return OpencodeConfig
412-
function M.get()
413-
return M.values
414-
end
415-
416290
---@export Config
417291
return setmetatable(M, {
418292
__index = function(_, key)

0 commit comments

Comments
 (0)