2020-08-27 16:10:01 +00:00
|
|
|
-- Imports
|
2021-07-07 18:25:14 +00:00
|
|
|
local libmodal = require 'libmodal'
|
2020-08-27 16:10:01 +00:00
|
|
|
|
|
|
|
-- The list of commands. Providing this will allow for autocomplete.
|
2020-05-11 18:17:58 +00:00
|
|
|
local commandList = {'new', 'close', 'last'}
|
2020-05-08 17:18:01 +00:00
|
|
|
|
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()
|
2021-07-07 18:25:14 +00:00
|
|
|
local userInput = vim.g.fooModeInput
|
2020-05-13 22:22:25 +00:00
|
|
|
if userInput == 'new' then
|
2021-09-08 19:05:28 +00:00
|
|
|
vim.api.nvim_command 'tabnew'
|
2020-05-13 22:22:25 +00:00
|
|
|
elseif userInput == 'close' then
|
2021-09-08 19:05:28 +00:00
|
|
|
vim.api.nvim_command 'tabclose'
|
2022-04-25 21:59:33 +00:00
|
|
|
vim.g.fooModeExit = true
|
2020-05-13 22:22:25 +00:00
|
|
|
elseif userInput == 'last' then
|
2021-09-08 19:05:28 +00:00
|
|
|
vim.api.nvim_command 'tablast'
|
2020-05-11 18:17:58 +00:00
|
|
|
end
|
|
|
|
end
|
2020-05-08 17:18:01 +00:00
|
|
|
|
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)
|