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-lsis installed and in your path. On macOS, you can usebrew 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
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
I’ve figured out a great trick, to be able to run mix test with filename and line numbers as longs a Add command expansions %key{body} by ksdrar · Pull Request #6979 · helix-editor/helix · GitHub is not merged yet.
I’m using zellij, wezterm and helix of course.
- 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.
- 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
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”}
cloudytoday
Yep, it’s awesome. I’m also using a not yet merged PR which adds a file tree to it, it’s stable and I had no issues with it for a month or so.
fceruti
I once took a class on Korean and the teacher said we were lucky in Spanish because we could start saying to the waitress
I want aaaaaa
And then, after thinking about it, say “coke”. The needed (I guess they still do), start with the subject.
That’s something I think helix got right. Start with the subject, you can visualize it, and then perform the action.
da” is an act of faith in vim, but once you truly believe in it, you can see the light







