Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Would it be possible to highlight words or line which are before or after cursor ? #71

Closed
Nico-Guyon opened this issue Apr 16, 2021 · 13 comments

Comments

@Nico-Guyon
Copy link

Nico-Guyon commented Apr 16, 2021

First thank you for this great plugin !

I was using easymotion until now and unfortunately it became unusable after enabling diagnostics since the labels are shortly parsed as the buffer is modified.
Hop is a great replacement for my usage of easymotion except for one thing: the ability to highlight before or after the cursor position.

For example with easymotion if you press:

  • <easymotion-prefix>w it will highlight all words after the cursor
  • <easymotion-prefix>b it will highlight all words before the cursor
  • in the same way <easymotion-prefix> with j or k will highlight lines below or above the current line

This is quite practical because if you know where you want to jump, it can show less labels.

Is it already possible with hop ?
If not would it be possible to add some functions for example HopWordNext, HopWordPrev, HopLineAbove, HopLineBelow ?

@jhgarner
Copy link

This is what I've added in #60.

@hadronized
Copy link
Owner

Yes it’s on-going. I need to review several PRs and I’ve been a little busy lately but it should land ~soonish.

hadronized added a commit that referenced this issue Jun 13, 2021
This first commit allows to apply the hints to only the previous part of
the cursor or what comes after.

This commit doesn’t currently check the column, only the line. The next
commit will add support for before / after on the current line and
should also add support for a way to reduce apply hints only to the
current line.

This is an alternative implementation of #59.

Relates to #71, #91.
hadronized added a commit that referenced this issue Jun 18, 2021
Allows to hint lines by respecting a before / after hint mode. The
first / last line will be truncated accordingly.

Relates to #71, #91.
hadronized added a commit that referenced this issue Jun 19, 2021
Allows to hint lines by respecting a before / after hint mode. The
first / last line will be truncated accordingly.

Relates to #71, #91.
@hadronized
Copy link
Owner

This is now implemented in #93 and is going to be merged on master very soon.

@Nico-Guyon
Copy link
Author

Thanks :)

@Nico-Guyon
Copy link
Author

That was one of the feature I was missing from easymotion, it's so great that it's now also available on hop !

I'm sorry to ask this but easymotion had another cool thing I was using also all the time, some motion operators for more precise jumps.

For example, I was using those bindings all the time :

  • <easymotion-prefix>e to jump forward to the end of a word
  • <easymotion-prefix>ge to jump backward to the end of a word

There is also another distinction with f and t:

  • <easymotion-prefix>f and <easymotion-prefix>F can be used to find a character forward / backward (which now correspond to HopChar1 AC / BC)
  • <easymotion-prefix>t and <easymotion-prefix>T is nearly the same but instead of find it's a 'till' operation and will jump just before the character

These features may seem like a nice to have and maybe they are, but they add some more precision to your jumps and instead of doing a jump followed by a motion, if you know exactly where you want to go you can do both at the same time.

It would be great to add for example a command HopWordEnd (AC / BC) and HopTillChar1 (AC / BC)

What are your thoughts on this ?
Do you have an idea if it's possible to add those two operators to hop ?
If you want I can try to implement it ?

@luiz00martins
Copy link

@Nico-Guyon It seems like this was being worked on in #48.

@FelipeLema
Copy link
Contributor

@luiz00martins is it being worked on right now? I kinda got lost and if no one is looking into it I'm willing to do the work

@luiz00martins
Copy link

@FelipeLema It seems like this was being worked on by jhgarner on his fork, but looking by the age of the last commit, I think it was abandoned. It may be a good idea to, if not fork it, at least take a look at it to avoid repeated work.

Also, by reading #59 and #60's close messages by phaazon, it seems like in his opinion these features are already sufficiently implemented, or were "superseded" by #93. I would disagree with that. For example, it seems like there's no separation between f and t (i.e. stop inside or before) style motions, or "work only in this line" type motions (like vim's default f and t), or the mentioned "jump to the end of a word" motions. These were all implemented by jhgarner's fork. It may be the case that phaazon might not find these useful enough, or doesn't like the way that people are currently trying to implement them.

Nonetheless, it'd be best if you talked to @phaazon directly to get his opinion. This might avoid unnecessary work and help the future PR go in the right direction.

@jhgarner
Copy link

jhgarner commented Aug 3, 2021

It's less that the fork was abandoned and more that it had all the features I used and it sounded like phaazon had a better way of implementing it. For now, I use the "mergedall" branch of my fork although I hope to switch back to mainline hop once phaazon adds the remaining features.

@FelipeLema
Copy link
Contributor

@jhgarner could you expand on the "remaining features"? are these currently work in progress? are they any specific pull requests?

@jhgarner
Copy link

jhgarner commented Aug 6, 2021

The remaining features that still need to be added from "mergedall" are basically the things mentioned a couple messages up ( #71 (comment)) and stuff like issue #125. It sounds like #123 is one of the pull requests needed to add these features in a more sustainable way.

@hadronized
Copy link
Owner

Damn, I completely missed the rest of the discussion; sorry for that.

The idea of adding a HopWordEnd is a really good one, I like it. Given the current codebase, it should be very simple to write such a command (probably just a special regex to use). For the preserve jump, this will probably be done by the end of the week (if no one has come up with a patch in the meantime).

For f / F and t / T, this is already supported but the feature is really not up to my standards right now (it’s inclusive_jump). It’s counter-intuitive and doesn’t work all the time depending on the context. I want to change / refactor that with generic offset jumps. I’ll try to work on that this week too.

Clearly preserving the column is a low hanging fruit here.

@hadronized
Copy link
Owner

It is now possible to switch to either the beginning or the end position of a matched jump target. I’m going to close this PR as it contained a lot of elements. Please don’t hesitate to comment if you thing something is still missing (or open a PR for that specific thing, I’d rather like). Thank you.

yehuohan pushed a commit to yehuohan/hop.nvim that referenced this issue Apr 22, 2024
* docs: update to current implementation

* docs: add manh_distance and readwise_distance
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants