-- lx-bundle:true

--- Register overwrite mode without changing the text editor at startup
-- @module plugins.insertmode

local command = require("core.command")
local keymap = require("core.keymap")

local main

--- Load overwrite mode on its first use
-- @return table implementation
local function get_main()
	if not main then
		main = require("plugins.insertmode.main")
	end

	return main
end

command.register({
	["insertmode:toggle"] = {
		requires = { "doc", "cursor" },
		perform = function()
			return get_main().toggle()
		end,
	},
})

keymap.bind("plugin", {
	text_editor = {
		["insert"] = "insertmode:toggle",
		["ins"] = "insertmode:toggle",
	},
})
