malloryerik

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 hyphenated word, phoenix-heex.

phoenix-heex is the VSCode “language id” for .html.heex templates. If I understand correctly, Marlus Saraiva @msaraiva set it up, and it seems to solve… everything?

The new Phoenix Framework VSCode extension uses it.

So, just add phoenix-heex (and not, for example, HEEx) as a language for html and the vs-code-eex-formatter, Tailwind IntelliSense extension, HTML expansion/completion and other extensions all work today. :racehorse:

In your VSCode’s settings.json :

emmet HTML/CSS expansion & snippets

    "emmet.includeLanguages": {
        ...
        "phoenix-heex": "html"
    },

vs-code-eex-formatter

    "[phoenix-heex]": {
        "editor.defaultFormatter": "RoyalMist.vscode-eex-format"
    },

Tailwind class autocomplete (<- The maintainer told me how to find a language ID.)

    "tailwindCSS.includeLanguages": {
        "phoenix-heex": "html"
    },

… and likewise for the other extensions I use that allow language id input in setting.json; planting a “phoenix-heex” following the general pattern of other listed languages has seemed to work. :man_farmer:

I know quite little about this stuff, actually, so any help, advice and/or correction is welcome!

Showing Posts 1 to 10

alaadahmed

alaadahmed

Thanks a lot, you really saved me a lot of time searching and figuring out.

AlanMcCann

AlanMcCann

Thank you as well!

mikael

mikael

Do you get HTML intellisense in VS Code with this extension? I get syntax highlighting, but no HTML intellisense or autocompletion (eg. typing “<div c” should bring attributes like “class”, right?).

Also how about intellisense for assigns, functions defined in views, helpers (link, Routes etc.)?

gabecook

gabecook

I was unable to get the HEEx template formatting to work immediately.

    "[phoenix-heex]": {
        "editor.defaultFormatter": "RoyalMist.vscode-eex-format"
    },

When attempting to format a HEEx file, I would get the following error.

Extension 'Elixir Templates Formatter' is configured as formatter but it cannot format 'HEEx'-files

After some searching and a bit of hacking, I can get it to work if I make add ‘phoenix-heex’ to the providers in the the royalmist.vscode-eex-format-0.2.0 extension. Oh, I also have to format a EEx file first.

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context) {
    vscode.languages.registerDocumentFormattingEditProvider(["html", "eex", "HTML (EEx)", "html-eex", "phoenix-heex" ], {
        provideDocumentFormattingEdits(document) {
...

So, a couple of questions. First, has anybody else had this problem?

Second, why are there so many forks of this project? Is RoyalMist’s fork the one everybody uses? If I can figure this out I’ll try to submit a pull request.

gabecook

gabecook

If you have the problem I had, here’s the pull request I made to RoyalMist’s fork to get this to work.

https://github.com/RoyalMist/vscode-eex-format/pull/1

Also, thanks for making the original post. It really helped me get going.

Cheers!

malloryerik

malloryerik OP

Thanks so much! I’ve had various problems with this setup and it’s still never perfect, at least as I have it.

Second, why are there so many forks of this project? Is RoyalMist’s fork the one everybody uses?

The RoyalMist fork is the one I’ve seen mentioned the most, including by the PragmaticStudio folks. I think there must be so many forks because none are just right?

There’s a native Elixir HEEx formatter that’s been started, but I’m not sure when it will be ready.

https://github.com/Eptis/heex_formatter

Just two commits so far, but it looks like a sizeable amount of code.

@mikael asked about HTML Intellisense:

Do you get HTML intellisense in VS Code with this extension? I get syntax highlighting, but no HTML intellisense or autocompletion (eg. typing “<div c” should bring attributes like “class”, right?).

Well as I have things set up now it seems I only get Elixir Intellisense in .HEEx templates. Emmet works, and at present I’ve also got Tab9 and GitHub Copilot. Tab9 seems to give me most HTML autocomplete, and Copilot is like… umm… well it’s certainly interesting.

As for things like assigns, I find myself looking to my file myself, so no. I tend to work in separate module and template files, and I’m not yet sure how much of a difference that makes.

ani

ani

Yes, it’s not working for me as well. Getting the same error!

Sebb

Sebb

git clone https://github.com/gabecook/vscode-eex-format
cd vscode-eex-format
npm install -g vsce
npm install
vsce package
code --install-extension vscode-eex-format-0.2.0.vsix
gem install htmlbeautifier

plus the setting changes from above. :dizzy_face:

RoyalMist

RoyalMist

Hi all :slightly_smiling_face:

I just merged the PR sorry for the delay.
Version 0.5.0 is ok with the new format :slight_smile:

phpcitizen

phpcitizen

I cannot trigger the .heex files to work.

settings.json I have:

  "files.associations": {
    "*.heex": "phoenix-heex"
  },
  "editor.defaultFormatter": "RoyalMist.vscode-eex-format"

EDIT: Seems like triggering works with these settings but tag alignments with new tags

<.function ... /> 

does not align properly.

Where Next? Top

Trending in Guides/Tuts Top

rogach
I’ve spent some time understanding how to do hot code reloading with releases built using mix release, and here I’d like to detail the st...
New
c4lliope
# ~/src/livebook/.iex.exs System.cmd("xdg-open", [ LivebookWeb.Endpoint.access_url() ] ) Because Livebook requires a unique passcode on ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews