From 37d6048d131d5174544d9a2daebe613fef0869a2 Mon Sep 17 00:00:00 2001 From: Manuuurino <2855338+manuuurino@users.noreply.github.com> Date: Fri, 12 Apr 2024 10:21:25 +0200 Subject: [PATCH] feat(editing-support): add `mini-operators` plugin (#857) * feat(editing-support): add `mini-operators` * fix(mini-operators): add missing header for visual and changed prefix to default * fix(mini-operators): correctly implement `keys` lazy loading --------- Co-authored-by: Micah Halter --- .../editing-support/mini-operators/README.md | 5 ++++ .../editing-support/mini-operators/init.lua | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 lua/astrocommunity/editing-support/mini-operators/README.md create mode 100644 lua/astrocommunity/editing-support/mini-operators/init.lua diff --git a/lua/astrocommunity/editing-support/mini-operators/README.md b/lua/astrocommunity/editing-support/mini-operators/README.md new file mode 100644 index 000000000..af194555e --- /dev/null +++ b/lua/astrocommunity/editing-support/mini-operators/README.md @@ -0,0 +1,5 @@ +# mini-operators + +Text edit operators. Part of 'mini.nvim' library. + +**Repository:** diff --git a/lua/astrocommunity/editing-support/mini-operators/init.lua b/lua/astrocommunity/editing-support/mini-operators/init.lua new file mode 100644 index 000000000..5b7c1562a --- /dev/null +++ b/lua/astrocommunity/editing-support/mini-operators/init.lua @@ -0,0 +1,25 @@ +---@type LazySpec +return { + "echasnovski/mini.operators", + keys = function(_, keys) + local plugin = require("lazy.core.config").spec.plugins["mini.operators"] + local opts = require("lazy.core.plugin").values(plugin, "opts", false) + 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(keys, { + { line_lhs, desc = name .. " line" }, + { prefix, desc = name .. " operator" }, + { prefix, mode = "x", desc = name .. " selection" }, + }) + end + end, + opts = {}, +}