Helix editor for Elixir Development

Hey Helix users :slight_smile: I am trying Helix, but I miss shortcuts to run the tests for one of these:

  • the line my cursor is currently on (mix test path/to/the/file.exs:line_number)
  • the file I have currently open and active (mix test path/to/file.exs)
  • everything (mix test)

Do you have an idea if this is even possible in Helix?

1 Like

It looks like it could be done with an approach like this: Helix and tmux integration - DEV Community

Are you guys enjoying Helix?

To me, it served me as a stepping stone into neovim.

Having total control of your IDE is amazing. There’s nothing in particular that would make someone jump from vscode, but it’s just the volume of tiny optimizations that makes it awesome.

I’ve actually switched over from neovim. I like the movement patterns better and not having to have to configure everything is great as well.
I’m using it in combination with https://zellij.dev/ and use similar things like that for testing.

For elixir most things work great. The only issue is that I haven’t got the tailwind integration with elixir working.

1 Like

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

2 Likes

Did anyone figured out how to configure Helix to run ElixirLS debug adapter? Helix added support and looking at Helix editor for Elixir Development - #32 by darnahsan hx --health checks if DAP is working

1 Like

Hi, have you got it working with tailwind ? If yes, could you share the config. thanks in advance

Not yet. I haven’t really looked further to it. I think the best way to debug would be to compare what other editors send to the tailwind lap and see what the difference is.

1 Like

There is a solution that works :tada:

you can find the discussion here:

[language-server.tailwind-heex]
command = "tailwindcss-language-server"
args = ["--stdio"]

[[language]]
name = "elixir"
language-id = "phoenix-heex"
language-servers = ["tailwind-heex", "elixir-ls"]
auto-format = true

[[language]]
name = "heex"
language-id = "phoenix-heex"
language-servers = ["tailwind-heex", "elixir-ls"]
auto-format = true
2 Likes

Has anyone got do…end completion working in Helix?

I can see there’s an issue related to indentation in the Issues tracker that would suggest this is working, but I can’t get it to action. I’ve updated elixir-ls, checked snippets is set to true, and updated hx.

edit: fixed, I was not being patient enough for the snippet prompt. Spoilt by VS Code for the simple return after the do keyword, but persisting with hx as the feel/speed in general is excellent.

I also added vscode-html-language-server in order to get html code completions:

[language-server.tailwind-heex]
command = "tailwindcss-language-server"
args = ["--stdio"]

[[language]]
name = "elixir"
language-id = "phoenix-heex"
language-servers = ["tailwind-heex", "elixir-ls", "vscode-html-language-server"]
auto-format = true

[[language]]
name = "heex"
language-id= "phoenix-heex"
language-servers = ["tailwind-heex", "elixir-ls", "vscode-html-language-server"]
comment-token = "<%!--"
auto-format = true

But there is one problem with this: the symbol picker shows not only elixir symbols but also arbitrary html symbols which makes it hard to work with. So I’ll probably remove it again.

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.

5 Likes

All seems good, but how do we git the dap to work?

$ hx --health elixir
Configured language server: elixir-ls
Binary for language server: /run/current-system/sw/bin/elixir-ls
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✓
Indent queries: ✓