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

21 lines
582 B
Lua
Raw Normal View History

local libmodal = require 'libmodal'
2020-08-27 16:10:01 +00:00
2022-04-26 15:33:37 +00:00
-- the list of commands. Providing this will allow for autocomplete
local commandList = {'new', 'close', 'last'}
2022-04-26 15:33:37 +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
2022-04-26 15:33:37 +00:00
-- enter the prompt
2020-07-03 17:01:04 +00:00
libmodal.prompt.enter('FOO', FooMode, commandList)