Closed zolrath closed 1 year ago
You'll need to use nvim-treesitter for highlighting. TSInstall eex
In my original lazy.vim config I have:
-- add elixir to treesitter
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed, { "elixir", "eex" })
end,
}
which ensures that both eex and elixir are installed.
After adding that back I can confirm that a fresh install will have leex highlighting!
Sounds good!
The heex rendering definitely has an advantage in that the HTML is properly highlighted as well.
I seem to remember having html highlighting with leex, was that just prior to treesitter or does your leex look like the heex example?
That was prior to treesitter.
leex and eex highlighting as provided by vim-elixir is "html with elixir inside the <% %>", whereas eex with treesitter is just "elixir inside the <% %>".
this is currently a treesitter/nvim-treesitter limitation. ERB from ruby has the same drawback.
It's because eex is not HTML specific, you can use it with any plaintext document.
a lot of people change the filetype detection of html.eex and html.leex templates to use the heex parser, even tho it might technically be wrong sometimes (like when you put the embedded elixir inside an opening tag <div class="<%= @class %>"></div>
I personally have only used heex and surface at work recently, and when i've used eex within my open source, it has been *.ex.eex
templates.
Thought that might be the case, thanks for the detail!
Hopefully there's some movement on that issue someday, interesting to see work being done on compatible grammars like https://github.com/rockerBOO/tree-sitter-html-eex/ if treesitter itself doesn't end up supporting embedded templates.
Hello! After replacing my custom Elixir setup using lazy.vim with the instructions in the readme of this repo, I do not have syntax highlighting for the "eelixir" filetype.
ft=eelixir
ft=heex
Co-located in a LiveView