doomemacs icon indicating copy to clipboard operation
doomemacs copied to clipboard

Support for Elixir's ~H sigil and HEEX files

Open sezaru opened this issue 2 years ago • 4 comments

I confirm that...

  • [X] I have searched the issue tracker, documentation, FAQ, Discourse, and Google, in case this issue has already been reported/resolved.

  • [X] I have read "How to Debug Issues", and will use it to provide as much information about this issue as possible.

  • [X] The issue can be reproduced on the latest available commit of Doom.

  • [X] The issue can be reproduced on a stable release of Emacs, such as 27, 28, or 29. (Unstable versions end in .50, .60, or .9x)

Expected behavior

In Elixir, you can create HEEX files or embed it directly in elixir code using the H sigil.

In both cases Doom should have correct syntax highlight and indentation.

Current behavior

If we open an HEEX file (eg. my_file.html.heex), Doom will use web-mode and will not understand the elixir bits of it.

For example, we can see that the syntax highlight is broken in this image:

image

If we are using the H sigil, doom will just parse it as a simple string instead of actually heex code:

image

I noticed that in doom list of tree sitter support, it has heex there, and it did create a .so in my machine for it, it is just never used at all.

Also, we now have https://github.com/wkirschbaum/elixir-ts-mode and https://github.com/wkirschbaum/heex-ts-mode modes which supports the above feature, maybe we should replace the current elixir-mode config with one that uses these new modes?

Steps to reproduce

  1. Have Doom with (elixir +tree-sitter), (erlang +tree-sitter) and (web +tree-sitter) enabled.
  2. Open emacs
  3. Open an elixir file that uses a H sigil or a HEEX file

System Information

https://pastebin.com/7QKuhXhE

sezaru avatar Dec 20 '23 00:12 sezaru

Dooms elixir module is currently not using any of the tree sitter modes, it's pretty easy however to copy the elixir module into your own private config and replace the elixir-mode with elixir-ts-mode. I haven't worked on submitting this upstream yet as it would have to deal with emacs 28 which doesn't have built in tree sitter.

John-Goff avatar Dec 20 '23 17:12 John-Goff

Dooms elixir module is currently not using any of the tree sitter modes, it's pretty easy however to copy the elixir module into your own private config and replace the elixir-mode with elixir-ts-mode. I haven't worked on submitting this upstream yet as it would have to deal with emacs 28 which doesn't have built in tree sitter.

For an example OP could look at: https://github.com/cullan/doom-elixir-ts

zetashift avatar Dec 21 '23 22:12 zetashift

I found the same problem. Is there any update on this?

Rope-a-dope avatar Nov 14 '24 05:11 Rope-a-dope

Syntax highlighting works for me with this config in Emacs 30:

(use-package
  emacs
  :ensure nil
  :custom
  (treesit-language-source-alist
   '((heex "https://github.com/phoenixframework/tree-sitter-heex")
     (elixir "https://github.com/elixir-lang/tree-sitter-elixir")))

  (major-mode-remap-alist
   '((elixir-mode . elixir-ts-mode)))
  )

However the other way around - Elixir syntax in .heex files does not.

katafrakt avatar Feb 17 '25 23:02 katafrakt

As of https://github.com/doomemacs/doomemacs/commit/5cda3ed25a55b1492bf864a1fe8b7daaf655bbfa, Doom now uses treesit, and with that (and 0c311a517250262425fafd62d162c0683434c252) comes elixir and heex support, so I'll consider this resolved. If that's not the case, let me know and I'll reopen this. Thanks for bringing it to my attention, in any case!

hlissner avatar Aug 31 '25 13:08 hlissner