nvim-libmodal/examples/lua/prompt-callback.lua

22 lines
596 B
Lua
Raw Normal View History

2020-08-27 16:10:01 +00:00
-- Imports
local libmodal = require 'libmodal'
2020-08-27 16:10:01 +00:00
-- The list of commands. Providing this will allow for autocomplete.
local commandList = {'new', 'close', 'last'}
2020-08-27 16:10:01 +00:00
-- The function which will be called whenever the user enters a command.
2020-07-03 17:01:04 +00:00
function FooMode()
local userInput = vim.g.fooModeInput
2020-05-13 22:22:25 +00:00
if userInput == 'new' then
vim.api.nvim_command 'tabnew'
2020-05-13 22:22:25 +00:00
elseif userInput == 'close' then
vim.api.nvim_command 'tabclose'
vim.g.fooModeExit = true
2020-05-13 22:22:25 +00:00
elseif userInput == 'last' then
vim.api.nvim_command 'tablast'
end
end
2020-08-27 16:10:01 +00:00
-- Enter the prompt.
2020-07-03 17:01:04 +00:00
libmodal.prompt.enter('FOO', FooMode, commandList)