mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
fix: nil mappings and move to config
This commit is contained in:
parent
8523ceaedc
commit
7211ee600e
2 changed files with 18 additions and 12 deletions
|
|
@ -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,22 +93,22 @@ function M.ai_whichkey()
|
||||||
}
|
}
|
||||||
|
|
||||||
local ret = { mode = { "o", "x" } }
|
local ret = { mode = { "o", "x" } }
|
||||||
local default_mappings = {
|
---@type table<string, string>
|
||||||
|
local mappings = vim.tbl_extend("force", {}, {
|
||||||
around = "a",
|
around = "a",
|
||||||
inside = "i",
|
inside = "i",
|
||||||
|
|
||||||
around_next = "an",
|
around_next = "an",
|
||||||
inside_next = "in",
|
inside_next = "in",
|
||||||
around_last = "al",
|
around_last = "al",
|
||||||
inside_last = "il",
|
inside_last = "il",
|
||||||
}
|
goto_left = "g[",
|
||||||
local user_mappings = LazyVim.opts("mini.ai").mappings
|
goto_right = "g]",
|
||||||
local mappings = vim.tbl_extend("force", default_mappings, user_mappings)
|
}, opts.mappings or {})
|
||||||
|
mappings.goto_left = nil
|
||||||
|
mappings.goto_right = nil
|
||||||
|
|
||||||
for name, prefix in pairs(mappings) do
|
for name, prefix in pairs(mappings) do
|
||||||
if name:match("next$") or name:match("last$") then
|
name = name:gsub("^around_", ""):gsub("^inside_", "")
|
||||||
name = name:gsub("^around_", ""):gsub("^inside_", "")
|
|
||||||
end
|
|
||||||
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
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue