feat(input): option to allow normal mode (#3)
This commit is contained in:
parent
7e6e962341
commit
08c0cf3217
|
@ -3,6 +3,9 @@ local default_config = {
|
|||
-- Default prompt string
|
||||
default_prompt = "➤ ",
|
||||
|
||||
-- When true, <Esc> will close the modal
|
||||
insert_only = true,
|
||||
|
||||
-- These are passed to nvim_open_win
|
||||
anchor = "SW",
|
||||
relative = "cursor",
|
||||
|
|
|
@ -149,13 +149,11 @@ setmetatable(M, {
|
|||
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 require('dressing.input').confirm()<CR>",
|
||||
keyopts
|
||||
)
|
||||
local close_rhs = "<cmd>lua require('dressing.input').confirm()<CR>"
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<Esc>", close_rhs, keyopts)
|
||||
if config.insert_only then
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "i", "<Esc>", close_rhs, keyopts)
|
||||
end
|
||||
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")
|
||||
|
|
Loading…
Reference in New Issue