diff --git a/README.md b/README.md index 5123c85..5386755 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ require("codex").setup({ relative = "editor", width = 0.4, wo = { + winhighlight = "Normal:NormalFloat", winfixwidth = false, }, }, @@ -130,7 +131,7 @@ Supported options: - `count`: first Snacks terminal count for each directory. Defaults to `1`. - `on_notification`: optional callback for OSC 9 notifications. Defaults to `nil`. - `keys`: terminal-local session keys. Set an entry to `false` to disable it. -- `win`: options merged into the Snacks window config. Defaults include `win.wo.winfixwidth = false`; only `win.wo.winbar` is reserved and managed by `codex.nvim`. +- `win`: options merged into the Snacks window config. Defaults include `win.wo.winhighlight = "Normal:NormalFloat"` and `win.wo.winfixwidth = false`; only `win.wo.winbar` is reserved and managed by `codex.nvim`. - `terminal`: options merged into the Snacks terminal config. When more than one session exists for the current directory, Codex terminal diff --git a/lua/codex/init.lua b/lua/codex/init.lua index 7b9752e..4079fa5 100644 --- a/lua/codex/init.lua +++ b/lua/codex/init.lua @@ -18,6 +18,7 @@ local defaults = { relative = "editor", width = 0.4, wo = { + winhighlight = "Normal:NormalFloat", winbar = "", winfixwidth = false, }, diff --git a/test/codex_spec.lua b/test/codex_spec.lua index 4f6c522..e83c3c5 100644 --- a/test/codex_spec.lua +++ b/test/codex_spec.lua @@ -205,6 +205,11 @@ assert_eq(calls[1].opts.win.width, 0.4, "default terminal width should be 40 per assert_eq(type(calls[1].opts.win.wo.winbar), "string", "Codex winbar should be a static string") assert_eq(calls[1].opts.win.wo.winbar:find("%{", 1, true), nil, "Codex winbar should not be an expression") assert_eq(calls[1].opts.win.wo.winbar, "", "default terminal winbar should be hidden for one session") +assert_eq( + calls[1].opts.win.wo.winhighlight, + "Normal:NormalFloat", + "default terminal background should use NormalFloat" +) assert_eq(calls[1].opts.win.wo.winfixwidth, false, "default terminal width should remain adjustable") local default_snacks_win = simulate_snacks_on_win(calls[1], true) assert_eq(default_snacks_win.opts.wo.winfixwidth, false, "Codex should correct Snacks' stored split default") @@ -241,6 +246,7 @@ codex.setup({ q = "hide", }, wo = { + winhighlight = "Normal:CursorLine", winfixwidth = true, }, }, @@ -268,6 +274,11 @@ assert_eq(calls[2].opts.count, 4, "configured count should be passed to Snacks") assert_eq(calls[2].opts.win.position, "left", "per-call win config should merge") assert_eq(calls[2].opts.win.width, 0.5, "configured win config should be preserved") assert_eq(calls[2].opts.win.wo.winbar, "", "Codex winbar should stay hidden when win config merges") +assert_eq( + calls[2].opts.win.wo.winhighlight, + "Normal:CursorLine", + "configured winhighlight should override the default" +) assert_eq(calls[2].opts.win.wo.winfixwidth, true, "configured winfixwidth should override the default") local configured_snacks_win = simulate_snacks_on_win(calls[2], true) assert_eq(configured_on_win, configured_snacks_win, "configured on_win callback should be preserved") @@ -285,6 +296,7 @@ assert_eq(calls[2].opts.auto_close, false, "Snacks auto_close should stay disabl codex.toggle({ win = { wo = { + winhighlight = "Normal:ErrorMsg", winbar = "Codex", winfixwidth = false, }, @@ -306,6 +318,11 @@ assert_list( "the plugin notification override should follow and take precedence over configured arguments" ) assert_eq(calls[3].opts.win.wo.winbar, "", "Codex should clear a per-call winbar for one session") +assert_eq( + calls[3].opts.win.wo.winhighlight, + "Normal:ErrorMsg", + "per-call winhighlight should override setup" +) assert_eq(calls[3].opts.win.wo.winfixwidth, false, "per-call winfixwidth should override setup") local per_call_snacks_win = simulate_snacks_on_win(calls[3], true) assert_eq(per_call_snacks_win.opts.wo.winfixwidth, false, "per-call winfixwidth should correct Snacks' stored value")