Upgrade leap, fix visuals since breaking change, some light optimization

and refactoring, add more labelmappings since were not using autojump,
and add remote action binding "gl"
This commit is contained in:
Martin Larsson 2024-07-15 17:36:35 +02:00
parent 47189b4b62
commit c472143d9f
2 changed files with 46 additions and 5 deletions

View file

@ -27,7 +27,6 @@ return {
term_colors = true,
sidebars = { "qf", "help" },
integrations = {
leap = true,
lsp_saga = true,
lsp_trouble = true,
mason = true,
@ -86,7 +85,12 @@ return {
-- Lazy
LazyNormal = { link = "EdgeTool" },
NotifyBackground = { link = "EdgeTool" }
-- Notify
NotifyBackground = { link = "EdgeTool" },
-- Leap
LeapLabelPrimary = { bg = colors.green, fg = colors.base },
LeapBackdrop = { link = "Comment" },
}
end
})

View file

@ -1,4 +1,6 @@
local buffers_without_inlay_hints = {}
local saved_hlsearch = false
local function set_inlay_hints_active(buffers, enable)
for _, bufnr in pairs(buffers) do
vim.lsp.inlay_hint.enable(enable, { burfnr = bufnr })
@ -20,13 +22,19 @@ end
return {
"ggandor/leap.nvim",
dependencies = {
"tpope/vim-repeat",
{ "tpope/vim-repeat", lazy = true },
},
event = "VeryLazy",
lazy = true,
config = function()
local leap = require("leap")
-- Disable auto jumping to the first match
-- Autojumping is not intuitive when running bi-directional leaps
leap.opts.safe_labels = {}
-- 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
leap.opts.labels = "tsragneiomdch,pfluxzv./kwqby;j1234567890{}()[]<>J!@#$%^&*TSRAGNEIOMDCHPFLUXZV?KWQBY:"
local autocmds = {
{
@ -35,12 +43,15 @@ return {
local open_buffers = get_open_buffers_with_inlay_hints()
set_inlay_hints_active(open_buffers, false)
buffers_without_inlay_hints = open_buffers
saved_hlsearch = vim.o.hlsearch
vim.o.hlsearch = false
end
},
{
event_name = "LeapLeave",
cb = function()
set_inlay_hints_active(buffers_without_inlay_hints, true)
vim.o.hlsearch = saved_hlsearch
end
},
}
@ -52,11 +63,37 @@ return {
utils.create_user_event_cb(cmd.event_name, cmd.cb, leap_augroup_name)
end
require("utils").add_keymaps({
local leap_user = require("leap.user")
local leap_remote = require("leap.remote")
utils.add_keymaps({
n = {
["l"] = {
cmd = function()
require("leap").leap({ target_windows = require("leap.user").get_focusable_windows() })
-- Make sure we can Leap to any window
leap.leap({
target_windows = leap_user.get_focusable_windows()
})
end,
},
["gl"] = {
cmd = function()
leap_remote.action()
end
}
},
v = {
["l"] = {
cmd = function()
leap.leap({
target_windows = { vim.api.nvim_get_current_win() }
})
end,
}
},
o = {
["l"] = {
cmd = function()
leap_remote.action()
end,
}
}