Are there any plugins/configuration settings that provide syntax highlighting/formatting for eex/heex templates in Neovim? I am trying to setup Neovim for Elixir dev and this seems to be the missing part yet.
I am using Treesitter with the elixir
and heex
plugins installed.
require("nvim-treesitter.configs").setup(
{
ensure_installed = {
"eex",
"elixir",
"erlang",
"heex",
"html",
"surface",
...
},
...
highlight = {enable = true},
}
I have syntax highlighting working, but the formatting does not seem to work inside a ~H sigal or .heex file. Any other config I could be missing?
I use my LSP to do formatting (I do this on_attach
):
local opts = {buffer = 0}
vim.keymap.set("n", "<Leader>f", vim.lsp.buf.formatting, opts)
I prefer to trigger formatting myself rather then on save. Another thing to check for is to make sure you update your elixirls to the latest
Yes, I am running 0.11 version of elixir ls. I can format elixir code use key and also format on write. Either of these work with Elixir code, but do not format .heex files or code inside ~H. I am also running Elixir 1.14.1.
In your setup, does it format HEEX?
You have to configure the formatter:
https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.HTMLFormatter.html#module-setup
That was it. Not set to format heex templates. Thanks
Did you also get html syntax highlighting in eex/heex files ?
Something like mention in the Expected section of this github issue
I am using neovim/lunarvim and all is working fine. Only nit I have is it takes a couple of seconds to clear warnings/errors in the editor. So you can fix an issue and after a few the error notification clears. Wish it was more instantaneous.