You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nvim-libmodal/examples/lua/supress-exit.lua

24 lines
625 B
Lua

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

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)