Crates.io | hop-kak |
lib.rs | hop-kak |
version | 0.2.0 |
source | src |
created_at | 2023-12-14 17:26:14.307955 |
updated_at | 2023-12-14 22:58:26.76652 |
description | Hinting binary for Kakoune |
homepage | |
repository | https://github.com/phaazon/hop.kak |
max_upload_size | |
id | 1069764 |
size | 32,456 |
Table of content:
This binary is intended to be used with the Kakoune editor, and provides hinting capabilities based on the current selections of the user. The workflow is simple:
%sh{}
block — via $kak_selections_desc
, typically.<esc>
key.Currently, the only installation channel is https://crates.io. It requires cargo
to be installed.
cargo install hop-kak
You must include the hop.kak file before trying to use Hop. It contains:
hop_ranges
option. Used to highlight your buffer with the labels.hop_label
face definition. Feel free to override the default.Another approach is to use hop-kak --init
inside your kakrc
to automatically inject the of the hop.kak
file:
evaluate-commands %sh{ hop-kak --init }
--init
is only available ifhop-kak
is compiled with theinit
features, which is enabled by default.
hop-kak
optionshop-kak
— the built binary — doesn’t have any configuration file. Instead, it is configured by passing CLI arguments:
-k --keyset
: the keyset to use. This depends on your keyboard layout. Choose it wisely! It must not have any
duplicate key, and keys are ordered by importance; i.e. the keys that are easier to reach should appear first.
TODO
.TODO
.etisura,cnovpdélxqygàhfbjz
.-s --sels
: selections to hint. You should always pass $kak_selections_desc
here.-l --labels
: previous generated labels. You should never need to use that argument.-z --key
: key for reduction. You should never need to use that argument.--handle
: which part of a selection to put the cursor on; the anchor, or the cursor. Default to the anchor.The binary was made with few responsibilities, so that people can use it in a wider variety of situations. For this
reason, you will have to build a bit around hop-kak
. hop-kak
works by reading selections in, highlighting them and
making Kakoune wait for a key press to either abort, or reduce the hints. If you decide to reduce the hints, hop-kak
will filter your selections and reduce them to map the new set of hints. Hence, hop-kak
can basically be seen as a
trie reducer for Kakoune selections. It is then very composable. You pass it initial selections, and it interactively
filters them.
Whatever your selections, you will always want to start a hopping session with the following command:
eval -no-hooks -- %sh{ hop-kak --keyset "<YOUR_KEYSET_HERE>" --sels "$kak_selections_desc" }
For instance, with the bépo keyboard layout, you could map the è
key to start hopping with your current selections:
map global normal è ':eval -no-hooks -- %sh{ hop-kak --keyset "etisura,cnovpdélxqygàhfbjz" --sels "$kak_selections_desc" }<ret>'
Then, it’s up to you to come up with your own workflow!
You should have an option to set your keyset if you intend on having several workflows. For instance, for bépo:
declare-option str hop_kak_keyset 'etisura,cnovpdélxqygàhfbjz'
Something that is pretty useful is to map a key to select the visible part of the buffer. <a-%>
is a good candidate,
as it’s not mapped by Kakoune for now:
map global normal <a-%> ':execute-keys gtGbx<ret>'
This will help with creating selections. We assume you have this binding below. You can also make a command for that:
define-command hop-kak %{
eval -no-hooks -- %sh{ hop-kak --keyset "$kak_opt_hop_kak_keyset" --sels "$kak_selections_desc" }
}
With the <a-%>
mapping, you can select words with <a-%>s\w+
, and then press your mapping to start hopping around.
A slightly better approach to reduce the number of keys and control keys to type is to create a small function like this:
define-command -override hop-kak-words %{
exec 'gtGbxs\w+<ret>:eval -no-hooks -- %sh{ hop-kak --keyset "$kak_opt_hop_kak_keyset" --sels "$kak_selections_desc" }<ret>'
}
And mapping it to your key; e.g. SPC è
:
map global user è :hop-kak-words<ret>