mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-24 05:21:07 +00:00
Merge 4f7b2daf5c into 459a4c3b10
This commit is contained in:
commit
4b93223e38
1 changed files with 78 additions and 21 deletions
|
|
@ -1,37 +1,94 @@
|
||||||
|
-- A helper function making it easier to set "clever-f" behavior
|
||||||
|
-- (use f/F or t/T instead of ;/, - see the plugin clever-f.vim).
|
||||||
|
local function clever(...)
|
||||||
|
return require("leap.user").with_traversal_keys(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ft(key_specific_args)
|
||||||
|
require("leap").leap(vim.tbl_deep_extend("keep", key_specific_args, {
|
||||||
|
inputlen = 1,
|
||||||
|
inclusive = true,
|
||||||
|
opts = {
|
||||||
|
labels = "",
|
||||||
|
safe_labels = vim.fn.mode(true):match("no?") and "" or nil,
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- disable flash
|
-- disable flash
|
||||||
{ "folke/flash.nvim", enabled = false, optional = true },
|
{ "folke/flash.nvim", enabled = false, optional = true },
|
||||||
|
|
||||||
-- easily jump to any location and enhanced f/t motions for Leap
|
-- Leap provides improved vim-sneak-style navigation with live label
|
||||||
|
-- preview and multi-window scope, and also extra features like remote
|
||||||
|
-- operations and incremental treesitter node selection.
|
||||||
{
|
{
|
||||||
url = "https://codeberg.org/andyg/leap.nvim.git",
|
url = "https://codeberg.org/andyg/leap.nvim.git",
|
||||||
enabled = true,
|
|
||||||
keys = function()
|
|
||||||
---@type LazyKeysSpec[]
|
|
||||||
local ret = {}
|
|
||||||
for _, key in ipairs({ "f", "F", "t", "T" }) do
|
|
||||||
ret[#ret + 1] = { key, mode = { "n", "x", "o" } }
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end,
|
|
||||||
opts = { labeled_modes = "nx" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
url = "https://codeberg.org/andyg/leap.nvim.git",
|
|
||||||
enabled = true,
|
|
||||||
keys = {
|
keys = {
|
||||||
{ "s", mode = { "n", "x", "o" }, desc = "Leap Forward to" },
|
{ "s", mode = { "n", "x", "o" }, "<Plug>(leap)", desc = "Leap" },
|
||||||
{ "S", mode = { "n", "x", "o" }, desc = "Leap Backward to" },
|
{ "S", mode = { "n" }, "<Plug>(leap-from-window)", desc = "Leap from Window" },
|
||||||
{ "gs", mode = { "n", "x", "o" }, desc = "Leap from Windows" },
|
-- Enhanced f/t motions.
|
||||||
|
-- To keep using `;`/`,` just set `opts = clever(";", ",")` everywhere.
|
||||||
|
{
|
||||||
|
"f",
|
||||||
|
mode = { "n", "x", "o" },
|
||||||
|
function()
|
||||||
|
ft({ opts = clever("f", "F") })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"F",
|
||||||
|
mode = { "n", "x", "o" },
|
||||||
|
function()
|
||||||
|
ft({ backward = true, opts = clever("f", "F") })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t",
|
||||||
|
mode = { "n", "x", "o" },
|
||||||
|
function()
|
||||||
|
ft({ offset = -1, opts = clever("t", "T") })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"T",
|
||||||
|
mode = { "n", "x", "o" },
|
||||||
|
function()
|
||||||
|
ft({ backward = true, offset = 1, opts = clever("t", "T") })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
-- See the documentation for extras, like setting up automatic
|
||||||
|
-- pasting after yank operations or defining remote text objects.
|
||||||
|
{
|
||||||
|
"gs",
|
||||||
|
mode = { "n", "o" },
|
||||||
|
function()
|
||||||
|
-- Automatically enter Visual mode when coming from Normal.
|
||||||
|
require("leap.remote").action({ input = vim.fn.mode(true):match("o") and "" or "v" })
|
||||||
|
end,
|
||||||
|
desc = "Remote Operation",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"R",
|
||||||
|
mode = { "x", "o" },
|
||||||
|
function()
|
||||||
|
require("leap.treesitter").select({ opts = clever("R", "r") })
|
||||||
|
end,
|
||||||
|
desc = "Leap Treesitter",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
opts = {
|
||||||
|
-- Exclude whitespace and the middle of alphabetic words from preview.
|
||||||
|
preview = function(ch0, ch1, ch2)
|
||||||
|
return not (ch1:match("%s") or ch0:match("%a") and ch1:match("%a") and ch2:match("%a"))
|
||||||
|
end,
|
||||||
|
equivalence_classes = { " \t\n\r", "[({", "})]", "\"'`" },
|
||||||
},
|
},
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
local leap = require("leap")
|
local leap = require("leap")
|
||||||
for k, v in pairs(opts) do
|
for k, v in pairs(opts) do
|
||||||
leap.opts[k] = v
|
leap.opts[k] = v
|
||||||
end
|
end
|
||||||
leap.add_default_mappings(true)
|
|
||||||
vim.keymap.del({ "x", "o" }, "x")
|
|
||||||
vim.keymap.del({ "x", "o" }, "X")
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue