lukertty

lukertty

Tips: Syntax highlight for inline ~L liveview code in emacs

Install web-mode and mmm-mode first and put this in your config file:

(require 'mmm-mode)
(require 'web-mode)
(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)
    (submode 'web-mode)
    (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")
         (web-mode-on-engine-setted))
    (apply f r)))

:grin:

Most Liked

ananthakumaran

ananthakumaran

FYI, I am taking a stab at the grammar as well. GitHub - ananthakumaran/tree-sitter-elixir · GitHub

axelson

axelson

Scenic Core Team

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.

jsmestad

jsmestad

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).

https://blog.evalcode.com/phoenix-liveview-inline-syntax-highlighting-for-emacs/

Last Post!

mrjbj

mrjbj

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

Where Next?

Popular in Guides/Tuts Top

benwilson512
Correct if me I’m wrong, as best I can tell there aren’t any reasons to use mix run --no-halt in production vs releases. The marginal val...
New
dgamidov
Hi folks, Just a short instruction. Maybe it will help somebody. Install boostrap with deps and Sass: cd assets npm install jquery ...
New
Eiji
Hey, today I give amnesia library a try and found a few problems. I would like describe how to setup it properly and solve problems which...
New
nietaki
Just a quick heads up: There seems to be a bug in Erlang/OTP 21.3, which can cause some errors when making http requests. If you’re using...
New
zookzook
If you want to use the MongoDB in your next Killer-App-Project, but you did not dare ask because otherwise many would advise you to use P...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
rhcarvalho
After collecting information from multiple sources (this forum, blogs, StackOverflow and GitHub), I was finally able to successfully embe...
New

Other popular topics Top

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
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
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 49266 226
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement