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

25 lines
641 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.

-- Imports
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)