feat: bind <Esc> to cancel dialog in input (fix #1)

This commit is contained in:
Steven Arcangeli 2021-12-04 11:03:07 -08:00
parent 770501336f
commit 27d1ea0a15
1 changed files with 8 additions and 0 deletions

View File

@ -38,6 +38,14 @@ return function(opts, on_confirm)
vim.api.nvim_buf_set_option(bufnr, "buftype", "prompt")
vim.api.nvim_buf_set_option(bufnr, "swapfile", false)
vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe")
local keyopts = { silent = true, noremap = true }
vim.api.nvim_buf_set_keymap(
bufnr,
"i",
"<Esc>",
"<cmd>lua dressing_prompt_confirm()<CR>",
keyopts
)
vim.fn.prompt_setprompt(bufnr, prompt)
-- Would prefer to use v:lua directly here, but it doesn't work :(
vim.fn.prompt_setcallback(bufnr, "dressing#prompt_confirm")