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

Add option to jump to file from :peek #1

Open
mahulst opened this issue Oct 2, 2024 · 0 comments
Open

Add option to jump to file from :peek #1

mahulst opened this issue Oct 2, 2024 · 0 comments

Comments

@mahulst
Copy link

mahulst commented Oct 2, 2024

I added a bunch of things to my local kak files for this plugin. It's similar to how cargo.kak jumps to files from cargo errors.
I add the line set-option buffer filetype harpoon to set the file type in the :peek command.

# Add and remove hooks to pressing enter
hook global WinSetOption filetype=harpoon %{
    map -docstring "Jump to position" buffer normal <ret> %{: harpoon-jump<ret>}
}
hook global WinSetOption filetype=(?!harpoon).* %{
    unmap buffer normal <ret> %{: harpoon-jump<ret>}
}

declare-option -docstring "regex describing file paths and line numbers" \
    regex \
    harpoon_file_pattern \
    "/(\w|\.|/)+:\d+:\d+"

# jump to file where the cursor is
define-command harpoon-jump %{

    evaluate-commands -save-regs fl %{

        execute-keys -draft "g" "h" "/" %opt{harpoon_file_pattern} <ret> "<a-;>" ";T:" '"fy' 'llT:"ly'

	harpoon-line-column %reg{f} %reg{l}
    }
}
# helper
define-command harpoon-line-column -params 2 %{
    evaluate-commands -try-client %opt{jumpclient} %{
        edit -existing "%arg{1}" "%arg{2}" 

        try %{ focus }
    }
} -docstring "Like edit but understands file:line:col parameters"
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