-- lx-bundle:true

--- Register comment commands without loading their editing implementation
-- @module plugins.comments

local command = require("core.command")

local main

--- Load the comment implementation on its first command
-- @return table implementation
local function get_main()
	if not main then
		main = require("plugins.comments.main")
	end

	return main
end

--- Build one lazy comment command
-- @param operation_name string exported operation name
-- @return table command_definition
local function lazy_command(operation_name)
	return {
		requires = { "doc", "edit" },
		perform = function()
			return get_main()[operation_name]()
		end,
	}
end

command.register({
	["comment:toggle-line"] = lazy_command("toggle_line"),
	["comment:toggle-block"] = lazy_command("toggle_block"),
	["comment:toggle-guard"] = lazy_command("toggle_guard"),
	["comment:toggle-inline-block"] = lazy_command("toggle_inline_block"),
	["comment:toggle-smart"] = lazy_command("toggle_smart"),
	["comment:uncomment"] = lazy_command("uncomment"),
})
