Skip to content

Not working for HTML-like files #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SHxKM opened this issue Jun 30, 2019 · 48 comments
Closed

Not working for HTML-like files #58

SHxKM opened this issue Jun 30, 2019 · 48 comments

Comments

@SHxKM
Copy link

SHxKM commented Jun 30, 2019

Thanks for the great extension.

For regular HTML files, it works great. However, the extension stops working completely once a file is associated via VSCode to another file type.

For example, Django template files use the regular .html extension but include special mustache {{ }} syntax. I'm using another extension to get tag highlighting for these files, as well as emmet expansion. But once I associate this file as "Django HTML" - TailwindCSS Intellisense stops working.

Anything I'm missing?

@SHxKM
Copy link
Author

SHxKM commented Jul 1, 2019

Poking in the code, could it be as simple as adding "django-html" to this list in this file in src/index.ts?

https://github.com/bradlc/vscode-tailwindcss/blob/dd82e0282e03f6832f18976718f036050fe57ecc/src/index.ts#L40-L61

Perhaps it's better to make this list extensible through a setting?

@JulioBarros
Copy link

Doesn't work for me for .jsx files. Would be great if that could work too. Thanks.

@alpap
Copy link

alpap commented Jul 18, 2019

same here for svelte files

@dhc02
Copy link
Contributor

dhc02 commented Jul 19, 2019

I'm pretty sure @SHxKM's suggestion should work for django, and a similar simple change should work for most other html-like files.

As you can see from #18 , that's all it took to make this work for Phoenix last year.

I think that what we need is a setting for the extension that can be modified by users to add other filetypes so that it's not hard-coded in the extension, requiring a pull request for every addition.

This would be similar to how PHP Intelephense does it: In your settings.json, you can add

"intelephense.files.associations": [
    "*.php",
    "*.phtml",
    "*.myRandomFiletype"
  ]

and then it will start treating .myRandomFiletype as php.

I've looked into the code for this extension and I can't wrap my head around how to implement something like this yet. What do you think, @bradlc?

@rhyswat
Copy link

rhyswat commented Jul 31, 2019

Ditto when I've told VS Code to treat foo.css as PostCSS. I get completions for foo.css as CSS.

Extension version 0.2.0

VS Code version 1.36.1

bradlc added a commit that referenced this issue Aug 6, 2019
@ryudice
Copy link

ryudice commented Aug 10, 2019

It's not working on js and jsx files

@pavelloz
Copy link

pavelloz commented Aug 11, 2019

I have the same problem, but in .liquid files. Maybe it would be nice to just have an option that you place under a language that enables plugin.

ie.

    "[liquid]": {
        "tailwindcss.enabled": true
    },

Anyway, since author is not responding and this is very easy fix + pretty much a blocker, probably forking is the way to go.

@skycult
Copy link

skycult commented Aug 13, 2019

It does not works for any Vue + Tailwind project.

@pavelloz
Copy link

BTW. @skycult make sure you have config file in your project.

When i was tuning forked extension for my use case i discovered https://github.com/bradlc/vscode-tailwindcss/blob/master/package.json#L25-L27 which means extension wont even activate until you have a tailwind config.

@kamalhm
Copy link

kamalhm commented Sep 9, 2019

@pavelloz

I've added the tailwind config but it still doesnt show up on vue-file, any suggestion?

@reducio
Copy link

reducio commented Sep 19, 2019

I have problem with .html.eex and .html.leex files in Phoenix (Elixir).

If changing the VSCode file type (lower right hand corner of window) to HTML manually when editing tailwind classes which is annoying but does work.

So I can see this extension support HTML (EEx): https://github.com/bradlc/vscode-tailwindcss/blob/f5dfe02f74ac9bd68529f1997ae875691b819833/src/index.ts#L50

Check topic on the ElixirForum, please: https://elixirforum.com/t/how-to-force-the-tailwind-css-intellisense-extension-for-vscode-work-with-html-eex-and-html-leex-files/25520

@reducio
Copy link

reducio commented Sep 19, 2019

I have problem with .html.eex and .html.leex files in Phoenix (Elixir).

If changing the VSCode file type (lower right hand corner of window) to HTML manually when editing tailwind classes which is annoying but does work.

So I can see this extension support HTML (EEx):

https://github.com/bradlc/vscode-tailwindcss/blob/f5dfe02f74ac9bd68529f1997ae875691b819833/src/index.ts#L50

Check topic on the ElixirForum, please: https://elixirforum.com/t/how-to-force-the-tailwind-css-intellisense-extension-for-vscode-work-with-html-eex-and-html-leex-files/25520

SOLUTION: https://elixirforum.com/t/how-to-force-the-tailwind-css-intellisense-extension-for-vscode-work-with-html-eex-and-html-leex-files/25520/4?u=stavanger

praveenperera pushed a commit to praveenperera/vscode-tailwindcss that referenced this issue Sep 26, 2019
@jrock2004
Copy link

It would be awesome of we could add our list of filetypes because I think it would be bad for the maintainer of the plugin to have to add them all. The real logic seems to be in tailwindcss-language-server which seems to be private. Would be awesome to hear from main developer on if he would like help implementing something or are we all stuck with the ext he has chosen?

@andreasRu
Copy link

Need to use the extension for .cfm files too.

@mrmurphy
Copy link

I'd love to have it work for .re files!

@flaugher
Copy link

For what it's worth, I switched to Intellisense for CSS by Zignd and it works for my use case which is setting the VS Code language mode to Django HTML.

@optimizasean
Copy link

I would love to see this work on .NET files (.razor - Razor Syntax)!

@angieherrera
Copy link

Would love this for .twig files as well.

@fpauser
Copy link

fpauser commented Feb 8, 2020

And I'd love to see support for glimmer templates (hbs) in Ember.js projects

@ghost
Copy link

ghost commented Mar 17, 2020

I personally like how emmet does it.

  "emmet.includeLanguages": {
    "HTML (Eex)": "html",
    "HTML (EEx)": "html",
  },

though from reading the code not sure why #54 is not working.

@bux
Copy link

bux commented Mar 27, 2020

👍 for mustache files

@dasAnderl
Copy link

doesnt work in vue files in vs code. does work in intellij idea though.

@zolrath
Copy link

zolrath commented Apr 29, 2020

I can confirm that while trying the new v0.3.0-alpha.1 vsix the extension fails to provide IntelliSense for "HTML (EEx)" (.html.eex and .html.leex) files.

Testing on standard .html files in the same directory provides IntelliSense so it's not deactivated for this project as a whole, just the EEx files.

@bradlc
Copy link
Contributor

bradlc commented Apr 29, 2020

@zolrath That's odd. It works fine for me in .html.eex files with this extension installed. Are you using the same one?

I am definitely going to look into adding a file association setting 👍 For now I have added some languages to v0.3.0-alpha-1 so please let me know if I've missed yours

@bux
Copy link

bux commented Apr 29, 2020

@bradlc
adding *.mustache would be appreciated

bradlc pushed a commit that referenced this issue Apr 29, 2020
@zolrath
Copy link

zolrath commented Apr 29, 2020

@zolrath That's odd. It works fine for me in .html.eex files with this extension installed. Are you using the same one?

I am definitely going to look into adding a file association setting 👍 For now I have added some languages to v0.3.0-alpha-1 so please let me know if I've missed yours

@bradlc
I am using the ElixirLS extension which is the current most-supported Elixir plugin.
Additionally, I tried the extension you linked, both with ElixirLS enabled and with ElixirLS disabled and I not getting IntelliSense on .html.eex files.

@ghost
Copy link

ghost commented Apr 29, 2020

I also get the same ^

@zolrath
Copy link

zolrath commented Apr 30, 2020

I've been performing some tests for Elixir support now that the name is correct in v0.3.0-alpha-1.

In a standard Phoenix project the directory structure (only showing relevant files/folders) is:

./
├── assets
│   └── node_modules
│   └── tailwind.config.js
├── lib
│   └── example_web
│   │   └── templates
│   │   │   └── layout (or any folder name)
│   │   │   │   └── root.html.eex
│   │   │   │   └── live.html.leex
│   │   └── live
│   │   │   └── page_live.html.leex
│   │   │   └── collocated_live.ex (has a render function with ~L"""html""" inside it)

The behavior I'm seeing is that if I start VSCode in the root directory I get no Tailwind IntelliSense of any kind.

Start VSCode in root

  • html: No IntelliSense
  • html.eex|html.leex: No IntelliSense

Start VSCode in /assets

  • html: Immediate IntelliSense when typing in class attribute
  • html.eex|html.leex: IntelliSense must be manually triggered. If I type Ctrl+Space while inside a class attribute autocomplete appears. It does not automatically trigger while typing but once Ctrl+Space or a space is pressed it begins autocompleting. If backspace is pressed autocomplete stops and must be retriggered with Ctrl+Space or space.

It seems that the extension isn't recognizing the tailwind.config.js files location?

Edit:
If vscode-tailwindcss requires tailwind.config.js and node_modules to be present it may be discovering tailwind.config.js properly but not finding node_modules

Since tailwind.config.js isn't in my root and there is no node_modules in my root, can you add a fallback to look for node_modules in the same directory as tailwind.config.js?

Edit 2:
Seems to be working great with alpha 2!

@mikebusby
Copy link

Would love to see support for nunjucks templates (.njk)

@gerrywastaken
Copy link

Use this instead: https://marketplace.visualstudio.com/items?itemName=Atishay-Jain.All-Autocomplete

Just open the generated css file (e.g. public/css/app.css) in a tab and the classes will complete in all other tabs.

@lobo-tuerto
Copy link

I personally like how emmet does it.

  "emmet.includeLanguages": {
    "HTML (Eex)": "html",
    "HTML (EEx)": "html",
  },

though from reading the code not sure why #54 is not working.

For anyone stumbling upon this, the new way for making emmet work with your .html.eex files now is:

"emmet.includeLanguages": {
  "html-eex": "html"
},

@lobo-tuerto
Copy link

BTW this extension is not working with HTML EEx files anymore :(

@mettiu
Copy link

mettiu commented Jun 10, 2020

@bradlc
adding *.hbs and *.handlebars files would be appreciated

@Nisthar
Copy link

Nisthar commented Jun 15, 2020

any updates?

@bradlc
Copy link
Contributor

bradlc commented Jun 15, 2020

django-html is now one of the languages with built-in support 👍

@bradlc bradlc closed this as completed Jun 15, 2020
@andreasRu
Copy link

So this issue "not working for HTML like files" has been closed with addition of django-html support? Should I open another issue for adding the support for other html like file extensions that still won't work, or should we just forget about it for now?

@zolrath That's odd. It works fine for me in .html.eex files with this extension installed. Are you using the same one?

I am definitely going to look into adding a file association setting For now I have added some languages to v0.3.0-alpha-1 so please let me know if I've missed yours

@bradlc
Copy link
Contributor

bradlc commented Jun 15, 2020

@andreasRu v0.3.0 added support for any language, via the includeLanguages setting. If it's not working for you please open a new issue.

@andreasRu
Copy link

andreasRu commented Jun 17, 2020

@bradlc Oh goodness!!! Just updated/added to my workplace, works PERFECTLY!!! LOVE YOU 💯 :D THANK YOU SO MUCH!!!

@imbwaldo
Copy link

imbwaldo commented Jun 25, 2020

Thanks a ton, @bradlc!

@icarthik
Copy link

could you pls extend for .hbs handlebars files

@icarthik
Copy link

@bradlc could you pls extend for .hbs handlebars files

@jd-solanki
Copy link

for hbs:

{
    "tailwindCSS.includeLanguages": {
        "hbs": "html",
    },
}

@aanomm
Copy link

aanomm commented Jun 13, 2021

  • this still doesn't seem to work for nunjucks
  • should it?
  • nunjucks is so gooooood

@xshapira
Copy link

xshapira commented Sep 6, 2021

For Django templates:

"tailwindCSS.includeLanguages": {
    "plaintext": "django-html",
    "django-html": "html",
  }

Works flawlessly!

@koppel
Copy link

koppel commented Feb 1, 2023

Thanks for that! The same works for nunjucks; can we make this part of the documentation?

    "tailwindCSS.includeLanguages": {
        "plaintext": "njk",
        "njk": "html"
    }

@JexPY
Copy link

JexPY commented Jul 6, 2023

@xshapira thnx,

Worked in the custom workspace:

    "json.schemaDownload.enable": true,
    "files.associations": {
        "*.html": "jinja-html"
    },
    "emmet.includeLanguages": {
        "jinja-html": "html"
    },
    "[jinja-html]": {
        "editor.defaultFormatter": "monosans.djlint",
        "editor.detectIndentation": false,
        "editor.tabSize": 2,
        "editor.formatOnSave": true
    },
    "tailwindCSS.includeLanguages": {
        "plaintext": "jinja-html",
        "jinja-html": "html",
        "javascript": "javascript",
        "css": "css"
    }

@IgorArnaut
Copy link

IgorArnaut commented Apr 12, 2025

For Django templates:

"tailwindCSS.includeLanguages": {
"plaintext": "django-html",
"django-html": "html",
}

Works flawlessly!

Doesn't work for me. I have both Tailwind CSS Intellisense and junstyle's Django Template Support and I use django-tailwind package in Django project.

@IgorArnaut
Copy link

@andreasRu v0.3.0 added support for any language, via the includeLanguages setting. If it's not working for you please open a new issue.

How do I set it for .jsx files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests