-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
e16738c
commit 37d6048
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
25
lua/astrocommunity/editing-support/mini-operators/init.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {}, | ||
} |