Giter Club home page Giter Club logo

hop.nvim's People

Contributors

afterlook avatar aznhe21 avatar blakejc94 avatar christianchiarulli avatar ckafi avatar clason avatar delphinus avatar dreomite avatar dsabadie-datadog avatar ehllie avatar felipelema avatar firstmover avatar hadronized avatar henry-hsieh avatar iago-lito avatar ii14 avatar itepechi avatar jackwiseman avatar johnlevidy avatar maaslalani avatar matts966 avatar mhinz avatar runiq avatar smoka7 avatar snezhniylis avatar spamwax avatar tssm avatar voldikss avatar yehuohan avatar ysy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hop.nvim's Issues

Allow to go to previous hint state

In many applications that allow for hints (alacritty, vimium in the browser), pressing backspace after the initial key press allows you to go back to the previous hint state. Would it be possible to implement the same in hop? e.g. if I HopWord and the hints lr kr show up somewhere in the buffer. I press l, and the hint updates to r. I want to press <BS> to go back to lr in case I made a mistake initially pressing l and instead intended to press k. As things are right now I have to HopWord again.

Update documentation

Hi

It seems the documentation is still referencing old locations of some functions.
E.g. regex_by_word_start() is no longer in jump_targets but in jump_regex.

hint_char1 uses regexes

Describe the bug

hint_char1 uses regexp search instead of a straightforward character search.

To Reproduce

This should be straightforward to reproduce:

Define an f keymap as recommended by documentation:

vim.keymap.set('', 'f', function()
  hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = true })
end, {remap=true})
  1. Open a file with content like this:
Some text [text in brackets]
  1. Press f[

You'll see

E5108: Error executing lua: .../.local/share/nvim/lazy/hop.nvim/lua/hop/jump_target.lua:413: couldn't parse regex: Vim:E769: Missing ] after %s[                                                                                                               
stack traceback:                                                                                                                                                                                                                                               
        [C]: in function 'regex'                                                                                                                                                                                                                               
        .../.local/share/nvim/lazy/hop.nvim/lua/hop/jump_target.lua:413: in function 'regex_by_case_searching'                                                                                                                                                 
        ...rzmilka/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:519: in function 'hint_char1'                                                                                                                                                              
        /Users/grzegorzmilka/.config/nvim/lua/misc-plugins.lua:348: in function </Users/grzegorzmilka/.config/nvim/lua/misc-plugins.lua:345>    

Expected behavior

Hop jumps to the first occurrence of `[

version (please complete the following information):

  • Nvim version: 0.9.4
  • hop.nvim version: a75b915

Additional context

Also f. jumps to any character. This is wrong behavior for HopChar1, which ideally should jump to exactly the character specified. It doesn't make much sense from UX perspective to expect the user to provide a regexp. We can't make any proper regexp with just one character, and we eliminate control characters from becoming targets.

At least there should be an option to disable regexpes from Hop.

Edit: I discovered that this behavior started happening in the recent commit: a75b915.

Error when HopLineBC or HopWordBC on an empty line

Describe the bug

Error executing Lua callback: ...a/.local/share/vscnvim/plugged/hop.nvim/lua/hop/init.lua:139: Invalid 'end_col': out of range
stack traceback:
[C]: in function 'nvim_buf_set_extmark'
...a/.local/share/vscnvim/plugged/hop.nvim/lua/hop/init.lua:139: in function 'set_unmatched_lines'
...a/.local/share/vscnvim/plugged/hop.nvim/lua/hop/init.lua:155: in function 'apply_dimming'
...a/.local/share/vscnvim/plugged/hop.nvim/lua/hop/init.lua:364: in function 'hint_with_callback'
...a/.local/share/vscnvim/plugged/hop.nvim/lua/hop/init.lua:315: in function 'hint_with'
...a/.local/share/vscnvim/plugged/hop.nvim/lua/hop/init.lua:567: in function 'hint'
...jia/.local/share/vscnvim/plugged/hop.nvim/plugin/hop.lua:59: in function <...jia/.local/share/vscnvim/plugged/hop.nvim/plugin/hop.lua:58>

To Reproduce
Call HopLineBC on any empty lines

version (please complete the following information):

  • Nvim version: 0.9.1
  • hop.nvim version: Git head

HopYankChar1 - First character is not included in yank

When using HopYankChar1 the first (leftmost or uppermost) character is not included in the yank.
For example if you have text abcdefgh and select a as the start character for the yank and h as the terminating character then the actual yanked text is bcdefgh. This behavior is the same h is selected first then a.

To Reproduce
Initiate command HopYankChar1, follow the Yank start pattern prompt to select a start character. Follow the Yank end pattern prompt to select the end character. Paste the yanked text to see the result.

Expected behavior
The first character should be included instead of excluded. i.e. from the intro abcdefgh should be in the yank register.

Screenshots
N/A

version (please complete the following information):

  • Nvim version: 0.9.1
  • hop.nvim version: 2.3.0

Additional context
No additional comments. But thank you for continuing this plugin!

case_insensitive Isn't working

Describe the bug
Setting the case_insensitive = false, on the opts key and then running commands like: :HopChar1 doesn't seem to be working

To Reproduce
Steps to reproduce the behavior:

-- bootstrap lazy
        local lazypath = root .. "/plugins/lazy.nvim"
        if not vim.loop.fs_stat(lazypath) then
          vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
        end
        vim.opt.runtimepath:prepend(lazypath)

-- install hop.nvim
        local plugins = {
          { 
            "smoka7/hop.nvim", 
            opts = { 
               case_insensitive = false, 
            } 
          },
        }
        require("lazy").setup(plugins,{})
--- How You use hop...

:HopChar1

Expected behavior
It should respect the case_insensitive prop and only highlight the matching capital letters.

version (please complete the following information):

  • Nvim version: 0.9.5
  • hop.nvim version: * (latest)

add tests

Describe the bug
The repo is missing tests. Why a repo is should have tests is a given

To Reproduce

Expected behavior

Have tests ran in pull requests

Screenshots

version (please complete the following information):

Additional context

See hadronized#271 for a first approach. Still dunno why was it closed.

HopLine no longer labels folds

Describe the bug

The old HopLine labeled folds. After switching to this fork, it no longer does so.

To Reproduce

  1. Enable folds in nvim
  2. Open a file with folds
  3. Fold some lines
  4. Show line labels with :HopLine

Expected behavior

I expect folded lines to be labeled like the original Hop did.

Screenshots

Here's the screenshot of the old behavior with folded lines labeled.

hop_bug_two

Here's the screenshot of the new behavior with folded lines not labeled.

hop_bug_one

version (please complete the following information):

  • Nvim version: master
  • hop.nvim version: master

Support repeating jumps

I've only given the codebase a cursory look so I'm not sure how feasible this is but I've been missing the ;/, (or n/N) functionality of EasyMotion with its easymotion-next and easymotion-prev commands. If the upstream repo shows signs of life I'll transfer this issue there but until then I'll leave it here. If it's doable and within my abilities to implement this then I'll try to get a PR going for this if I find the time.

Bug: Calling any Hop command on an empty line with folke/noice.nvim installed causes the cursor to turn black

Describe the bug
When you call any hop command on an empty line with noice installed, the cursor turns black. This is true with all color schemes.

I have tried

vim.cmd("highlight! link NoiceCursor Cursor")

But this doesn't fix anything.

To Reproduce

  1. Create an empty line
  2. Put cursor on empty line
  3. <cmd>HopChar1AC<cr>
-- bootstrap lazy
        local lazypath = root .. "/plugins/lazy.nvim"
        if not vim.loop.fs_stat(lazypath) then
          vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
        end
        vim.opt.runtimepath:prepend(lazypath)

-- install hop.nvim
        local plugins = {
          { "smoka7/hop.nvim", opts = {} },
          {"folke/noice.nvim", opts = {} },
        }
        require("lazy").setup(plugins,{})

Expected behavior
I expect the cursor to remain the same color.

Screenshots
With noice enabled

With noice disabled

version (please complete the following information):

  • Nvim version: NVIM v0.9.1
  • hop.nvim version: "hop.nvim": { "branch": "master", "commit": "5681edd36cf858c821826178e77af78463c1c281" }

Hop target incorrectly positioned for lsp inlay hints

Describe the bug
When I have this code (notice the inlay hints which are some kind of virtual text)
image

and I want to jump to the first ' character. I see this
image

To Reproduce
Let me know if you would like me to provide code for a full repro. I don't have the time to do it right now as the setup is a bit confusing to me and it will take some time.

Expected behavior
The hop target should be displayed on the ' character. It was unexpectedly displayed on the inlay hint instead.

version (please complete the following information):

  • Nvim version: NVIM v0.10.0-dev-2086+g965dbd0e0
  • hop.nvim version: 6d853addd6e11df8338b26e869a29b36f2c3e893

Additional context
My hop config:

---@type LazySpec
return {
  "smoka7/hop.nvim",
  version = "*",
  event = "VeryLazy",
  opts = {},
  keys = {
    {
      "<leader>y",
      mode = { "n", "x", "o" },
      function()
        local hop = require("hop")
        hop.hint_lines_skip_whitespace({})
      end,
      desc = "Hop to line",
    },

    {
      "<leader><leader>",
      mode = { "n", "x", "o" },
      function()
        local hop = require("hop")
        hop.hint_char1({})
      end,
      desc = "Hop to given character",
    },
  },
}

Jump back (i.e. ctrl-o) is broken after hop (at least :HopChar1)

Describe the bug
The cursor is on the position P. Use :HopChar1 to hop somwhere and the ctrl-o to jump back. Cursor is not on the original position P.

To Reproduce
Configuration:

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  { "smoka7/hop.nvim", opts = {} },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

Steps to reproduce the behavior:

  1. Let's have a file with simple content:
first
second
third
  1. Put the cursor on the first line on character r.
  2. Run :HopChar1, use character i, so you get two targets (a in the word first and s in the word third) - choose s
  3. Press ctrl-o to jump back
  4. You are on character f in the word first

Expected behavior
After jump back by ctrl-o, you should be on the character r in the word first - the place before hop.

Version (please complete the following information):

  • Nvim version: 0.9.1
  • hop.nvim version: master

Additional context
Additionally - in the more complex content, the cursor is not even on the same line after ctrl-o.

Thank you for maintaining hop.nvim after the original project become unmaintained. However, after switch to this repo this issue appeared. It breaks e.g. following workflow: hop somewhere, cut/yank some content, jump back and put the content there.

Documentation points to upstream wiki

Describe the bug
README file points to upstream wiki in phaazon's repo

To Reproduce

Expected behavior
Either migrate wiki or not mention it. Pointing to the upstream wiki could result in confusion as the code in this fork changes through time

Screenshots

version (please complete the following information):

Additional context

:HopPattern not working

Describe the bug
:HopPattern not working. Results in a ipairs error.

To Reproduce
Steps to reproduce the behavior:

-- bootstrap lazy
        local lazypath = root .. "/plugins/lazy.nvim"
        if not vim.loop.fs_stat(lazypath) then
          vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
        end
        vim.opt.runtimepath:prepend(lazypath)

-- install hop.nvim
        local plugins = {
          { "smoka7/hop.nvim", opts = {} },
        }
        require("lazy").setup(plugins,{})
--- How You use hop...
:HopPattern
<insert pattern> + Enter

Expected behavior
The pattern searched for gets highlighted.

Screenshots
image

version (please complete the following information):

  • Nvim version: NVIM v0.9.2
  • hop.nvim version: Commit df0b5b6

Additional context

How to configure custom highlights without hop.nvim overriding

I need some guidance on configuring custom highlights in this plugin. Currently, I'm using a Lua file to set custom highlights like this:

local function set_hl(group, tbl)
  vim.api.nvim_set_hl(0, group, type(tbl) == 'table' and tbl or { fg = tbl })
end

set_hl('HopNextKey', { fg = '#ffffff', bg = '#ff007c', bold = true })
set_hl('HopNextKey1', { fg = '#ffffff', bg = '#00dfff', bold = true })
set_hl('HopNextKey2', { fg = '#ffffff', bg = '#2b8db3' })
set_hl('HopUnmatched', { fg = '#666666', sp = '#666666' })

While this works, I noticed that when I set custom highlights in my Lua file, they get overridden by hop.nvim, making me re-require the Lua file after hop setup.

Is there a more streamlined way to define custom highlights without this overriding issue in hop.nvim? Any guidance or suggestions would be greatly appreciated.
(I have already disabled the 'create_hl_autocmd' option if that's relevant)

-- Insert the highlights and register the autocommand if asked to.

How to use with select/delete/change/yank etc

I feel like a bit of an idiot. In the feature list I see that hop can be used "with commands like v, d, c, y to visually select/delete/change/yank up to your new cursor position." My assumption is that I could initiate, say, delete as usual by pressing the 'd' key. Then I'd be able to press a second key as part of the delete "chord" to invoke hop. Whatever hop matched would be deleted.

I put the following in my init.lua:
vim.api.nvim_set_keymap('n', 'dh', ':HopChar1<CR>', { noremap = true, silent = true })

(Normally dh would delete left, but I wanted to invoke hop instead.)

What this actually seems to do is exit the delete and then do a standard hop.char1. That is, no deletion occurs.

I'm guessing I'm missing something very simple. Could you help me figure out how to properly integrate hop into select/delete/change/yank via key chords? TIA!

Custom callback feels clunky

I found out about the custom callback feature, so I decided to implement my first one in my neovim config. This simply extends the HopLineStart to immediately enter insert mode on a new line:

local hop = require("hop")
hop.setup({})

local hop_insert_line = function()
    local regex = require("hop.jump_regex").regex_by_line_start_skip_whitespace()
    local target = require("hop.jump_target").jump_target_generator(regex)
    hop.hint_with_callback(target, hop.opts, function(jt)
        hop.move_cursor_to(jt, hop.opts)
        -- v this the critical line
        vim.api.nvim_input("o")
    end)
end

vim.keymap.set("n", "go", hop_insert_line)

I feel this is a lot of boilerplate for a single lua command callback to a single default target. Is there an easier way to implement this? If not, could the default targets accept a callback as an optional parameter?

The help documentation is excellent, but it is lacking an example that would have likely saved me some time. Would adding my example to the wiki, hop.txt, or examples make sense?

:HopChar1CurrentLineAC creates two jump characters instead of just jumping

Describe the bug
When using :HopChar1CurrentLineAC with the cursor on some character X, if there is at least one more X ahead on the line,
:HopChar1CurrentLineAC creates a jump character for where the cursor is as well as all subsequent Xs.

To Reproduce
Steps to reproduce the behavior:

-- bootstrap lazy
        local lazypath = root .. "/plugins/lazy.nvim"
        if not vim.loop.fs_stat(lazypath) then
          vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
        end
        vim.opt.runtimepath:prepend(lazypath)

-- install hop.nvim
        local plugins = {
          { "smoka7/hop.nvim", opts = {} },
        }
        require("lazy").setup(plugins,{})
--- How You use hop...

Suppose we have the line live love laugh with the cursor on the l on love. Running :HopChar1CurrentLineAC
will create a jump character to jump on the l for love and another one to jump on the l for laugh.

Expected behavior
The cursor should jump directly to the l on love without creating a jump character, similar to what you would expect with using f,t,F,T.

version (please complete the following information):

  • Nvim version: 9.0.2
  • hop.nvim version: master

Additional context
This also applies to :HopChar1CurrentLineBC (but is perhaps expected behaviour for :HopChar1CurrentLine?)

`require 'hop'.hint_char1({direction = require 'hop.hint'.HintDirection.BEFORE_CURSOR})` errors when standing in empty line

Describe the bug

hop.nvim errors when doing require 'hop'.hint_char1({direction = require 'hop.hint'.HintDirection.BEFORE_CURSOR})

To Reproduce

  • Create empty buffer
  • input the following text
...

  • :norm G (make sure you're standing at the last line)
  • :lua require 'hop'.hint_char1({direction = require 'hop.hint'.HintDirection.BEFORE_CURSOR}) and input .
  • currently getting the following error
E5108: Error executing lua: .../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:139: Invalid 'end_col': out of range
stack traceback:
	[C]: in function 'nvim_buf_set_extmark'
	.../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:139: in function 'set_unmatched_lines'
	.../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:155: in function 'apply_dimming'
	.../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:364: in function 'hint_with_callback'
	.../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:315: in function 'hint_with'
	.../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:519: in function 'hint_char1'
	/home/user/.config/nvim/lua/custom/plugins/init.lua:29: in function </home/user/.config/nvim/lua/custom/plugins/init.lua:25>

Expected behavior

hop offers candidates to jump to any of the three .s in the first line

Screenshots
NA

version (please complete the following information):

  • Nvim version: 0.9.1
  • hop.nvim version: 877e175

Additional context
NA

Clear status line after hop when `cmdheight > 1`

Re-raising this issue from the original repo: hadronized#276

When I use :HopChar1, the statusline changes to Hop 1 Char: . However, this does not go away after hopping when using more than 1 line for the statusline (when the cmdheight option is greater than 1).

Would it be possible to clear the prompt after hopping no matter how large the statusline is?

error when hopping from empty line

Describe the bug
vim throws an error when doing hop_char1(direction=HintDirection.AFTER_CURSOR) from an empty line (HintDirection.BEFORE_CURSOR works ok, though)

To Reproduce
Steps to reproduce the behavior:

  • stand on an empty buffer
  • create next line using o, write any character twice (say ..)
  • go back to first empty line (gg)
  • call lua require 'hop'.hint_char1({direction = require 'hop.hint'.HintDirection.AFTER_CURSOR}) and enter the chacter (., see step 2)
  • get the following error
E5108: Error executing lua: .../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:139: Invalid 'col': out of range
stack traceback:
	[C]: in function 'nvim_buf_set_extmark'
	.../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:139: in function 'set_unmatched_lines'
	.../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:155: in function 'apply_dimming'
	.../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:364: in function 'hint_with_callback'
	.../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:315: in function 'hint_with'
	.../user/.local/share/nvim/lazy/hop.nvim/lua/hop/init.lua:519: in function 'hint_char1'
	/home/user/.config/nvim/lua/custom/plugins/init.lua:62: in function </home/user/.config/nvim/lua/custom/plugins/init.lua:58>

Expected behavior
If you add a space to the empty line, everything behaves as expected

Screenshots
NA

version (please complete the following information):

  • Nvim version: 9.1
  • hop.nvim version: 0b250bf

Additional context
NA

create_hl_autocmd = false does not work

Hi,

Thanks for maintaining this plugin.

The wiki and internal documentation indicate to use create_hl_autocmd = false (:help hop-config-create_hl_autocmd)

https://github.com/smoka7/hop.nvim/wiki/Configuration#control-highlight-autocommands-with-create_hl_autocmd

It doesn't work anymore since 90e078a as reported in #20.

Is it possible to restore this option?

Some colorshemes (like gruvbox-materiel ans others) customize highlights for popular plugins like hop.

version (please complete the following information):

  • Nvim version: 0.9.2
  • hop.nvim version: 2.3.0 (git master)

Incompatibility with nvim-treehopper

nvim-treehopper works fine with original hop, but not with this fork.

E5108: Error executing lua: ...ugel/.local/share/nvim/lazy/nvim-treehopper/lua/tsht.lua:301: ...rugel/.local/share/nvim/lazy/hop.nvim/lua/hop/window.lua:74: attempt to index local 'opts' (a nil value)
stack traceback:
	[builtin#36]: at 0x01047bc61c
	...ugel/.local/share/nvim/lazy/nvim-treehopper/lua/tsht.lua:301: in function 'move'
	/Users/bruno.krugel/.config/nvim/lua/custom/mappings.lua:405: in function </Users/bruno.krugel/.config/nvim/lua/custom/mappings.lua:404>

Feature: Use treesitter textobject awarness for the current context as where to jump

Sup smoka! I would finally like to contribute to hop. I mostly use t and T to jump on the current line for faster navigation. Let me quickly brush over what's bugging me.

Lets consider the following line:

    compact_success_msg "Plugins cloned successfully."

Often you use motions such as ciw to quickly change a word and lets say I want to change the word success from the line above unfortunately ciw wont to the trick here neither does b or e as compact_success_msg is the whole node and none of these motions are aware of the substring success. So the simple solution is to use something like hop current line to quickly jump where you want the cursor to be.

Now my cursor is on the first s of the substring success and invoking my jump will leave me with the following options:

image

Depending on the length of the line this won't allow me to consistently establish a muscle memory for selecting the current actual word success because the hop selection counts all occurrences of the substring s on the current line and in case of the substring Plugins I'm presented with the jumptarget v instead of t.

image

This got me thinking that it could be useful to implement text object awarness to assign jumptargets in the current context to have a more consisten set of jump targets. Note: this enavitibly opens up a variety of new features of jumping behaviours such incremental adding of jump targets or a range of jump targets where the user is supposed to define two jump targets instead of one to make a selection for example.

This also opens up a variety of ways this could be implemented I wanted to know how you envision the future of hop and what I can do to help. Would be great if we could discuss the details. One possible way is to provide different schema queries from treesitter for different languages for example.

Random error while trying to hop

Describe the bug
When I have two vertical windows and I try to hop from the one of them, I randomly get the following error.

Error executing Lua callback: ...re/nvim/site/pack/packer/start/hop.nvim/lua/hop/init.lua:110: attempt to get length of a nil value
stack traceback:
        ...re/nvim/site/pack/packer/start/hop.nvim/lua/hop/init.lua:110: in function 'set_unmatched_lines'
        ...re/nvim/site/pack/packer/start/hop.nvim/lua/hop/init.lua:164: in function 'apply_dimming'
        ...re/nvim/site/pack/packer/start/hop.nvim/lua/hop/init.lua:373: in function 'hint_with_callback'
        ...re/nvim/site/pack/packer/start/hop.nvim/lua/hop/init.lua:324: in function 'hint_with'
        ...re/nvim/site/pack/packer/start/hop.nvim/lua/hop/init.lua:471: in function <...re/nvim/site/pack/packer/start/hop.nvim/lua/hop/init.lua:464>

This happens after upgrading to the lastest version.

To Reproduce
Steps to reproduce the behavior:

-- bootstrap lazy
        local lazypath = root .. "/plugins/lazy.nvim"
        if not vim.loop.fs_stat(lazypath) then
          vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
        end
        vim.opt.runtimepath:prepend(lazypath)

-- install hop.nvim
        local plugins = {
          { "smoka7/hop.nvim", opts = {} },
        }
        require("lazy").setup(plugins,{})
--- How You use hop...

Expected behavior
Jump markers should appear without any error

Screenshots

Screen.Recording.2023-08-29.at.08.26.37.mov

version (please complete the following information):

  • Nvim version: NVIM v0.10.0-dev-1773+g55f6a1cab-Homebrew
  • hop.nvim version: v2.2.6

HopVertical command not work

Describe the bug
HopVertical command not work

To Reproduce
Steps to reproduce the behavior:
In nvim Command mode exec HopVertical

-- bootstrap lazy
        local lazypath = root .. "/plugins/lazy.nvim"
        if not vim.loop.fs_stat(lazypath) then
          vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
        end
        vim.opt.runtimepath:prepend(lazypath)

-- install hop.nvim:
editor["smoka7/hop.nvim"] = {
	lazy = true,
	event = "VeryLazy",
	config = require("editor.hop"),
}
--- How You use hop...

Expected behavior
In nvim command mode exec HopVertical, it work

Screenshots
If applicable, add screenshots to help explain your problem.
image

version (please complete the following information):

  • Nvim version: 0.9.1
  • hop.nvim version: latest, commit: 31e0e42

Additional context
Add any other context about the problem here.

Bug: Invalid `end_col`: out of range

Describe the bug

When using <cmd>HopLineAC<cr> or <cmd>HopLineBC<cr> to jump to below/above lines, there's an error:

image

To Reproduce

Install hop.nvim with lazy.nvim:

  {
    "smoka7/hop.nvim",
    version = "*",
    config = function() 
      require("hop").setup()
    end,
  },

I found in below lua file, it can always re-produce this issue.

Here's the file link: https://github.com/linrongbin16/fzfx.nvim/blob/2f7425cf7fdb94814eb98295f3fb7851daace68d/spec/lib/switches_spec.lua?plain=1#L13

local cwd = vim.fn.getcwd()

describe("lib.switches", function()
  local assert_eq = assert.is_equal
  local assert_true = assert.is_true
  local assert_false = assert.is_false

  before_each(function()
    vim.api.nvim_command("cd " .. cwd)
  end)

  local switches = require("fzfx.lib.switches")
  describe("[fzfx_disable_buffer_previewer]", function()
    it("disabled", function()
      vim.g.fzfx_disable_buffer_previewer = 1
      assert_true(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = true
      assert_true(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = "true"
      assert_false(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = nil
      assert_false(switches.buffer_previewer_disabled())
    end)
    it("enabled", function()
      vim.g.fzfx_disable_buffer_previewer = 0
      assert_false(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = false
      assert_false(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = "false"
      assert_false(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = nil
      assert_false(switches.buffer_previewer_disabled())
    end)
  end)
end)

The re-produce steps are:

  1. Place the cursor to line-13, column-47 (the function()).
  2. Press <S-V> to enter visual mode (and current line is selected).
  3. Press G to go to bottom line (and from the start line to the bottom line are all selected).
  4. Press <Leader>k (I mapped this key to <cmd>HopLineBC<cr>) to jump to above lines.

Expected behavior

Don't throw exception, and jump correctly.

Screenshots

See above.

version (please complete the following information):

  • Nvim version: NVIM v0.10.1, Build type: Release.
  • hop.nvim version: v2.7.0.

Additional context

N/A.

Allow Custom Distance Function or Support Read-wise Distance

I would like to be able to rely on the first 3 hops ( read top to bottom, left to right ) being labeled 'a', 's', 'd' ( rather than Manhattan distance ). For example, in the following case:

abcdefghijklmnopqrstuvwxyz
this is the z i mean

If I start with my cursor on the k and single char hop to "z", the "a" ends up on the z on the line below, which frequently leads to me deleting more than I intend, since I always scan lines left to right before top to bottom.

I would like to provide my own scoring function ( rather than xbias ) which always orders higher lines first and always orders leftmost characters first. That way I can rely on usages like: "dft<target>a" always being safe ( and especially, means in the common case I don't even need to read the targets -- even if it's additional keystrokes it is a sequence I can rely on ).

I'm happy to take a stab at the changes myself if there's appetite for it!

My initial thought was that config could just take a custom function similar to x_bias which receives the same parameters ( minus bias of course ).

HopLine in operator pending mode not working on lines as a whole

Thanks for maintaining this nice plugin. I was trying to configure a key binding for operator pending mode which deletes several lines at once. For this a tried to add this configuration:

vim.keymap.set('', '<Space>j', function()
  hop.hint_lines({ direction = directions.AFTER_CURSOR, current_line_only = false })
end, {remap=true})

It works great to jump to a line in normal mode, but operator mode behaves a bit odd. In this example text (cursor position marked with |)

ab|c
def
ghi

I would expect to delete all lines when jumping to the last line with d<Space>j. Instead, the text

abhi

is left in the buffer. Is it somehow possible to tell hop to work on whole lines?

HopWordMW seems to not work cross-window from within terminal buffers (normal mode)

First things first

First of all: Thank you so much for this great plugin, i love it a lot and appreciate the work!

Describe the bug

The HopWordMW user command does not allow me to hop to a window outside a terminal buffer (in normal mode).

To Reproduce

I have this configuration:

-- install and configure hop.nvim
  {
    'smoka7/hop.nvim', -- hopping arround
    version = "*",
    config = function()
      require('hop').setup {
        multi_windows = true,
      }
    end
  },

-- hop arround anywhere cross windows
vim.api.nvim_set_keymap("n", "f", "<cmd>HopWordMW<CR>",
  { noremap = true, silent = true, desc = "Hop anywhere cross windows" })

Expected behavior

Use the command mapping to hop from any visible split window to any other visible split window.

Screenshots

hop'ing from a normal text buffer (multi windows works)r:

image

hop'ing from a terminal buffer in normal mode (multi windows does not work on my machine):

image

version (please complete the following information):

NVIM v0.9.2
Build type: Release
LuaJIT 2.1.0-beta3

with latest hop version:

version 2.3.1
tag     v2.3.1
branch  master
commit  f2508f4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.