xiaoqiang

xiaoqiang

Helix editor for Elixir Development

These past few days, I’ve tried switching from Neovim to Helix, and so far the experience has been great. Compared to neovim, which requires multiple plugins and configurations, Helix requires very little configuration to start using it for Elixir. Plus, it has a great shortcut key prompts, so if you’ve used vim before, you can quickly get used to it.

In addition to its out-of-the-box features, one of my favorite features of Helix is its multi-selection editing!

Prerequisites:

  • Ensure that elixir-ls is installed and in your path. On macOS, you can use brew install elixir-ls.

Put the following configuration in .config/helix/languages.toml, and happy coding!

[[language]]
name = "elixir"
scope = "source.elixir"
injection-regex = "elixir"
file-types = ["ex", "exs"]
roots = ["mix.exs"]
auto-format = true
diagnostic-severity = "Hint"
comment-token = "#"
indent = {tab-width = 2, unit = " "}
language-server = {command = "elixir-ls"}

Most Liked

xiaoqiang

xiaoqiang

It is possible because their syntax highlighting uses tree-sitter.

Furthermore, I suggest updating the Elixir configuration to support specific features of the language server in heex. Additionally, I discovered that my understanding of the “injection-regex” configuration item was incorrect, and we may not require it.

[[language]]
name = "elixir"
scope = "source.elixir"
file-types = ["ex", "exs", "heex"]
roots = ["mix.exs"]
auto-format = true
diagnostic-severity = "Hint"
comment-token = "#"
indent = {tab-width = 2, unit = " "}
language-server = {command = "elixir-ls"}
tcoopman

tcoopman

I’ve figured out a great trick, to be able to run mix test with filename and line numbers as longs a https://github.com/helix-editor/helix/pull/6979 is not merged yet.

I’m using zellij, wezterm and helix of course.

  1. I use this script to parse the file and line number from the terminal:
        set -x

        status_line=$(wezterm cli get-text | rg -e "(?:NOR\s+|NORMAL|INS\s+|INSERT|SEL\s+|SELECT)\s+[\x{2800}-\x{28FF}]*\s+(\S*)\s[^│]* (\d+):*.*" -o --replace '$1 $2')
        filename=$(echo $status_line | awk '{ print $1}')
        line_number=$(echo $status_line | awk '{ print $2}')

        case "$1" in
          "file")
            mix test $filename
            ;;
          "line")
            mix test $filename:$line_number
            ;;
          "all")
            mix test
            ;;
        esac

Source: nix-hour/code/29/home.nix at dfe7bfde9dc117b3f2d583eb418f2376f141757a · tweag/nix-hour · GitHub

save it somewhere as executable.

  1. I add these key-bindings in helix:
[keys.normal."t"]
a = ":run-shell-command zellij run -d right -- helix-wezterm-script.sh all"
f = ":run-shell-command zellij run -d right -- helix-wezterm-script.sh file"
l = ":run-shell-command zellij run -d right -- helix-wezterm-script.sh line"

And now you can run tl in a test file and it will run the test on that line in split.

Hopefully this is useful to someone.

joges

joges

I noticed that the syntax highlighting for HEEX files was not correct with just adding “heex” to the file types but adding “html.heex” did the trick for me:

[[language]]
name = “elixir”
scope = “source.elixir”
injection-regex = “elixir”
file-types = [“ex”, “exs”, “html.heex”]
roots = [“mix.exs”]
auto-format = true
diagnostic-severity = “Hint”
comment-token = “#”
indent = {tab-width = 2, unit = " "}
language-server = {command = “elixir-ls”}

Last Post!

nulltree

nulltree

Depends on what plugins you’d miss, I guess. For me the biggest current paper cut t is it not automatically recognizing external file changes.

As to the plugin system’s release - it appears to be somewhat close, the creator recently remarked he primarily wants some more code reorganization to be willing to release it under a feature flag.

Where Next?

Popular in Dev Env & Tools Top

mkunikow
SpaceVim is a community-driven vim distribution that seeks to provide layer feature, especially for neovim. It offers a variety of layers...
New
Eiji
Here is my personal list: Real multi-thread support. Panel, sidebar or file tab should not freeze whole app and OS. Access to symbo...
New
pinksynth
Hey everybody. I was wondering if anybody here has used Panic’s Nova editor. It came out recently and I saw there was no Elixir Formatte...
New
dimitarvp
It would also be the reason for me to seriously hurt myself. :003: I’ve spent way too much time tinkering. I’ll be the first to agree th...
New
jswanner
I was about to reply to Why doesn’t Phoenix use Conventional Commit prefixes? - #41 by sodapopcan with some git aliases that I use for th...
New
PJUllrich
I built a devcontainer that makes it safe(-er) to run Claude Code in YOLO mode (--dangerously-skip-permissions) on Elixir&Phoenix pro...
New
bwlang
I want to buld this docker image but it fails with a timeout at RUN mix local.hex --force Maybe it’s just a maintenance window, but the...
New

Other popular topics Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement