This repository has been archived on 2024-05-26. You can view files and clone it, but cannot push or open issues or pull requests.
core/config/lua/init.lua

57 lines
2.1 KiB
Lua

-- Copyright (C) 2024 - 2024:
-- The Trinitrix Project <benedikt.peetz@b-peetz.de, antifallobst@systemausfall.org, sils@sils.li>
-- SPDX-License-Identifier: GPL-3.0-or-later
--
-- This file is part of Trinitrix.
--
-- Trinitrix is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published
-- by the Free Software Foundation, either version 3 of the License,
-- or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
-- FIXME(@soispha): The code here has been deprecated, update it when trixy supports lua <2024-05-03>
-- 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)
trinitrix.std.keymaps.add("n", "<TAB>", trinitrix.api.ui.cycle_planes)
-- 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)
-- Help people
trinitrix.std.keymaps.add("n", "<C-c>", function()
print("To exit trinitrix use 'trinitrix.api.exit()' instead!")
end)