Skip to content

Commit a4fdf89

Browse files
authored
feat(ui): add configurable input window options (#324)
Allow users to customize window-local options for the input window via `ui.input.win_options` in config. Any valid Neovim window option can be set, such as signcolumn, cursorline, number, relativenumber, etc. This improves flexibility for user preferences and editor appearance.
1 parent e95905b commit a4fdf89

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

lua/opencode/config.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ M.defaults = {
160160
},
161161
-- Auto-hide input window when prompt is submitted or focus switches to output window
162162
auto_hide = false,
163+
-- Window-local options applied to the input window.
164+
-- Any valid Neovim window option can be added here.
165+
-- Users can override these and add any extra option, e.g.:
166+
-- win_options = { signcolumn = 'no', cursorline = true, conceallevel = 2 }
167+
win_options = {
168+
signcolumn = 'yes',
169+
cursorline = false,
170+
number = false,
171+
relativenumber = false,
172+
},
163173
},
164174
picker = {
165175
snacks_layout = nil,

lua/opencode/types.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,28 @@
142142
---@field highlights? OpencodeHighlightConfig
143143
---@field picker OpencodeUIPickerConfig
144144

145+
---Window-local options applied to the input window.
146+
---Any valid Neovim window-local option (`:h window-variable`) can be set here.
147+
---Common examples:
148+
--- signcolumn = 'no'
149+
--- cursorline = true
150+
--- number = true
151+
--- relativenumber = true
152+
--- foldcolumn = '0'
153+
--- statuscolumn = ''
154+
--- conceallevel = 2
155+
---@class OpencodeUIInputWinOptions : table<string, any>
156+
---@field signcolumn? string # Value for 'signcolumn' (e.g. 'yes', 'no', 'auto')
157+
---@field cursorline? boolean
158+
---@field number? boolean
159+
---@field relativenumber? boolean
160+
145161
---@class OpencodeUIInputConfig
146162
---@field text { wrap: boolean }
147163
---@field min_height number
148164
---@field max_height number
149165
---@field auto_hide boolean
166+
---@field win_options? OpencodeUIInputWinOptions # Window-local options applied to the input window. Any valid Neovim window option is accepted.
150167

151168
---@class OpencodeHighlightConfig
152169
---@field vertical_borders? { tool?: { fg?: string, bg?: string }, user?: { fg?: string, bg?: string }, assistant?: { fg?: string, bg?: string } }

lua/opencode/ui/input_window.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,13 @@ function M.setup(windows)
268268

269269
set_buf_option('filetype', 'opencode', windows)
270270
set_win_option('winhighlight', config.ui.window_highlight, windows)
271-
set_win_option('signcolumn', 'yes', windows)
272-
set_win_option('cursorline', false, windows)
273-
set_win_option('number', false, windows)
274-
set_win_option('relativenumber', false, windows)
271+
272+
-- Apply user-configurable window options
273+
local win_opts = config.ui.input.win_options or {}
274+
for opt, value in pairs(win_opts) do
275+
pcall(set_win_option, opt, value, windows)
276+
end
277+
275278
set_buf_option('buftype', 'nofile', windows)
276279
set_buf_option('bufhidden', 'hide', windows)
277280
set_buf_option('buflisted', false, windows)

0 commit comments

Comments
 (0)