negcx

negcx

VS Code HTML Language Features for EEX and LEEX

I am using Visual Studio Code and the great vscode-elixir-ls extension, which was recently updated. I am getting syntax highlighting in .leex and .eex files which is great.

However, none of the VS Code HTML language features are working: HTML formatting, tag matching, attribute autocompletion, etc.

I have tried including some settings that I had enabled for prior extensions:

"[html-eex]": {
    "editor.tabSize": 2,
    "editor.defaultFormatter": "vscode.html-language-features"
  },
"emmet.includeLanguages": {
    "html-eex": "html"
  },

This has not succeeded. When I try to save the file VS Code reports that the HTML Language Features ‘extension’ has failed to format the file. For other extensions I have forked to add html-eex support, but I believe this is built right into VS Code. (such as GitHub - negcx/vscode-html-css: Visual Studio Code Extension - CSS support for HTML documents · GitHub)

Has anyone solved this or found a different solution?

Most Liked

Dusty

Dusty

A complete solution isn’t here yet, but I’ve been circumventing the tag completion piece with snippets. The snippets were one of many awesome gifts that The Pragmatic Studio has provided as part of their LiveView course.

Here is a gist with the snippets—scroll down for the HTML tags in EEX (sorry for the excessive indentation I’m on mobile and can’t easily fix).

Although VS Code allows you to configure snippets by language, I think it works better to put them in a global snippets file with the scope property specifying the language. That way you only write the snippet once, but can use it in EX. EEX, LEEX, etc.

The only functional difference with the snippets is that you need to type the trigger instead of the tag, for example div then tab, rather than <div>.

I know it’s only a piece of what you’re looking for, but it makes a big difference for me.

axelson

axelson

Scenic Core Team

This will take some work that no one has put in the time yet. Here’s the VSCode documentation on an embedded language:
https://code.visualstudio.com/api/language-extensions/embedded-languages

negcx

negcx

By the way, my setting above did get Emmet snippets to work (e.g. div>div>h1). If I’m being honest, I’m looking more for the linting, attribute autocomplete, etc. These snippets are great though, thanks for those!

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
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
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
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
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New

We're in Beta

About us Mission Statement