diff --git a/lua/astrocommunity/editing-support/mini-operators/init.lua b/lua/astrocommunity/editing-support/mini-operators/init.lua index 4f3fc298c..bc3966973 100644 --- a/lua/astrocommunity/editing-support/mini-operators/init.lua +++ b/lua/astrocommunity/editing-support/mini-operators/init.lua @@ -1,33 +1,27 @@ --- NOTE: the default prefix is `g`, but this will override some bindings. -local prefix = "g" - ---@type LazySpec return { "echasnovski/mini.operators", - event = "User AstroFile", - dependencies = { - "AstroNvim/astrocore", - ---@type AstroCoreOpts - opts = { - mappings = { - n = { - [prefix] = { - name = "Text edit operators", - }, - }, - v = { - [prefix] = { - name = "Text edit operators", - }, - }, - }, - }, - }, - opts = { - evaluate = { prefix = prefix .. "e" }, - exchange = { prefix = prefix .. "x" }, - multiply = { prefix = prefix .. "m" }, - replace = { prefix = prefix .. "r" }, - sort = { prefix = prefix .. "s" }, - }, + keys = function() + local plugin = require("lazy.core.config").spec.plugins["mini.operators"] + local opts = require("lazy.core.plugin").values(plugin, "opts", false) + local maps = {} + for operator, default in pairs { + evaluate = "g=", + exchange = "gx", + multiply = "gm", + replace = "gr", + sort = "gs", + } do + local prefix = vim.tbl_get(opts, operator, "prefix") or default + local line_lhs = prefix .. vim.fn.strcharpart(prefix, vim.fn.strchars(prefix) - 1, 1) + local name = operator:sub(1, 1):upper() .. operator:sub(2) + vim.list_extend(maps, { + { line_lhs, desc = name .. " line" }, + { prefix, desc = name .. " operator" }, + { prefix, mode = "x", desc = name .. " selection" }, + }) + end + return maps + end, + opts = {}, }