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 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.

  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”}

cloudytoday

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

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

Where Next?

Popular in Dev Env & Tools Top

AstonJ
While on the theme of routers: Is your computer's internet connection wired or wireless? (Poll) Which router do you use? How do you se...
New
aziz
I’m happy to finally present to you the best Sublime Text package for Elixir, templates and more! :partying_face: :confetti_ball: Elixi...
New
JoeZMar
After the keyboard thread has convinced me to purchase a UHK I wanted to make one about the mouse. Switching to a programmable keyboard h...
New
AstonJ
Inspired by @jdiago’s post containing this slide: I thought it would be interesting discussing what independent languages like Elixir...
#ai
New
kayoj
Hello I have been testing different environments for Elixir development & noticed something odd. When I run the Elixir formatter loc...
#ai
New
borag
I shared an Elixir Architect skill for Claude Code which proves that Elixir is the best LLM friendly language (@josevalim ) https://git...
New
AstonJ
Following on from this post in Do you use LittleSnitch or the equivalent on your OS? I think it might be worth us creating this thread so...
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
evnp
How do you all feel about the use of AI tools for building Elixir/Phoenix projects, with respect to these topics? Longform context below....
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

Other popular topics Top

yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New

We're in Beta

About us Mission Statement