Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,12 @@ require('opencode').setup({
['<leader>orr'] = { 'diff_restore_snapshot_file' }, -- Restore a file to a restore point
['<leader>orR'] = { 'diff_restore_snapshot_all' }, -- Restore all files to a restore point
['<leader>ox'] = { 'swap_position' }, -- Swap Opencode pane left/right
['<leader>opa'] = { 'permission_accept' }, -- Accept permission request once
['<leader>opA'] = { 'permission_accept_all' }, -- Accept all (for current tool)
['<leader>opd'] = { 'permission_deny' }, -- Deny permission request once
['<leader>ott'] = { 'toggle_tool_output' }, -- Toggle tools output (diffs, cmd output, etc.)
['<leader>otr'] = { 'toggle_reasoning_output' }, -- Toggle reasoning output (thinking steps)
['<leader>o/'] = { 'quick_chat', mode = { 'n', 'x' } }, -- Open quick chat input with selection context in visual mode or current line context in normal mode
},
input_window = {
['<cr>'] = { 'submit_input_prompt', mode = { 'n', 'i' } }, -- Submit prompt (normal mode and insert mode)
['<S-cr>'] = { 'submit_input_prompt', mode = { 'n', 'i' } }, -- Submit prompt (normal mode and insert mode)
['<esc>'] = { 'close' }, -- Close UI windows
['<C-c>'] = { 'cancel' }, -- Cancel opencode request while it is running
['~'] = { 'mention_file', mode = 'i' }, -- Pick a file and add to context. See File Mentions section
Expand Down Expand Up @@ -178,15 +175,10 @@ require('opencode').setup({
['<leader>oO'] = { 'debug_output' }, -- Open raw output in new buffer for debugging
['<leader>ods'] = { 'debug_session' }, -- Open raw session in new buffer for debugging
},
permission = {
accept = 'a', -- Accept permission request once (only available when there is a pending permission request)
accept_all = 'A', -- Accept all (for current tool) permission request once (only available when there is a pending permission request)
deny = 'd', -- Deny permission request once (only available when there is a pending permission request)
},
session_picker = {
rename_session = { '<C-r>' }, -- Rename selected session in the session picker
delete_session = { '<C-d>' }, -- Delete selected session in the session picker
new_session = { '<C-n>' }, -- Create and switch to a new session in the session picker
new_session = { '<C-s>' }, -- Create and switch to a new session in the session picker
},
timeline_picker = {
undo = { '<C-u>', mode = { 'i', 'n' } }, -- Undo to selected message in timeline picker
Expand Down
15 changes: 15 additions & 0 deletions lua/opencode/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,21 @@ function M.permission_deny(permission)
M.respond_to_permission('reject', permission)
end

function M.question_answer()
local question_window = require('opencode.ui.question_window')
local question_info = question_window.get_current_question_info()
if question_info and question_info.options and question_info.options[1] then
question_window._answer_with_option(1)
end
end

function M.question_other()
local question_window = require('opencode.ui.question_window')
if question_window.has_question() then
question_window._answer_with_custom()
end
end

function M.toggle_tool_output()
local action_text = config.ui.output.tools.show_output and 'Hiding' or 'Showing'
vim.notify(action_text .. ' tool output display', vim.log.levels.INFO)
Expand Down
8 changes: 0 additions & 8 deletions lua/opencode/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ M.defaults = {
['<leader>orr'] = { 'diff_restore_snapshot_file', desc = 'Restore file snapshot' },
['<leader>orR'] = { 'diff_restore_snapshot_all', desc = 'Restore all snapshots' },
['<leader>ox'] = { 'swap_position', desc = 'Swap window position' },
['<leader>oPa'] = { 'permission_accept', desc = 'Accept permission' },
['<leader>oPA'] = { 'permission_accept_all', desc = 'Accept all permissions' },
['<leader>oPd'] = { 'permission_deny', desc = 'Deny permission' },
['<leader>otr'] = { 'toggle_reasoning_output', desc = 'Toggle reasoning output' },
['<leader>ott'] = { 'toggle_tool_output', desc = 'Toggle tool output' },
['<leader>o/'] = { 'quick_chat', desc = 'Quick chat with current context', mode = { 'n', 'x' } },
Expand Down Expand Up @@ -85,11 +82,6 @@ M.defaults = {
['<leader>oO'] = { 'debug_output' },
['<leader>ods'] = { 'debug_session' },
},
permission = {
accept = 'a',
accept_all = 'A',
deny = 'd',
},
session_picker = {
rename_session = { '<C-r>' },
delete_session = { '<C-d>' },
Expand Down
17 changes: 9 additions & 8 deletions lua/opencode/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,10 @@
---@class OpencodeKeymapInputWindow : table<string, OpencodeKeymapEntry>
---@class OpencodeKeymapOutputWindow : table<string, OpencodeKeymapEntry>

---@class OpencodeKeymapPermission
---@field accept string
---@field accept_all string
---@field deny string

---@class OpencodeKeymap
---@field editor OpencodeKeymapEditor
---@field input_window OpencodeKeymapInputWindow
---@field output_window OpencodeKeymapOutputWindow
---@field permission OpencodeKeymapPermission
---@field session_picker OpencodeSessionPickerKeymap
---@field timeline_picker OpencodeTimelinePickerKeymap
---@field history_picker OpencodeHistoryPickerKeymap
Expand Down Expand Up @@ -208,8 +202,8 @@
---@field quick_chat OpencodeQuickChatConfig

---@class MessagePartState
---@field input TaskToolInput|BashToolInput|FileToolInput|TodoToolInput|GlobToolInput|GrepToolInput|WebFetchToolInput|ListToolInput Input data for the tool
---@field metadata TaskToolMetadata|ToolMetadataBase|WebFetchToolMetadata|BashToolMetadata|FileToolMetadata|GlobToolMetadata|GrepToolMetadata|ListToolMetadata Metadata about the tool execution
---@field input TaskToolInput|BashToolInput|FileToolInput|TodoToolInput|GlobToolInput|GrepToolInput|WebFetchToolInput|ListToolInput|QuestionToolInput Input data for the tool
---@field metadata TaskToolMetadata|ToolMetadataBase|WebFetchToolMetadata|BashToolMetadata|FileToolMetadata|GlobToolMetadata|GrepToolMetadata|ListToolMetadata|QuestionToolMetadata Metadata about the tool execution
---@field time { start: number, end: number } Timestamps for tool use
---@field status string Status of the tool use (e.g., 'running', 'completed', 'failed')
---@field title string Title of the tool use
Expand Down Expand Up @@ -307,6 +301,13 @@
---@field questions OpencodeQuestionInfo[] Questions to ask
---@field tool? { messageID: string, callID: string }

---@class QuestionToolInput
---@field questions OpencodeQuestionInfo[] Questions that were asked

---@class QuestionToolMetadata: ToolMetadataBase
---@field answers string[][] Array of answer arrays (one per question)
---@field truncated boolean Whether the results were truncated

---@class MessageTokenCount
---@field reasoning number
---@field input number
Expand Down
Loading