hadronized / hop.nvim

Neovim motions on speed!
Other
2.47k stars 137 forks source link

Error when trying to navigate to line from empty line #335

Open chaudry-786 opened 1 year ago

chaudry-786 commented 1 year ago

Hi, If I try to navigate to another line "HopLineAC" or "HopLineBC" from an empty line I get following error.

E5108: Error executing lua /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:130: col value outside range
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:130: in function 'set_unmatched_lines'
        /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:140: in function 'apply_dimming'
        /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:352: in function 'hint_with_callback'
        /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:304: in function 'hint_with'
        /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:544: in function 'hint_lines'
        [string ":lua"]:1: in main chunk
samjwill commented 1 year ago

This doesn't happen for me on Ubuntu 22.04 with Neovim v0.8.0-1210-gd367ed9b2 (Release) and LuaJIT 2.1.0-beta3 . Is there something unique about your setup or file that you're editing that might suggest the cause of the issue?

image

cheeze2000 commented 1 year ago

:HopWordAC and :HopWordBC also have the same error when used on an empty line.

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

chaudry-786 commented 1 year ago

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

mystilleef commented 1 year ago

@sabah1994, are you using the hop.hint_lines API?

chaudry-786 commented 1 year ago

@mystilleef I dont't think so.

This is my config https://github.com/sabah1994/dotfiles/blob/d758306f2b02436ad5b48d6f8957e34b5e9a6405/nvim/lua/plug-config/hop.lua#L3

chaudry-786 commented 1 year ago

@samjwill @mystilleef any update on this please?

mystilleef commented 1 year ago

@samjwill @mystilleef any update on this please?

Unfortunately, I'm having the same issue.

klingberg commented 1 year ago

I have the same issue with HopChar2AC and HopChar2BC. It seems like the error occurs when I jump from an empty line and Hop suggests multiple destinations. When there is only one matching destination no error occurs.

hadronized commented 1 year ago

Iā€™m having a look at that tomorrow. That bug has been crawling around in several part of the API, and a refactor of the window position / jump is probably required as more and more features were added in the past months.

juanchinojo commented 1 year ago

Currently having the same issue, anyone been able to find a workaround?

NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by brew@Ventura-arm64.local

BartSte commented 1 year ago

Currently having the same issue, anyone been able to find a workaround?

NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by brew@Ventura-arm64.local

As a workaround, when the cursor is on a blank line, I let it jump to the next non-blank line, for example:

local function hop_w()
    local opts = { direction = hint.HintDirection.AFTER_CURSOR }
    vim.cmd('.g/^$/normal )')
    hop.hint_words(opts)
end

Not a nice way, and it won't work all the time, but it is enough for now...

chaudry-786 commented 1 year ago

@phaazon any update on this?

jesHrz commented 1 year ago

Same issue on hint_char1 and hint_word

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

liketurbo commented 1 year ago

Currently having the same issue, anyone been able to find a workaround? NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by brew@Ventura-arm64.local

As a workaround, when the cursor is on a blank line, I let it jump to the next non-blank line, for example:

local function hop_w()
    local opts = { direction = hint.HintDirection.AFTER_CURSOR }
    vim.cmd('.g/^$/normal )')
    hop.hint_words(opts)
end

Not a nice way, and it won't work all the time, but it is enough for now...

Still will break though if you on the last line and it is empty or file consists of an empty lines šŸ˜ž But for now it's the only solution šŸ‘ˆļø

chaudry-786 commented 1 year ago

any progress on this?

AlkTheOrg commented 1 year ago

This doesn't happen for me on Ubuntu 22.04 with Neovim v0.8.0-1210-gd367ed9b2 (Release) and LuaJIT 2.1.0-beta3 . Is there something unique about your setup or file that you're editing that might suggest the cause of the issue?

Not sure about Ubuntu, but having the same problem both in Mac Ventura and W10.

BartSte commented 1 year ago

Currently having the same issue, anyone been able to find a workaround? NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by brew@Ventura-arm64.local

As a workaround, when the cursor is on a blank line, I let it jump to the next non-blank line, for example:

local function hop_w()
    local opts = { direction = hint.HintDirection.AFTER_CURSOR }
    vim.cmd('.g/^$/normal )')
    hop.hint_words(opts)
end

Not a nice way, and it won't work all the time, but it is enough for now...

Still will break though if you on the last line and it is empty or file consists of an empty lines disappointed But for now it's the only solution point_left

A better work around is to use the following branch instead of the workaround above: https://github.com/aznhe21/hop.nvim/tree/fix-some-bugs

Hopefully it gets merged soon...

spire-carlos commented 1 year ago

Plug 'aznhe21/hop.nvim', { 'branch': 'fix-some-bugs'}

BartSte commented 1 year ago

Will this fix ever get merged?

FelipeLema commented 1 year ago

Will this fix ever get merged?

@BartSte can't say for sure, but you might try directly using the branch that fixes it in your config

BartSte commented 1 year ago

Currently having the same issue, anyone been able to find a workaround? NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by brew@Ventura-arm64.local

As a workaround, when the cursor is on a blank line, I let it jump to the next non-blank line, for example:

local function hop_w()
    local opts = { direction = hint.HintDirection.AFTER_CURSOR }
    vim.cmd('.g/^$/normal )')
    hop.hint_words(opts)
end

Not a nice way, and it won't work all the time, but it is enough for now...

Still will break though if you on the last line and it is empty or file consists of an empty lines disappointed But for now it's the only solution point_left

A better work around is to use the following branch instead of the workaround above: https://github.com/aznhe21/hop.nvim/tree/fix-some-bugs

Hopefully it gets merged soon...

Yes I know ;) @FelipeLema