Install web-mode and mmm-mode first and put this in your config file:
(setq mmm-global-mode 'maybe)
(setq mmm-parse-when-idle 't)
(setq mmm-set-file-name-for-modes '(web-mode))
(custom-set-faces '(mmm-default-submode-face ((t (:background nil)))))
(let ((class 'elixir-eex)
(front "^[ ]+~L\"\"\"")
(back "^[ ]+\"\"\""))
(mmm-add-classes (list (list class :submode submode :front front :back back)))
(mmm-add-mode-ext-class 'elixir-mode nil class))
(define-advice web-mode-guess-engine-and-content-type (:around (f &rest r) guess-engine-by-extension)
(if (and buffer-file-name (equal "ex" (file-name-extension buffer-file-name)))
(progn (setq web-mode-content-type "html")
(setq web-mode-engine "elixir")
(apply f r)))
I was unable to get syntax highlighting to update when modifying the LiveView sigil so I put together a similar solution based on polymode (instead of mmm-mode).
Next version of Neovim (0.5.0) uses the tree-sitter parser for syntax highlighting. Does anyone know how to configure tree-sitter to syntax-highlight embedded sub-languages like leex and sub-sub languages like surface?
Before tree-sitter will be usable with Elixir someone will have to write a tree-sitter elixir grammar. I’m aware of a few attempts, but as far as I’m aware none of them are close to being usable.
Most recent semi-active projects:
Older stalled projects:
I too am very interested in having tree sitter grammars (and even took a very short stab at writing one). Overall I like tree-sitter’s approach over a large number of brittle regular expressions.
FYI, I am taking a stab at the grammar as well. GitHub - ananthakumaran/tree-sitter-elixir
I havent’ been able to get this to work after several days of effort. I am able to see the mode indicator change, but the syntax highlighting in the ~L buffer, just won’t adjust. Perhaps it’s related to doom/evil mode, but not sure how to fix. Would be great if you have any further pointers. Thanks, jbj