xiaoqiang

xiaoqiang

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

Showing Posts 66 to 57

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.

paulsullivanjr

paulsullivanjr

Curious how many have converted from neovim to helix. I mess with helix some here and there but haven’t taken the dive to using it full time. Has the lack of a plugin system been an issue? I heard one may arrive someday but I don’t really keep up with that part of it.

joelpaulkoch

joelpaulkoch

I had issues with the LS formatter too and switched to a similar config
formatter = { command = "mix" , args = ["format", "-"] which works but doesn’t respect the formatter plugins.

The problem is that helix is executing this command in the directory of the file you’re working on. In the latest version of helix you can use expansions, so I’ve tried
formatter = { command = "mix" , args = ["format", "--dot-formatter", "%{pwd}/.formatter.exs", "-"]
which finds the .formatter.exs file but can’t find the mix dependencies.

So you would want something like formatter = { command = "cd %{pwd}; mix format -"
but I think it doesn’t work this way.

As a sidenote on helix master there is a %{workspace_directory} expansion which would be more appropriate I guess.

nulltree

nulltree

Ah interesting - I did to no avail in the past but probably didn’t give it sufficient time to properly recompile.
After waiting some minutes, it indeed appears fixed, thank you very much!

frankdugan3

frankdugan3

ElixirLS shouldn’t conflict (I use it). I have had it happen several times, and usually it’s because ElixirLS got stuck on compilation. Sometimes it happens after dep upgrades, other times certain compiler errors. Have you tried nuking the .elixir_ls folder and restarting the LSP? After it finishes recompiling, it should play nice.

nulltree

nulltree

Thank you - unfortunately, that one is set already :grimacing:

Setting the formatter as either

  • formatter = { command = "mix format" , args = ["--stdin"] } or
  • formatter = { command = "mix format" }
    also doesn’t work - I assume it might has to do with elixir-ls somehow.
frankdugan3

frankdugan3

For Spark DSL’s (Ash, etc.) specifically, the Spark formatter can be configured to remove parenthesis on format: Spark.Formatter — spark v2.7.2

nulltree

nulltree

Does/Did anyone else have problems with the formatter applying parentheses to DSLs (Ecto, Ash, …) using helix (and elixir-ls) - and/or ideas on how to resolve this?

Example:

postgres do
    table "tracks"
    repo Tunez.Repo
  end

turns to

postgres do
    table("tracks")
    repo(Tunez.Repo)
  end

Happens for both auto-format or using the helix’s :format cmd.
The formatter.ex is (presumably) correctly set up and respected by other editors where this doesn’t happen.

For completeness’ sake, my language config:

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

[language-server.elixir-ls]
command = "elixir-ls"
config = { elixirLS.dialyzerEnabled = true }

Other info (but happens for years, so no recent incompatibility)

  • macOS 15.5
  • helix main-branch
  • Elixir 18.4/OTP 28
  • elixir-ls 0.28.1
frigidcode

frigidcode

I removed the helix install which was done using asdf and downloaded the pre-built binary from GH. Now tree-sitter highlighting works, I haven’t tested the elixir lsp yet.

frigidcode

frigidcode

Nadda, I tried your config earlier and no dice. I installed and build the grammars but nothing yet.

[[language]]
name = "elixir"
language-id = "elixir"
language-servers = [ "elixir-ls" ]
auto-format = true
➜  git:(main) ✗ hx --health elixir
Configured language servers:
  ✓ elixir-ls: /home/xxxx/.local/bin/elixir-ls/elixir-ls
Configured debug adapter: None
Configured formatter: None
Highlight queries: ✘
Textobject queries: ✘
Indent queries: ✘

Where Next? Top

Trending in Dev Env & Tools Top

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews