feat(util.mini): follow the user's mappings instead of hardcoded values (#4043)
Because I use the Colemak-DH keyboard layout, I have mapped 'i' to 'h'. Therefore, the current mini.ai which_key prompts are inconsistent with my keymap. ## Description The names and prefixes used in mini.ai_whichkey() are hardcoded and should follow the user's mappings. ## Related Issue(s) No ## Screenshots No ## Checklist - [ x ] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --------- Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
@ -171,9 +171,6 @@ return {
|
|||||||
"echasnovski/mini.ai",
|
"echasnovski/mini.ai",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = function()
|
opts = function()
|
||||||
LazyVim.on_load("which-key.nvim", function()
|
|
||||||
vim.schedule(LazyVim.mini.ai_whichkey)
|
|
||||||
end)
|
|
||||||
local ai = require("mini.ai")
|
local ai = require("mini.ai")
|
||||||
return {
|
return {
|
||||||
n_lines = 500,
|
n_lines = 500,
|
||||||
@ -197,6 +194,14 @@ return {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
config = function(_, opts)
|
||||||
|
require("mini.ai").setup(opts)
|
||||||
|
LazyVim.on_load("which-key.nvim", function()
|
||||||
|
vim.schedule(function()
|
||||||
|
LazyVim.mini.ai_whichkey(opts)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,8 @@ function M.ai_buffer(ai_type)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- register all text objects with which-key
|
-- register all text objects with which-key
|
||||||
function M.ai_whichkey()
|
---@param opts table
|
||||||
|
function M.ai_whichkey(opts)
|
||||||
local objects = {
|
local objects = {
|
||||||
{ " ", desc = "whitespace" },
|
{ " ", desc = "whitespace" },
|
||||||
{ '"', desc = '" string' },
|
{ '"', desc = '" string' },
|
||||||
@ -92,14 +93,20 @@ function M.ai_whichkey()
|
|||||||
}
|
}
|
||||||
|
|
||||||
local ret = { mode = { "o", "x" } }
|
local ret = { mode = { "o", "x" } }
|
||||||
for prefix, name in pairs({
|
---@type table<string, string>
|
||||||
i = "inside",
|
local mappings = vim.tbl_extend("force", {}, {
|
||||||
a = "around",
|
around = "a",
|
||||||
il = "last",
|
inside = "i",
|
||||||
["in"] = "next",
|
around_next = "an",
|
||||||
al = "last",
|
inside_next = "in",
|
||||||
an = "next",
|
around_last = "al",
|
||||||
}) do
|
inside_last = "il",
|
||||||
|
}, opts.mappings or {})
|
||||||
|
mappings.goto_left = nil
|
||||||
|
mappings.goto_right = nil
|
||||||
|
|
||||||
|
for name, prefix in pairs(mappings) do
|
||||||
|
name = name:gsub("^around_", ""):gsub("^inside_", "")
|
||||||
ret[#ret + 1] = { prefix, group = name }
|
ret[#ret + 1] = { prefix, group = name }
|
||||||
for _, obj in ipairs(objects) do
|
for _, obj in ipairs(objects) do
|
||||||
local desc = obj.desc
|
local desc = obj.desc
|
||||||
|
Reference in New Issue
Block a user