Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom callback feels clunky #73

Open
NickCondron opened this issue May 10, 2024 · 0 comments
Open

Custom callback feels clunky #73

NickCondron opened this issue May 10, 2024 · 0 comments

Comments

@NickCondron
Copy link

I found out about the custom callback feature, so I decided to implement my first one in my neovim config. This simply extends the HopLineStart to immediately enter insert mode on a new line:

local hop = require("hop")
hop.setup({})

local hop_insert_line = function()
    local regex = require("hop.jump_regex").regex_by_line_start_skip_whitespace()
    local target = require("hop.jump_target").jump_target_generator(regex)
    hop.hint_with_callback(target, hop.opts, function(jt)
        hop.move_cursor_to(jt, hop.opts)
        -- v this the critical line
        vim.api.nvim_input("o")
    end)
end

vim.keymap.set("n", "go", hop_insert_line)

I feel this is a lot of boilerplate for a single lua command callback to a single default target. Is there an easier way to implement this? If not, could the default targets accept a callback as an optional parameter?

The help documentation is excellent, but it is lacking an example that would have likely saved me some time. Would adding my example to the wiki, hop.txt, or examples make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant