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

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
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
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
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
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
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 49084 226
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40042 209
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement