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. ![]()
In your VSCode’s settings.json :
emmet HTML/CSS expansion & snippets
"emmet.includeLanguages": {
...
"phoenix-heex": "html"
},
"[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. ![]()
I know quite little about this stuff, actually, so any help, advice and/or correction is welcome!
Trending in Guides/Tuts
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
alaadahmed
Thanks a lot, you really saved me a lot of time searching and figuring out.
AlanMcCann
Thank you as well!
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
I was unable to get the HEEx template formatting to work immediately.
When attempting to format a HEEx file, I would get the following error.
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.
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
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
Thanks so much! I’ve had various problems with this setup and it’s still never perfect, at least as I have it.
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:
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
Yes, it’s not working for me as well. Getting the same error!
Sebb
plus the setting changes from above.
RoyalMist
Hi all
I just merged the PR sorry for the delay.
Version 0.5.0 is ok with the new format
phpcitizen
I cannot trigger the .heex files to work.
settings.json I have:
EDIT: Seems like triggering works with these settings but tag alignments with new tags
does not align properly.