hadronized / hop.nvim

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

FR: multiple hint positions #342

Open SephVelut opened 1 year ago

SephVelut commented 1 year ago

Could we add the option to set hint_position to a table of values (e.g. BEGIN, END, MIDDLE)? I have two mappings that hop somewhere on the current line. One for BEGIN hint_position and the other for END. I would like to rely on only one mapping, with both BEGIN and END matches highlighted.

Probably the only critical change would need to be something like

-- lua/hop/jump_target.lua

-- mark_jump_targets_line()
-- ....
for _, v in pairs(hint_position) do
        local colp = col + b
        if v == hint.HintPosition.MIDDLE then
          colp = col + math.floor((b + e) / 2)
        elseif v == hint.HintPosition.END then
          colp = col + e - 1
        end
        jump_targets[#jump_targets + 1] = {
          line = line_context.line_nr,
          column = math.max(1, colp + col_offset + col_bias),
          length = math.max(0, matched_length),
          buffer = buf_handle,
          window = win_handle,
        }
end
-- ...

Ideally, Hop could have 'multiple highlighting' as a general concept, instead of hacking each individual highlight feature to include an option for multiple combinations.