1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-23 10:51:33 +08:00
SpaceVim/bundle/hop.nvim/examples/hop-extension-hello-world/lua/hop-extension-hello-world/init.lua
2022-04-27 22:13:32 +08:00

33 lines
834 B
Lua
Vendored

local M = {}
M.opts = {}
function M.hint_around_cursor(opts)
-- the jump target generator; we are simply going to retreive the cursor position and hint around it as an example
local jump_targets = function() -- opts ignored
local cursor_pos = require'hop.window'.get_window_context().cursor_pos
local line = cursor_pos[1] - 1
local col = cursor_pos[2] + 1
local jump_targets = {}
-- left
if col > 0 then
jump_targets[#jump_targets + 1] = { line = line, column = col - 1, window = 0 }
end
-- right
jump_targets[#jump_targets + 1] = { line = line, column = col + 1, window = 0 }
return { jump_targets = jump_targets }
end
require'hop'.hint_with(jump_targets, opts)
end
function M.register(opts)
vim.notify('registering the nice extension', 0)
M.opts = opts
end
return M