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

Docs: hint_with_callback example

Open smackesey opened this issue 3 years ago • 2 comments

I tried for some time to get hint_with_callback to work and kept running into errors. From the docs, it was unclear to me which of these I was supposed to do-- I ended up trying them all until I got the working one. I suggest adding a simple example:

local hop, hopjt = require('hop'), require('hop.jump_target')
local cb = function (target) print(target.line) end

-- option (1) -- FAIL
hop.hint_with_callback(
  hopjt.jump_targets_by_scanning_lines,
  hopjt.regex_by_word_start(),
  cb
)

-- option (2) -- FAIL
hop.hint_with_callback(
  hopjt.jump_targets_by_scanning_lines,
  hopjt.regex_by_word_start,
  cb
)

-- option (3) -- FAIL
hop.hint_with_callback(
  hopjt.jump_targets_by_scanning_lines(hopjt.regex_by_word_start()),
  {},
  cb
)

-- option (4) -- FAIL
hop.hint_with_callback(
  hopjt.jump_targets_by_scanning_lines(hopjt.regex_by_word_start),
  {},
  cb
)

-- option (5) -- OK
hop.hint_with_callback(
  hopjt.jump_targets_by_scanning_lines(hopjt.regex_by_word_start),
  nil,
  cb
)

smackesey avatar Dec 11 '21 21:12 smackesey

What kind of errors do you get?

hadronized avatar Jun 21 '22 10:06 hadronized

This was months ago, so I don't recall, but I stand by my suggestion to provide an example along the lines of option (5).

smackesey avatar Jun 21 '22 13:06 smackesey