forked from trinitrix/core
30 lines
1.0 KiB
Lua
30 lines
1.0 KiB
Lua
-- create the required tables under `std`
|
|
trinitrix.std = {keymaps = {}};
|
|
|
|
--- Add a new keymap. This is just a convenience function which registers the function
|
|
--- and at the same time deals with the fact that the whole trinitrix api is async.
|
|
---@param mode string
|
|
---@param key string
|
|
---@param callback function
|
|
trinitrix.std.keymaps.add = function(mode, key, callback)
|
|
local callback_key = trinitrix.api.register_function(function()
|
|
local co = coroutine.create(callback)
|
|
while coroutine.status(co) ~= "dead" do
|
|
coroutine.resume(co)
|
|
end
|
|
end)
|
|
trinitrix.api.keymaps.add(mode, key, callback_key)
|
|
end
|
|
|
|
|
|
|
|
trinitrix.std.keymaps.add("ci", "<ESC>", trinitrix.api.ui.set_mode_normal)
|
|
|
|
trinitrix.std.keymaps.add("n", ":", trinitrix.api.ui.command_line_show)
|
|
trinitrix.std.keymaps.add("n", "i", trinitrix.api.ui.set_mode_insert)
|
|
|
|
-- a simple test to prove that key chords work
|
|
trinitrix.std.keymaps.add("ni", "jj", function() print("hi") end)
|
|
|
|
trinitrix.std.keymaps.add("n", "q", trinitrix.api.exit)
|