Closed mboros1 closed 3 months ago
You can just do something like this:
local prompt = "> "
local input = Input({
relative = "cursor",
position = { row = 1, col = 0 },
size = { width = 20 },
border = "single",
}, {
prompt = prompt,
})
input:mount()
vim.keymap.set({ "n", "i" }, "<Enter>", function()
local value = string.sub(vim.api.nvim_get_current_line(), vim.fn.strwidth(prompt) + 1)
print(value)
end, { buffer = input.bufnr })
This will override the default behavior of <Enter>
key (which is to submit and close the input).
I'm trying to use the input box to send commands, which will send the inputs to an external program updating other popups
but when I submit, all of the boxes in the layout just close.
I can call a function in on submit to re-open the layout, but it causes the screen to flicker as it closes and re-opens which is a little annoying. Do you have advice on the best way to just have the input box clear the input text without closing when the on_submit function runs?