From dd61c58f42d089dbf47eb88b9a555d9b31e7cd64 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 7 Aug 2024 01:07:36 +0900 Subject: nvim/hop: migrate hop.nvim repo --- .config/nvim/lua/vimrc/plugins.lua | 49 +++++++++----------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) (limited to '.config/nvim/lua/vimrc/plugins.lua') diff --git a/.config/nvim/lua/vimrc/plugins.lua b/.config/nvim/lua/vimrc/plugins.lua index 5ff13d0..b4cd1ef 100644 --- a/.config/nvim/lua/vimrc/plugins.lua +++ b/.config/nvim/lua/vimrc/plugins.lua @@ -406,8 +406,7 @@ return { }, -- Neovim clone of EasyMotion { - 'phaazon/hop.nvim', - branch = 'v2', -- Hop.nvim's README recommends this. + 'smoka7/hop.nvim', lazy = true, keys = { {'f', '(hop-f)', mode = {'n', 'o', 'x'}}, @@ -425,52 +424,26 @@ return { {'sk', '(hop-k)', mode = {'n', 'o', 'x'}}, }, config = function() - require('hop').setup { + local hop = require('hop') + hop.setup { keys = 'asdfghweryuiocvbnmjkl;', } - - -- Emulate `g:EasyMotion_startofline = 0` in hop.nvim. - local function hop_jk(opts) - local hop = require('hop') - local jump_target = require('hop.jump_target') - - local column = vim.fn.col('.') - local match - if column == 1 then - match = function(_) - return 0, 1, false - end - else - local pat = vim.regex('\\%' .. column .. 'c') - match = function(s) - return pat:match_str(s) - end - end - setmetatable(opts, { __index = hop.opts }) - hop.hint_with( - jump_target.jump_targets_by_scanning_lines({ - oneshot = true, - match = match, - }), - opts - ) - end - - local hop = require('hop') local HintDirection = require('hop.hint').HintDirection local AFTER_CURSOR = HintDirection.AFTER_CURSOR local BEFORE_CURSOR = HintDirection.BEFORE_CURSOR - vim.keymap.set('', '(hop-f)', function() hop.hint_char1({ direction = AFTER_CURSOR, current_line_only = true }) end, { silent = true }) + vim.keymap.set('', '(hop-f)', function() hop.hint_char1({ direction = AFTER_CURSOR, current_line_only = true }) end, { silent = true }) vim.keymap.set('', '(hop-F)', function() hop.hint_char1({ direction = BEFORE_CURSOR, current_line_only = true }) end, { silent = true }) - vim.keymap.set('', '(hop-t)', function() hop.hint_char1({ direction = AFTER_CURSOR, current_line_only = true, hint_offset = -1 }) end, { silent = true }) - vim.keymap.set('', '(hop-T)', function() hop.hint_char1({ direction = BEFORE_CURSOR, current_line_only = true, hint_offset = 1 }) end, { silent = true }) + vim.keymap.set('', '(hop-t)', function() hop.hint_char1({ direction = AFTER_CURSOR, current_line_only = true, hint_offset = -1 }) end, { silent = true }) + vim.keymap.set('', '(hop-T)', function() hop.hint_char1({ direction = BEFORE_CURSOR, current_line_only = true, hint_offset = 1 }) end, { silent = true }) vim.keymap.set('', '(hop-s2)', function() hop.hint_char2() end, { silent = true }) - vim.keymap.set('', '(hop-n)', function() hop.hint_patterns({ direction = AFTER_CURSOR }, vim.fn.getreg('/')) end, { silent = true }) + + vim.keymap.set('', '(hop-n)', function() hop.hint_patterns({ direction = AFTER_CURSOR }, vim.fn.getreg('/')) end, { silent = true }) vim.keymap.set('', '(hop-N)', function() hop.hint_patterns({ direction = BEFORE_CURSOR }, vim.fn.getreg('/')) end, { silent = true }) - vim.keymap.set('', '(hop-j)', function() hop_jk({ direction = AFTER_CURSOR }) end, { silent = true }) - vim.keymap.set('', '(hop-k)', function() hop_jk({ direction = BEFORE_CURSOR }) end, { silent = true }) + + vim.keymap.set('', '(hop-j)', function() hop.hint_vertical({ direction = AFTER_CURSOR }) end, { silent = true }) + vim.keymap.set('', '(hop-k)', function() hop.hint_vertical({ direction = BEFORE_CURSOR }) end, { silent = true }) end, }, -- Extend J. -- cgit v1.2.3-70-g09d2