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)))
![]()
Most Liked
ananthakumaran
FYI, I am taking a stab at the grammar as well. GitHub - ananthakumaran/tree-sitter-elixir · GitHub
axelson
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:
- GitHub - wingyplus/tree-sitter-elixir: Tree Sitter grammar for Elixir · GitHub by @wingyplus
- Fork of the above: GitHub - Tuxified/tree-sitter-elixir: Tree Sitter grammar for Elixir · GitHub by @Tuxified
Older stalled projects:
- GitHub - jlgeering/tree-sitter-elixir: see also https://github.com/skbolton/tree-sitter-elixir · GitHub
- GitHub - lee-dohm/tree-sitter-elixir: Experimentation with a Tree Sitter grammar for Elixir · GitHub
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
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/
Popular in Guides/Tuts
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









