EasterPeanut

EasterPeanut

Why do my .heex files not get formatted with elixir-ls (and .ex/.exs files do)?

Environment

  • Elixir 1.14.1 and Erlang 25.1.1
  • elixir-ls 0.13.0 installed through Homebrew
  • Neovim 0.8.3 on MacOS
  • Native Neovim LSP

Neovim init.lua:

local path = vim.fs.find({ 'mix.exs', 'mix.lock', '.gitignore' })
vim.lsp.start({
  name = 'elixirls',
  cmd = { '/opt/homebrew/bin/elixir-ls' },
  root_dir = vim.fs.dirname(path[1]),
  settings = {},
})

-- autoformat on save
vim.api.nvim_create_autocmd('BufWritePost', {
  pattern = { '*.ex,*.exs,*.heex' },
  buffer = buffer,
  callback = function()
    vim.lsp.buf.format { async = true }
  end
})

formatter.exs:

If I run mix format on my .heex files it works so my formatter file should be fine, but for completeness:

[
  import_deps: [:phoenix],
  plugins: [Phoenix.LiveView.HTMLFormatter],
  inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}"]
]

I have setup native LSP in Neovim, installed elixir-ls 0.13.0 and I got auto formatting and format on save working for .ex/.exs files. But somehow it won’t work for .heex files. Afaik elixir-ls v0.11 should start support .heex files too, and I’m on v0.13 (installed through Homebrew, not sure if it that’s relevant to the issue).

Neovim tells me: [LSP] Format request failed, no matching language servers.

Does the version of elixir-ls I have installed not support .heex files or am I missing something?

Thanks in advance!

First Post!

EasterPeanut

EasterPeanut

Fixed it, my mistake was I had the current LSP setup placed in /nvim/ftplugin/elixir.lua and I needed another ftplugin for eelixir.lua

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
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
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
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
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New

We're in Beta

About us Mission Statement