Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
IngoMeyer441 opened this issue Feb 21, 2024 · 3 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@IngoMeyer441
Copy link

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?

@smoka7
Copy link
Owner

smoka7 commented Feb 21, 2024

It's not possible right now.

@smoka7 smoka7 added enhancement New feature or request good first issue Good for newcomers labels Feb 21, 2024
@rosshadden
Copy link

rosshadden commented Apr 23, 2024

The problem is even more general than that (unless I'm missing something which is very possible). hint_words for example behaves just like vim's w and b in normal mode, but in operator pending mode the AFTER_CURSOR version deletes the character with the hint too, unlike what vim does for the equivalent (dw). But then BEFORE_CURSOR works exactly like db.

Since it's different behavior depending on whether you are just navigating or in the middle of an operation, the hint_offset option is not relevant here. It would make things work correctly for operations but break it for normal navigation.

@shyun3
Copy link

shyun3 commented May 31, 2024

This issue in the original repo might be relevant: hadronized#127

vim does allow forced motions so one workaround I've used for this problem is to map something like:

vim.keymap.set('o', '<Space>j', 'V:lua my_hint_lines()<CR>')

where V is used to force linewise motion and the Lua function was defined separately as my_hint_lines.

One issue I've found though is that when you do something like d<Space>j and then cancel the hints by hitting escape, it still deletes the current line where the cursor is pointing. Not sure how to prevent that at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants