From 5223c5a6020e2610c0124228fcd163881618f5bd Mon Sep 17 00:00:00 2001 From: Mark Keller <8452750+keller00@users.noreply.github.com> Date: Mon, 6 Oct 2025 21:45:54 -0700 Subject: [PATCH] adding esc to close floating window --- lua/cursor-agent/ui/term.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lua/cursor-agent/ui/term.lua b/lua/cursor-agent/ui/term.lua index 8253678..ef2c97e 100644 --- a/lua/cursor-agent/ui/term.lua +++ b/lua/cursor-agent/ui/term.lua @@ -74,6 +74,19 @@ function M.open_float_term(opts) M.close(win) end, { buffer = bufnr, nowait = true, silent = true }) + -- Add ESC key to close the floating window in normal, insert, and terminal modes + pcall(vim.keymap.set, 'n', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + + pcall(vim.keymap.set, 'i', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + + pcall(vim.keymap.set, 't', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + -- Jump to bottom and enter terminal-mode for immediate typing local ok_lines, line_count = pcall(vim.api.nvim_buf_line_count, bufnr) if ok_lines then pcall(vim.api.nvim_win_set_cursor, win, { line_count, 0 }) end @@ -118,6 +131,19 @@ function M.open_float_win_for_buf(bufnr, opts) M.close(win) end, { buffer = bufnr, nowait = true, silent = true }) + -- Add ESC key to close the floating window in normal, insert, and terminal modes + pcall(vim.keymap.set, 'n', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + + pcall(vim.keymap.set, 'i', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + + pcall(vim.keymap.set, 't', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + -- Jump to bottom and enter terminal-mode for immediate typing local ok_lines, line_count = pcall(vim.api.nvim_buf_line_count, bufnr) if ok_lines then pcall(vim.api.nvim_win_set_cursor, win, { line_count, 0 }) end