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!

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