1 +#
relative-motions.yazi 3 +A [Yazi](https://github.com/sxyazi/yazi) plugin based about vim motions.
5 +https://github.com/dedukun/relative-motions.yazi/assets/25795432/04fb186a-5efe-442d-8d7b-2dccb6eee408
9 +- [Yazi](https://github.com/sxyazi/yazi) v0.3.0+
14 +ya pack -a dedukun/relative-motions
19 +If you want to use the numbers directly to start a motion add this to your `keymap.toml`:
24 +[[manager.prepend_keymap]]
26 +run = "plugin relative-motions --args=1"
27 +desc = "Move in relative steps"
29 +[[manager.prepend_keymap]]
31 +run = "plugin relative-motions --args=2"
32 +desc = "Move in relative steps"
34 +[[manager.prepend_keymap]]
36 +run = "plugin relative-motions --args=3"
37 +desc = "Move in relative steps"
39 +[[manager.prepend_keymap]]
41 +run = "plugin relative-motions --args=4"
42 +desc = "Move in relative steps"
44 +[[manager.prepend_keymap]]
46 +run = "plugin relative-motions --args=5"
47 +desc = "Move in relative steps"
49 +[[manager.prepend_keymap]]
51 +run = "plugin relative-motions --args=6"
52 +desc = "Move in relative steps"
54 +[[manager.prepend_keymap]]
56 +run = "plugin relative-motions --args=7"
57 +desc = "Move in relative steps"
59 +[[manager.prepend_keymap]]
61 +run = "plugin relative-motions --args=8"
62 +desc = "Move in relative steps"
64 +[[manager.prepend_keymap]]
66 +run = "plugin relative-motions --args=9"
67 +desc = "Move in relative steps"
72 +Alternatively you can use a key to trigger a new motion without any initial value, for that add the following in `keymap.toml`:
75 +[[manager.prepend_keymap]]
77 +run = "plugin relative-motions"
78 +desc = "Trigger a new relative motion"
83 +Additionally there are a couple of initial configurations that can be given to the plugin's `setup` function:
85 +| Configuration | Values | Default | Description |
86 +| -------------- | ----------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
87 +| `show_numbers` | `relative`, `absolute`, `relative_absolute` or `none` | `none` | Shows relative or absolute numbers before the file icon |
88 +| `show_motion` | `true` or `false` | `false` | Shows current motion in Status bar |
89 +| `only_motions` | `true` or `false` | `false` | If true, only the motion movements will be enabled, i.e., the commands for delete, cut, yank and visual selection will be disabled |
91 +If you want, for example, to enable relative numbers as well as to show the motion in the status bar,
92 +add the following to Yazi's `init.lua`, i.e. `~/.config/yazi/init.lua`:
95 +-- ~/.config/yazi/init.lua
96 +require("relative-motions"):setup({ show_numbers="relative", show_motion = true })
100 +> The `show_numbers` and `show_motion` functionalities overwrite [`Current:render`](https://github.com/sxyazi/yazi/blob/ec33085f672e52adb934503d78703b8dd70621a8/yazi-plugin/preset/components/current.lua#L26)
101 +> and [`Status:children_render`](https://github.com/sxyazi/yazi/blob/ec33085f672e52adb934503d78703b8dd70621a8/yazi-plugin/preset/components/status.lua#L173) respectively.
102 +> If you have custom implementations for any of this functions
103 +> you can add the provided `Entity:number` and `Status:motion` to your implementations, just check [here](https://github.com/dedukun/relative-motions.yazi/blob/main/init.lua#L126) how we are doing things.
107 +This plugin adds the some basic vim motions like `3k`, `12j`, `10gg`, etc.
108 +The following table show all the available motions:
110 +| Command | Description |
111 +| -------------- | ------------------- |
112 +| `j`/`<Down>` | Move `n` lines down |
113 +| `k`/`<Up>` | Move `n` lines up |
114 +| `gj`/`g<Down>` | Go `n` lines down |
115 +| `gk`/`g<Up>` | Go `n` lines up |
116 +| `gg` | Go to line |
118 +Furthermore, the following operations were also added:
120 +| Command | Description |
121 +| ------- | ------------- |
122 +| `v` | visual select |
125 +| `d` | Delete motion |
127 +This however must be followed by a direction, which can be `j`/`<Down>`, `k`/`<Up>` or repeating the command key,
128 +which will operate from the cursor down, e.g. `2yy` will copy two files.
130 +Finally, we also support some tab operations:
132 +| Command | Description |
133 +| ------- | ------------------------------------ |
134 +| `t` | create `n` tabs |
135 +| `H` | Move `n` tabs left |
136 +| `L` | Move `n` tabs right |
137 +| `gt` | Go to the `n` tab |
138 +| `w` | Close tab `n` |
139 +| `W` | Close `n` tabs right |
140 +| `<` | Swap current tab with `n` tabs left |
141 +| `>` | Swap current tab with `n` tabs right |
142 +| `~` | Swap current tab with tab `n` |