Elevate your CLI experience: Helix (upd.)

Posted Jan 04, 2024. Updated Jan 07, 2024  ‐  2 min read

A post-modern text editor

It's a joke from Helix website. I'm looking for a lightweight text editor. I'll use it for editing configuration files and simple code changes. If you are looking for such editor, then Helix may be for you. Later, I'll try to replace VSCode with it.

Installation

There are many options how to install Helix. There are pre-build binaries and packages for many operating systems. Unfortunatelly, my prefered way of installing software (cargo install) is not available. Because of that I'll install Helix from it's git repository.

git clone https://github.com/helix-editor/helix.git
cd helix/
git checkout 23.10
cargo install --path helix-term --locked

If you will notice a build error related to tree-sitter-gemini, you need to edit languages.toml and remove lines related to gemini.

We can install tree-sitter grammars now.

hx --grammar fetch
hx --grammar build
cp --recursive runtime/queries/ ~/.config/helix/runtime/
cp --recursive runtime/themes/ ~/.config/helix/runtime/
cp runtime/tutor ~/.config/helix/runtime/
Basic usage

If you never used vi like editor before, it is good to start with tutorial and read usage documentation.

Let's run tutorial.

hx

Here is what you should see on the screen.

Helix

Make sure that you are in NOR (normal) mode by pressing ESC. Now you can press : and type "tutor" and press Enter. Congrats, you are in Helix tutorial ;)

Now you can configure Helix as default editor.

$env.EDITOR = 'hx'
config env

Now add $env.EDITOR = 'hx' at the end of config file.

Configuration (2024-01-07)

Creating a good theme for a text editor used for coding is not an easy task. Everyone has their preferences. I'll improve my theme daily, but I need a starting point. I decided to use base16_default_dark.toml as the base theme.

cp ~/.config/helix/runtime/themes/base16_default_dark.toml ~/.config/helix/runtime/themes/practicalrs.toml

Changing editor theme requires a ~/.config/helix/config.toml file. Inside this file we need to have a theme configuration.

theme = "practicalrs"

[editor]
true-color = true

We need to edit theme ~/.config/helix/runtime/themes/practicalrs.toml file. Here is a palette that I'm using.

[palette]
base00 = "#040404" # Default Background
base01 = "#100f0f" # Lighter Background (Used for status bars, line number and folding marks)
base02 = "#d4d9cc" # Selection Background
base03 = "#45a52d" # Comments, Invisibles, Line Highlighting
base04 = "#bc7800" # Dark Foreground (Used for status bars)
base05 = "#cb910e" # Default Foreground, Caret, Delimiters, Operators
base06 = "#e8e8e8" # Light Foreground (Not often used)
base07 = "#f8f8f8" # Light Background (Not often used)
base08 = "#3b96bf" # Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted
base09 = "#3b96bf" # Integers, Boolean, Constants, XML Attributes, Markup Link Url
base0A = "#3b96bf" # Classes, Markup Bold, Search Text Background
base0B = "#dc4025" # Strings, Inherited Class, Markup Code, Diff Inserted
base0C = "#c02310" # Support, Regular Expressions, Escape Characters, Markup Quotes
base0D = "#0e4a8a" # Functions, Methods, Attribute IDs, Headings
base0E = "#0e4a8a" # Keywords, Storage, Selector, Markup Italic, Diff Changed
base0F = "#a16946" # Deprecated, Opening/Closing Embedded Language Tags, e.g. <?php ?>

Here is how Helix looks like after applying this theme.

Helix

You can find my Helix config files in prs-configs repository.

Let's end this article here. LSP for Rust and editor configuration is a topic for another one.

Tools usage disclosure. I'm not a native English speaker. I use the following tools to improve my wording: Google Translate, Grammarly, and Hemingway Editor. These tools use artificial intelligence. I use them only to improve my writing, not to generate content.