From 3f2bf0fdeeb2621d31fdab066fef3c6a515857b7 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 17 Apr 2026 09:43:51 +0200 Subject: [PATCH] Remove deprecated flit and use leap --- nvim/lua/plugins/motions.lua | 53 ++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/nvim/lua/plugins/motions.lua b/nvim/lua/plugins/motions.lua index 38320f4..cc1ed63 100644 --- a/nvim/lua/plugins/motions.lua +++ b/nvim/lua/plugins/motions.lua @@ -1,3 +1,38 @@ +vim.keymap.set({ 'n', 'x', 'o' }, 's', '(leap)') +vim.keymap.set('n', 'S', '(leap-from-window)') + +local function ft(key_specific_args) + require('leap').leap( + vim.tbl_deep_extend('keep', key_specific_args, { + inputlen = 1, + inclusive = true, + opts = { + -- Force autojump. + labels = '', + -- Match the modes where you don't need labels (`:h mode()`). + safe_labels = vim.fn.mode(1):match('o') and '' or nil, + }, + }) + ) +end + +local clever = require('leap.user').with_traversal_keys +local clever_f, clever_t = clever('f', 'F'), clever('t', 'T') + +vim.keymap.set({ 'n', 'x', 'o' }, 'f', function() + ft { opts = clever_f } +end) +vim.keymap.set({ 'n', 'x', 'o' }, 'F', function() + ft { backward = true, opts = clever_f } +end) +vim.keymap.set({ 'n', 'x', 'o' }, 't', function() + ft { offset = -1, opts = clever_t } +end) +vim.keymap.set({ 'n', 'x', 'o' }, 'T', function() + ft { backward = true, offset = 1, opts = clever_t } +end) + + return { { "vim-wordmotion", @@ -15,22 +50,4 @@ return { vim.g.wordmotion_nomap = true end, }, - - { - "leap.nvim", - keys = { - { "s", "(leap-forward-till)", mode = { "n", "x", }, desc = "Leap forward to" }, - { "S", "(leap-backward)", mode = { "n", "x", }, desc = "Leap backward to" }, - { "z", "(leap-forward-till)", mode = "o", desc = "Leap forward to" }, - { "Z", "(leap-backward)", mode = "o", desc = "Leap backward to" }, - }, - }, - - { - "flit.nvim", - keys = { "f", "F", "t", "T" }, - after = function() - require("flit").setup() - end, - }, }