From a4301613f9c860fed066ddcf2f927a1b6d804435 Mon Sep 17 00:00:00 2001 From: Marcelo Jacobus Date: Tue, 25 Feb 2025 15:32:04 -0300 Subject: [PATCH] More hop mappings --- lua/plugins/easy-motion.lua | 91 +++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 14 deletions(-) diff --git a/lua/plugins/easy-motion.lua b/lua/plugins/easy-motion.lua index c6f2810..073ed25 100644 --- a/lua/plugins/easy-motion.lua +++ b/lua/plugins/easy-motion.lua @@ -2,19 +2,82 @@ return { "smoka7/hop.nvim", version = "*", opts = {}, - config = function() - local hop = require("hop") - hop.setup() - vim.api.nvim_set_hl(0, "HopNextKey", { fg = "#ffcc00", bold = true }) - vim.api.nvim_set_hl(0, "HopNextKey1", { fg = "#ff8800", bold = true }) - vim.api.nvim_set_hl(0, "HopNextKey2", { fg = "#ff4400" }) - + keys = { -- Define key mappings similar to EasyMotion - vim.keymap.set("n", "f", function() - require("hop").hint_char1({ - direction = require("hop.hint").HintDirection.AFTER_CURSOR, - current_line_only = false, - }) - end, { desc = "Jump to character (EasyMotion-like)" }) - end, + { + "f", + function() + require("hop").hint_char1({ + direction = require("hop.hint").HintDirection.AFTER_CURSOR, + current_line_only = false, + }) + end, + mode = { "n", "x", "o" }, + desc = "Jump to character (EasyMotion-like)", + }, + -- Define key mappings similar to EasyMotion + { + "F", + function() + require("hop").hint_char1({ + direction = require("hop.hint").HintDirection.BEFORE_CURSOR, + current_line_only = false, + }) + end, + mode = { "n", "x", "o" }, + desc = "Jump to character (EasyMotion-like)", + }, + { + "f", + function() + require("hop").hint_char1({ + direction = require("hop.hint").HintDirection.AFTER_CURSOR, + current_line_only = true, + }) + end, + mode = { "n", "x", "o" }, + desc = "Hop forward to char", + }, + + -- EasyMotion-style `F` search (backward, current line only) + { + "F", + function() + require("hop").hint_char1({ + direction = require("hop.hint").HintDirection.BEFORE_CURSOR, + current_line_only = true, + }) + end, + mode = { "n", "x", "o" }, + desc = "Hop backward to char", + }, + + -- `t` behaves like `f` but stops before the target character (forward) + { + "t", + function() + require("hop").hint_char1({ + direction = require("hop.hint").HintDirection.AFTER_CURSOR, + current_line_only = true, + hint_offset = -1, + }) + end, + mode = { "n", "x", "o" }, + desc = "Hop forward before char", + }, + + -- `T` behaves like `F` but stops before the target character (backward) + { + "T", + function() + require("hop").hint_char1({ + direction = require("hop.hint").HintDirection.BEFORE_CURSOR, + current_line_only = true, + hint_offset = 1, + }) + end, + mode = { "n", "x", "o" }, + desc = "Hop backward before char", + }, + }, }