nvim-libmodal/examples/lua/key-combos-manually.lua

29 lines
624 B
Lua
Raw Normal View History

local api = vim.api
local libmodal = require('libmodal')
2020-05-15 02:12:15 +00:00
local fooModeInputHistory = {}
local function clearHistory(indexToCheck)
2020-05-15 02:12:15 +00:00
if #fooModeInputHistory >= indexToCheck then
fooModeInputHistory = {}
end
end
2020-05-15 02:12:15 +00:00
function fooMode()
fooModeInputHistory[#fooModeInputHistory + 1] = string.char(
api.nvim_get_var('fooModeInput')
2020-05-13 22:22:25 +00:00
)
local index = 1
2020-05-15 02:12:15 +00:00
if fooModeInputHistory[1] == 'z' then
if fooModeInputHistory[2] == 'f' then
if fooModeInputHistory[3] == 'o' then
api.nvim_command("echom 'It works!'")
else index = 3 end
else index = 2 end
end
clearHistory(index)
end
2020-05-15 02:12:15 +00:00
libmodal.mode.enter('FOO', fooMode)