Disable leap and change keybinding on markings back to default

This commit is contained in:
Martin Larsson 2025-08-14 20:18:56 +02:00
parent 0873c36a6f
commit 1c829674e4
2 changed files with 84 additions and 84 deletions

View file

@ -50,7 +50,7 @@ utils.foreach({
-- Marks are less frequently used than leaping, also, less relevant with arrow and fzf navigation. -- Marks are less frequently used than leaping, also, less relevant with arrow and fzf navigation.
-- Prioritize regular m for leaping, and <leader>m for setting marks. -- Prioritize regular m for leaping, and <leader>m for setting marks.
{ "<leader>m", "m", }, -- { "<leader>m", "m", },
{ "[d", function() { "[d", function()
vim.diagnostic.jump({ count = -1, float = false }) vim.diagnostic.jump({ count = -1, float = false })
end }, end },

View file

@ -1,86 +1,86 @@
local utils = require("utils") -- local utils = require("utils")
--
local saved_hlsearch = false -- local saved_hlsearch = false
local saved_highlights = {} -- local saved_highlights = {}
--
local function leap_across_windows() -- local function leap_across_windows()
require("leap").leap({ -- require("leap").leap({
target_windows = require("leap.user").get_focusable_windows() -- target_windows = require("leap.user").get_focusable_windows()
}) -- })
end -- end
--
local function leap_in_current_buffer() -- local function leap_in_current_buffer()
require("leap").leap({ -- require("leap").leap({
target_windows = { vim.api.nvim_get_current_win() } -- target_windows = { vim.api.nvim_get_current_win() }
}) -- })
end -- end
--
local function normal_mode_leap() -- local function normal_mode_leap()
if _G["snacks_zen_mode"] then -- if _G["snacks_zen_mode"] then
leap_in_current_buffer() -- leap_in_current_buffer()
else -- else
leap_across_windows() -- leap_across_windows()
end -- end
end -- end
--
local function save_and_set_invisible_inlay_hints_hl() -- local function save_and_set_invisible_inlay_hints_hl()
saved_highlights = vim.api.nvim_get_hl(0, { name = "LspInlayHint" }) -- saved_highlights = vim.api.nvim_get_hl(0, { name = "LspInlayHint" })
vim.api.nvim_set_hl(0, "LspInlayHint", { fg = utils.ayu_colors.bg, bg = "none" }) -- vim.api.nvim_set_hl(0, "LspInlayHint", { fg = utils.ayu_colors.bg, bg = "none" })
end -- end
--
local function restore_inlay_hints_hl() -- local function restore_inlay_hints_hl()
vim.api.nvim_set_hl(0, "LspInlayHint", saved_highlights) -- vim.api.nvim_set_hl(0, "LspInlayHint", saved_highlights)
end -- end
return { return {
"ggandor/leap.nvim", -- "ggandor/leap.nvim",
dependencies = { -- dependencies = {
{ "tpope/vim-repeat", lazy = true }, -- { "tpope/vim-repeat", lazy = true },
}, -- },
event = "VeryLazy", -- event = "VeryLazy",
lazy = true, -- lazy = true,
opts = {}, -- opts = {},
init = function() -- init = function()
local leap = require("leap") -- local leap = require("leap")
--
-- Disable auto jumping to the first match -- -- Disable auto jumping to the first match
-- Autojumping is not intuitive when running bi-directional leaps -- -- Autojumping is not intuitive when running bi-directional leaps
leap.opts.safe_labels = {} -- leap.opts.safe_labels = {}
-- Adding more labels since we're not using autojumping. These are sorted by priority -- -- Adding more labels since we're not using autojumping. These are sorted by priority
-- focusing on the home row and the strongest fingers for Colemak-DH -- -- focusing on the home row and the strongest fingers for Colemak-DH
leap.opts.labels = "tsragneiomdch,pfluxzv./kwqby;j1234567890{}()[]<>J!@#$%^&*TSRAGNEIOMDCHPFLUXZV?KWQBY:" -- leap.opts.labels = "tsragneiomdch,pfluxzv./kwqby;j1234567890{}()[]<>J!@#$%^&*TSRAGNEIOMDCHPFLUXZV?KWQBY:"
--
local autocmds = { -- local autocmds = {
{ -- {
event_name = "LeapEnter", -- event_name = "LeapEnter",
cb = function() -- cb = function()
saved_hlsearch = vim.o.hlsearch -- saved_hlsearch = vim.o.hlsearch
vim.o.hlsearch = false -- vim.o.hlsearch = false
save_and_set_invisible_inlay_hints_hl() -- save_and_set_invisible_inlay_hints_hl()
end -- end
}, -- },
{ -- {
event_name = "LeapLeave", -- event_name = "LeapLeave",
cb = function() -- cb = function()
vim.o.hlsearch = saved_hlsearch -- vim.o.hlsearch = saved_hlsearch
restore_inlay_hints_hl() -- restore_inlay_hints_hl()
end -- end
}, -- },
} -- }
--
local utils = require("utils") -- local utils = require("utils")
local leap_augroup_name = "LeapEvents" -- local leap_augroup_name = "LeapEvents"
vim.api.nvim_create_augroup(leap_augroup_name, { clear = true }) -- vim.api.nvim_create_augroup(leap_augroup_name, { clear = true })
for _, cmd in ipairs(autocmds) do -- for _, cmd in ipairs(autocmds) do
utils.create_user_event_cb(cmd.event_name, cmd.cb, leap_augroup_name) -- utils.create_user_event_cb(cmd.event_name, cmd.cb, leap_augroup_name)
end -- end
--
require("utils").foreach({ -- require("utils").foreach({
{ "n", "m", normal_mode_leap }, -- { "n", "m", normal_mode_leap },
{ "v", "m", leap_in_current_buffer }, -- { "v", "m", leap_in_current_buffer },
{ "o", "m", leap_in_current_buffer } -- { "o", "m", leap_in_current_buffer }
}, function(mapping) -- }, function(mapping)
vim.keymap.set(mapping[1], mapping[2], mapping[3]) -- vim.keymap.set(mapping[1], mapping[2], mapping[3])
end) -- end)
end, -- end,
} }