hop.nvim icon indicating copy to clipboard operation
hop.nvim copied to clipboard

Automatically include 'shifted version' of typed key, when matching.

Open ELLIOTTCABLE opened this issue 4 years ago • 1 comments
trafficstars

As with a lot of Issues in this repository, this is requesting reimplementation of an EasyMotion feature: g:EasyMotion_use_smartsign_us, et al.

Smartsign                                                *EasyMotion_smartsign*
                                                *g:EasyMotion_use_smartsign_us*
                                                *g:EasyMotion_use_smartsign_ja*

Matching signs target keys by smartcase like. E.g. type '1' and it matches
both '1' and '!' in Find motion.

This feature depends on your keyboard layout, so you must choose which
keyboard layout you use.

How to discriminate:
    Shift-2 = @ -> US layout
    Shift-2 = " -> JP layout

>
    let g:EasyMotion_use_smartsign_us = 1
<
    or
>
    let g:EasyMotion_use_smartsign_jp = 1
<

Default: 0

This saves a chording Shift, and is super-welcome for my tired, tired fingers. (More importantly, it's deeply burned into my muscle-memory from most-of-a-decade of EasyMotion use. :P)

ELLIOTTCABLE avatar Sep 20 '21 16:09 ELLIOTTCABLE

I’m not sure how I feel about that. I think the feature is easy to implement:

  • For jump targets with a pattern (HopChar{1,2}*, HopPattern*, etc.), we have a look at opts.smartsign_mappings or a similar name.
  • If it’s ~= nil, break the input list into individual search characters.
  • For each character, look them up in the mapping. If the mapping returns nothing, leave the character in the list and tries the next one.
  • If a character does look up, replace the character by a list of OR’ed pattern expressions (including the character itself). For instance, if we have '1' = { '!', 'l', '|' }, it will basically replace 1 with (1|!|l|\|).

That implementation might be slow with the regex, but unless we completely change the way we pattern match (which is also another possible solution; i.e. by_smart_regex.

hadronized avatar Jun 21 '22 10:06 hadronized