diff --git a/README.md b/README.md index 447cebf..3a91773 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,10 @@ executor.commands.run_with_new_command() executor.commands.show_presets() executor.commands.show_history() executor.commands.run_one_off(cmd) + +-- some minimal API which does not trigger user interactions +executor.api.set_task_command(cmd) +executor.api.run_task(cmd?) ``` You can therefore map the Vim commands to a key: diff --git a/lua/executor/init.lua b/lua/executor/init.lua index f6349a7..c7f7b3c 100644 --- a/lua/executor/init.lua +++ b/lua/executor/init.lua @@ -97,6 +97,16 @@ Public.commands = { end, } +Public.api = { + set_task_command = Executor.set_task_command, + run_task = function(cmd) + if not cmd and not Executor._stored_task_command then + error("no command provided as argument and no stored task command found for api.run_task") + end + Executor.run_task(cmd) + end, +} + vim.api.nvim_create_user_command("ExecutorReset", function() Public.commands.reset() end, {})