Skip to content

shybovycha/flash.hx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 

Repository files navigation

flash.hx

This is a Helix plugin similar to flash.nvim and leap.nvim.

This plugin uses single-letter jump labels, unlike the default behaviour of goto_word (g w) which uses two-letter labels.

output.webm

Installation

Prerequisites

First you need to obtain a fork of Helix with a working draft of a plugin system by cloning and building the corresponding branch. Note that you might have to enable a steel feature in helix-term/Cargo.toml file:

--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -31,7 +31,7 @@ assets = [
 ]

 [features]
-default = ["git"] # Add steel here for development
+default = ["git", "steel"] # Add steel here for development
 unicode-lines = ["helix-core/unicode-lines", "helix-view/unicode-lines"]
 integration = ["helix-event/integration_test"]
 git = ["helix-vcs/git"]

Then you will be able to use the Scheme / Steel configuration files in ~/.config/helix/ directory.

Installing this plugin

You need to copy the flash.scm file from this repo to the ~/.config/helix/ directory add the following code to the init.scm file:

(require "flash.scm")

Upon reloading Helix (the one built from the plugin system branch), you will be able to use :flash, :flash-forward and :flash-backward commands.

  • :flash - performs search on the entire screen
  • :flash-forward - performs search starting from the current cursor (or just the first one if there are multiple) downwards
  • :flash-backward - performs search from the top of the screen to the current cursor (or the first one if there are multiple)

The above three commands will move the cursor in normal mode and extend selection in selection mode. There are also overrides to only extend selection:

  • :flash-extend - performs search on the entire screen and extends selection to the jump label
  • :flash-extend-forward - performs search starting from the first cursor downwards and extends selection to the jump label
  • :flash-extend-backward - performs search starting from the first cursor upwards and extends selection to the jump label

But it is much more handy if you register keyboard shortcuts in the init.scm:

(keymap
  (global)
  (normal
    (g
      (/ ":flash-forward")
      (? ":flash-backward")))
  (select
    (g
      (/ ":flash-forward")
      (? ":flash-backward"))))

Then you can access the functionality using g / and g ?.

My personal preference is to set just one keybinding to search and jump on the entire screen with g /:

(keymap
  (global)
  (normal
    (g
      (/ ":flash"))))

Configuration

The list of labels could be configured using the existing jump-label-alphabet config option under the [editor] section in the ~/.config/helix/config.toml file.

This plugin supports two matching modes - when the jump label is placed at the end of the match and when it is placed at the start of the match, meaning jump would happen to either the beginning of the match or the end of the match, correspondingly.

This behaviour can be configured by either issuing a command :flash-set-jump-to [start|end] or by using the (flash-config 'jump-to 'start) or (flash-config 'jump-to 'end) helpers in the init.scm file.

Known limitations

Currently, there are quite a few limitations in this plugin, most of them due to a work-in-progress nature of the plugin system:

  • there might be bugs and glitches (the implementation is rather convoluted due to many other limitations of the plugin system, the Steel language and my skill with both)
  • the plugin might handle soft-wraps very poorly

About

Helix plugin to jump around like with flash.nvim

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published