Skip to content

Commit 7f27e47

Browse files
committed
style: apply stylua formatting for lint stability
1 parent 371dbce commit 7f27e47

18 files changed

Lines changed: 139 additions & 96 deletions

lua/opencode/commands/dispatch.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ local function run_hook(stage, hook_id, hook_fn, ctx)
104104
if not ok then
105105
-- Keep observer failures isolated so command execution stays deterministic.
106106
local command_name = (ctx.intent and ctx.intent.name) or 'unknown'
107-
log.warn('event=command_hook_error command=%s stage=%s hook_id=%s error=%s', command_name, stage, hook_id, tostring(next_ctx_or_err))
107+
log.warn(
108+
'event=command_hook_error command=%s stage=%s hook_id=%s error=%s',
109+
command_name,
110+
stage,
111+
hook_id,
112+
tostring(next_ctx_or_err)
113+
)
108114
emit_lifecycle_event('custom.command.hook_error', {
109115
stage = stage,
110116
hook_id = hook_id,

lua/opencode/commands/handlers/agent.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ M.command_defs = {
9494
execute = M.actions.configure_provider,
9595
},
9696
-- action name aliases for keymap compatibility
97-
configure_provider = { desc = 'Configure provider', execute = M.actions.configure_provider },
98-
configure_variant = { desc = 'Configure model variant', execute = M.actions.configure_variant },
97+
configure_provider = { desc = 'Configure provider', execute = M.actions.configure_provider },
98+
configure_variant = { desc = 'Configure model variant', execute = M.actions.configure_variant },
9999
variant = {
100100
desc = 'Switch model variant',
101101
execute = M.actions.configure_variant,

lua/opencode/commands/handlers/diff.lua

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,18 @@ M.command_defs = {
229229
end,
230230
},
231231
-- action name aliases for keymap compatibility
232-
diff_open = { desc = 'Open diff view', execute = M.actions.diff_open },
233-
diff_next = { desc = 'Next diff', execute = M.actions.diff_next },
234-
diff_prev = { desc = 'Previous diff', execute = M.actions.diff_prev },
235-
diff_close = { desc = 'Close diff view', execute = M.actions.diff_close },
236-
diff_revert_all_last_prompt = { desc = 'Revert all (last prompt)', execute = M.actions.diff_revert_all_last_prompt },
237-
diff_revert_this_last_prompt = { desc = 'Revert this (last prompt)', execute = M.actions.diff_revert_this_last_prompt },
232+
diff_open = { desc = 'Open diff view', execute = M.actions.diff_open },
233+
diff_next = { desc = 'Next diff', execute = M.actions.diff_next },
234+
diff_prev = { desc = 'Previous diff', execute = M.actions.diff_prev },
235+
diff_close = { desc = 'Close diff view', execute = M.actions.diff_close },
236+
diff_revert_all_last_prompt = {
237+
desc = 'Revert all (last prompt)',
238+
execute = M.actions.diff_revert_all_last_prompt,
239+
},
240+
diff_revert_this_last_prompt = {
241+
desc = 'Revert this (last prompt)',
242+
execute = M.actions.diff_revert_this_last_prompt,
243+
},
238244
}
239245

240246
return M

lua/opencode/commands/handlers/session.lua

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ local M = {
1010
actions = {},
1111
}
1212

13-
local session_subcommands = { 'new', 'select', 'child', 'sibling', 'parent', 'compact', 'share', 'unshare', 'agents_init', 'rename' }
13+
local session_subcommands =
14+
{ 'new', 'select', 'child', 'sibling', 'parent', 'compact', 'share', 'unshare', 'agents_init', 'rename' }
1415

1516
---@param message string
1617
local function invalid_arguments(message)
@@ -70,11 +71,9 @@ end
7071
---@param request_promise Promise<any>
7172
---@param error_prefix string
7273
local function run_api_action_with_checktime(request_promise, error_prefix)
73-
request_promise
74-
:and_then(schedule_checktime)
75-
:catch(function(err)
76-
notify_error(error_prefix, err)
77-
end)
74+
request_promise:and_then(schedule_checktime):catch(function(err)
75+
notify_error(error_prefix, err)
76+
end)
7877
end
7978

8079
function M.actions.open_input_new_session()
@@ -335,7 +334,10 @@ function M.actions.redo()
335334

336335
local next_message_id = find_next_message_for_redo(state_obj)
337336
if not next_message_id then
338-
run_api_action_with_checktime(state_obj.api_client:unrevert_messages(active_session.id), 'Failed to redo message: ')
337+
run_api_action_with_checktime(
338+
state_obj.api_client:unrevert_messages(active_session.id),
339+
'Failed to redo message: '
340+
)
339341
return
340342
end
341343

@@ -466,11 +468,21 @@ M.command_defs = {
466468
},
467469
-- action name aliases for keymap compatibility
468470
open_input_new_session = { desc = 'Open input (new session)', execute = M.actions.open_input_new_session },
469-
select_session = { desc = 'Select session', execute = function() return M.actions.select_session() end },
470-
select_child_session = { desc = 'Select child session', execute = M.actions.select_child_session },
471-
select_sibling_session = { desc = 'Select sibling session', execute = M.actions.select_sibling_session },
472-
select_parent_session = { desc = 'Go to parent session', execute = M.actions.select_parent_session },
473-
rename_session = { desc = 'Rename session', execute = function(args) return M.actions.rename_session(nil, args[1]) end },
471+
select_session = {
472+
desc = 'Select session',
473+
execute = function()
474+
return M.actions.select_session()
475+
end,
476+
},
477+
select_child_session = { desc = 'Select child session', execute = M.actions.select_child_session },
478+
select_sibling_session = { desc = 'Select sibling session', execute = M.actions.select_sibling_session },
479+
select_parent_session = { desc = 'Go to parent session', execute = M.actions.select_parent_session },
480+
rename_session = {
481+
desc = 'Rename session',
482+
execute = function(args)
483+
return M.actions.rename_session(nil, args[1])
484+
end,
485+
},
474486
undo = {
475487
desc = 'Undo last action',
476488
execute = function(args)

lua/opencode/commands/handlers/window.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ M.actions.toggle = Promise.async(function(new_session)
9090

9191
local function open_windows(restore_hidden)
9292
local ctx = build_toggle_open_context(restore_hidden == true)
93-
return session_runtime
94-
.open({
93+
return session_runtime
94+
.open({
9595
new_session = is_new_session,
9696
focus = ctx.focus,
9797
start_insert = false,
@@ -132,7 +132,7 @@ end)
132132
function M.actions.toggle_focus(new_session)
133133
if not ui.is_opencode_focused() then
134134
local focus = state.last_focused_opencode_window or 'input' ---@cast focus 'input' | 'output'
135-
session_runtime.open({ new_session = new_session == true, focus = focus })
135+
session_runtime.open({ new_session = new_session == true, focus = focus })
136136
else
137137
ui.return_to_last_code_win()
138138
end
@@ -183,7 +183,7 @@ M.command_defs = {
183183
end,
184184
},
185185
-- action name aliases for keymap compatibility
186-
open_input = { desc = 'Open input window', execute = M.actions.open_input },
186+
open_input = { desc = 'Open input window', execute = M.actions.open_input },
187187
open_output = { desc = 'Open output window', execute = M.actions.open_output },
188188
close = {
189189
desc = 'Close opencode windows',

lua/opencode/context/base_context.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ function M.get_current_cursor_data(buf, win, context_config)
171171
return nil
172172
end
173173

174-
local num_lines = config.context.cursor_data.context_lines --[[@as integer]]
175-
or 0
174+
local num_lines = config.context.cursor_data.context_lines --[[@as integer]] or 0
176175
local cursor_pos = vim.fn.getcurpos(win)
177176
local start_line = (cursor_pos[2] - 1) --[[@as integer]]
178177
local cursor_content = vim.api.nvim_buf_get_lines(buf, start_line, cursor_pos[2], false)[1] or ''

lua/opencode/lsp/opencode_ls.lua

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ end
9696
---@return OpencodeLspItem
9797
local function to_lsp_item(item, index, params, word)
9898
local source = require('opencode.ui.completion').get_source_by_name(item.source_name)
99-
local kind = (source and source.custom_kind) or
100-
vim.lsp.protocol.CompletionItemKind.Function ---@type lsp.CompletionItemKind
99+
local kind = (source and source.custom_kind) or vim.lsp.protocol.CompletionItemKind.Function ---@type lsp.CompletionItemKind
101100
local priority = source and source.priority or 999
102101
local line = params.position.line
103102
local col = params.position.character
@@ -167,29 +166,29 @@ handlers[ms.textDocument_completion] = function(params, callback)
167166
end
168167

169168
Promise.all(promises)
170-
:and_then(function(results)
171-
---@type OpencodeLspItem[]
172-
local all_items = {}
173-
local is_incomplete = false
174-
175-
for _, items in ipairs(results) do
176-
for j, item in ipairs(items or {}) do
177-
local source = completion.get_source_by_name(item.source_name)
178-
if source and source.is_incomplete then
179-
is_incomplete = true
180-
end
181-
182-
table.insert(all_items, to_lsp_item(item, j, params, word))
169+
:and_then(function(results)
170+
---@type OpencodeLspItem[]
171+
local all_items = {}
172+
local is_incomplete = false
173+
174+
for _, items in ipairs(results) do
175+
for j, item in ipairs(items or {}) do
176+
local source = completion.get_source_by_name(item.source_name)
177+
if source and source.is_incomplete then
178+
is_incomplete = true
183179
end
180+
181+
table.insert(all_items, to_lsp_item(item, j, params, word))
184182
end
183+
end
185184

186-
callback(nil, { isIncomplete = is_incomplete, items = all_items })
187-
end)
188-
:catch(function(err)
189-
local log = require('opencode.log')
190-
log.error('Error in completion handler: ' .. tostring(err))
191-
callback(nil, { isIncomplete = false, items = {} })
192-
end)
185+
callback(nil, { isIncomplete = is_incomplete, items = all_items })
186+
end)
187+
:catch(function(err)
188+
local log = require('opencode.log')
189+
log.error('Error in completion handler: ' .. tostring(err))
190+
callback(nil, { isIncomplete = false, items = {} })
191+
end)
193192
end
194193

195194
---Create the LSP server configuration
@@ -237,7 +236,7 @@ function M.start(bufnr)
237236
local completed_item = vim.v.completed_item
238237
if completed_item and completed_item.user_data then
239238
local data = vim.tbl_get(completed_item, 'user_data', 'nvim', 'lsp', 'completion_item', 'data')
240-
or vim.tbl_get(completed_item, 'user_data', 'lsp', 'item', 'data')
239+
or vim.tbl_get(completed_item, 'user_data', 'lsp', 'item', 'data')
241240

242241
local item = data and data._opencode_item
243242

lua/opencode/ui/base_picker.lua

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ local function telescope_ui(opts)
148148
sorter = conf.generic_sorter({}),
149149
previewer = opts.preview == 'file' and require('telescope.previewers').vim_buffer_vimgrep.new({}) or nil,
150150
layout_config = opts.width and {
151-
width = opts.width + 7, -- extra space for telescope UI
152-
} or nil,
151+
width = opts.width + 7, -- extra space for telescope UI
152+
} or nil,
153153
attach_mappings = function(prompt_bufnr, map)
154154
opts.close = function()
155155
selection_made = true
@@ -243,8 +243,8 @@ local function fzf_ui(opts)
243243

244244
return {
245245
winopts = opts.width and {
246-
width = opts.width + 8, -- extra space for fzf UI
247-
} or nil,
246+
width = opts.width + 8, -- extra space for fzf UI
247+
} or nil,
248248
fzf_opts = {
249249
['--prompt'] = opts.title .. ' > ',
250250
['--multi'] = has_multi_action and true or nil,
@@ -456,13 +456,11 @@ local function mini_pick_ui(opts)
456456
local selection_made = false
457457

458458
mini_pick.start({
459-
window = opts.width
460-
and {
461-
config = {
462-
width = opts.width + 2, -- extra space for mini.pick UI
463-
},
464-
}
465-
or nil,
459+
window = opts.width and {
460+
config = {
461+
width = opts.width + 2, -- extra space for mini.pick UI
462+
},
463+
} or nil,
466464
source = {
467465
items = items,
468466
name = opts.title,

lua/opencode/ui/completion/sort.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,3 @@ function M.sort_by_relevance(items, input, get_name, compare)
4343
end
4444

4545
return M
46-

lua/opencode/ui/permission_window.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ function M.restore_pending_permissions(session_id)
278278
return Promise.new():resolve(nil)
279279
end
280280

281-
return state.api_client:list_permissions()
281+
return state.api_client
282+
:list_permissions()
282283
:and_then(function(permissions)
283284
if not permissions or type(permissions) ~= 'table' then
284285
return

0 commit comments

Comments
 (0)