nvim-libmodal/examples/lua/supress-exit.lua
2022-04-26 11:33:37 -04:00

24 lines
625 B
Lua
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local libmodal = require 'libmodal'
-- function which is called whenever the user presses a button
local function fooMode()
-- append to the input history, the latest button press
local userInput = string.char(
-- the input is a character number
vim.g.fooModeInput
)
if userInput == '' then
vim.api.nvim_command "echom 'You cant leave using <Esc>.'"
elseif userInput == 'q' then
-- if the user presses 'q', libmodal will exit the mode
vim.g.fooModeExit = true
end
end
-- tell libmodal not to exit the mode immediately
vim.g.fooModeExit = false
-- enter the mode
libmodal.mode.enter('FOO', fooMode, true)