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/

Where Next?

Popular in Guides/Tuts Top

redfloyd
Greetings fellow alchemists ! I have started to write an open-source interpreter in Elixir (GitHub - nicolasdilley/dwarf-interpreter: Th...
New
dennisreimann
I wrote a guide for implementing Passwordless Authentication a.k.a. “Magic Login Links”: https://dennisreimann.de/articles/phoenix-passw...
New
zenw0lf
Hello all! For those wanting to try your hands at Elixir / Phoenix, I wrote a comprehensive tutorial on doing a simple JSON API with sai...
New
OndrejValenta
Me and my boys started a new website specifically designed for other ASP.NET programmers that struggle, as we do, with their transformati...
New
dkuhlman
For those of you who might be interested in using ZeroMQ in Elixir, I converted the Erlang examples in the ZeroMQ “zguide” to Elixir. I ...
New
9mm
So I’m really loving elixir. BY FAR the most excruciating piece of learning a functional language for me is having to “transform” all my ...
New
slouchpie
Warmest greetings, comrades. I recently started using :dns_cluster (GitHub - phoenixframework/dns_cluster: Simple DNS clustering for dis...
New
TwistingTwists
This is a thread to note down things/best practices encountered in LiveBeats App as I explore the source code. https://github.com/fly-...
New
jtormey
Hello! Having written a lot of LiveView code, I’ve made some VS Code snippets to speed up writing callbacks for LiveViews and LiveCompon...
New
kevinlang
Hey all, With Phoenix 1.6 just around the corner, I figured I’d make a tutorial on how to add Bulma to a new Phoenix 1.6 project. By lev...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
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
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

We're in Beta

About us Mission Statement