Skip to content

Commit

Permalink
feat(editing-support): add mini-operators plugin (#857)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
manuuurino and mehalter authored Apr 12, 2024
1 parent e16738c commit 37d6048
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lua/astrocommunity/editing-support/mini-operators/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# mini-operators

Text edit operators. Part of 'mini.nvim' library.

**Repository:** <https://github.com/echasnovski/mini.operators>
25 changes: 25 additions & 0 deletions lua/astrocommunity/editing-support/mini-operators/init.lua
Original file line number Diff line number Diff line change
@@ -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 = {},
}

0 comments on commit 37d6048

Please sign in to comment.