Skip to content

Commit daaccf9

Browse files
committed
fixed conflicting keybinds
The new default will now use <C-y> to close the codex window, remappable by the user. Other vim standard methods have many conflicts with the codex app
1 parent 26f1754 commit daaccf9

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# Codex Neovim Plugin
22
<img width="1480" alt="image" src="https://github.com/user-attachments/assets/eac126c5-e71c-4de9-817a-bf4e8f2f6af9" />
33

4-
## A Neovim plugin integrating the open-sourced Codex CLI (`codex`).
4+
## A Neovim plugin integrating the open-sourced Codex CLI (`codex`)
55
> Latest version: ![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/johnseth97/codex.nvim?sort=semver)
66
7-
Note: As of v1.0.0, <Esc> no longer closes the Codex window. Press q to close, and <Esc><Esc> to safely interrupt model generation without resetting context.
8-
97
### Features:
108
- ✅ Toggle Codex floating window with `:CodexToggle`
119
- ✅ Optional keymap mapping via `setup` call
1210
- ✅ Background running when window hidden
13-
- ✅ Statusline integration via `require('codex').status()`
11+
- ✅ Statusline integration via `require('codex').status()`
1412

1513
### Installation:
1614

@@ -42,7 +40,10 @@ return {
4240
},
4341
},
4442
opts = {
45-
keymaps = {}, -- Disable internal default keymap (<leader>cc -> :CodexToggle)
43+
keymaps = {
44+
toggle = nil, -- Keybind to toggle Codex window (Disabled by default, watch out for conflicts)
45+
quit = '<C-q>', -- Keybind to close the Codex window (default: Ctrl + q)
46+
}, -- Disable internal default keymap (<leader>cc -> :CodexToggle)
4647
border = 'rounded', -- Options: 'single', 'double', or 'rounded'
4748
width = 0.8, -- Width of the floating window (0.0 to 1.0)
4849
height = 0.8, -- Height of the floating window (0.0 to 1.0)

lua/codex/init.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ local state = require 'codex.state'
55
local M = {}
66

77
local config = {
8-
keymaps = {},
8+
keymaps = {
9+
toggle = nil,
10+
quit = '<C-q>', -- Default: Ctrl+q to quit
11+
},
912
border = 'single',
1013
width = 0.8,
1114
height = 0.8,
@@ -86,11 +89,19 @@ end
8689
function M.open()
8790
local function create_clean_buf()
8891
local buf = vim.api.nvim_create_buf(false, false)
92+
8993
vim.api.nvim_buf_set_option(buf, 'bufhidden', 'hide')
9094
vim.api.nvim_buf_set_option(buf, 'swapfile', false)
9195
vim.api.nvim_buf_set_option(buf, 'filetype', 'codex')
92-
vim.api.nvim_buf_set_keymap(buf, 't', 'q', [[<C-\><C-n><cmd>lua require('codex').close()<CR>]], { noremap = true, silent = true })
93-
vim.api.nvim_buf_set_keymap(buf, 'n', 'q', [[<cmd>lua require('codex').close()<CR>]], { noremap = true, silent = true })
96+
97+
-- Apply configured quit keybinding
98+
99+
if config.keymaps.quit then
100+
local quit_cmd = [[<cmd>lua require('codex').close()<CR>]]
101+
vim.api.nvim_buf_set_keymap(buf, 't', config.keymaps.quit, [[<C-\><C-n>]] .. quit_cmd, { noremap = true, silent = true })
102+
vim.api.nvim_buf_set_keymap(buf, 'n', config.keymaps.quit, quit_cmd, { noremap = true, silent = true })
103+
end
104+
94105
return buf
95106
end
96107

0 commit comments

Comments
 (0)