Skip to content
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

FEATURE: Automatically detect remote style sheets #49

Open
VladimirMikulic opened this issue Mar 16, 2020 · 18 comments
Open

FEATURE: Automatically detect remote style sheets #49

VladimirMikulic opened this issue Mar 16, 2020 · 18 comments
Assignees
Labels
enhancement New feature or request

Comments

@VladimirMikulic
Copy link

As the title suggests, I would like that this extension can suggest classes in a file that is referencing a remote style sheet without requiring me to add it to the html-css-class-completion.remoteStyleSheets property.

Would that be possible? Thanks.

@gencer
Copy link
Owner

gencer commented Mar 17, 2020

Hi @VladimirMikulic , It is actually possible but let me think about it.

BTW, should we only allow HTML files or All files like .{hml,htm,php,slim,latte,vue}... This can be a little tricky.

@VladimirMikulic
Copy link
Author

Hi @gencer. Thank you very much for a fast reply.
It's annoying that every time I switch project, I need to add different version of Bootstrap/Tailwind.. to the completion.remoteStyleSheets property.

Instead of an array, you could maybe have parseRemoveStyleSheets as boolean.

For the initial implementation, only HTML files are just fine.
Maybe you could set a configuration option for this as well to let users decide which files to allow?

@gencer
Copy link
Owner

gencer commented Mar 17, 2020

Sounds good to me. Both boolean value and trace fields for extensions. I will look into this tomorrow.

@VladimirMikulic
Copy link
Author

Awesome! Thank you very much.

@gencer
Copy link
Owner

gencer commented Mar 19, 2020

This can be implemented. I believe i can parse html with regex and inlcude in the project however this is going to be harder on other template providers. I have two options here.

A) only support html for now and provide option for this
B) create unified parser for each template providers and parse all.

Im evaluating these options now.

@VladimirMikulic
Copy link
Author

@gencer that's some good news. Let me know what you've decided to do. In my opinion, the unified parser would be really cool to have (as a config option maybe).

@gencer
Copy link
Owner

gencer commented Apr 8, 2020

@VladimirMikulic Can you test this version, please?

Before installing this one, please remove all remoteStylesheet directives from config files.

Currently this will try to load from HTML only. There is a new configuration parameter called searchRemoteGlobPattern:

          "html-css-class-completion.searchRemoteGlobPattern": {
            "type": "string",
            "default": "**/*.{svelte,latte,php,html,twig}",
            "description": "A glob pattern that includes html code which will be parsed if its contains Remote CSS"
          },

But its currently only supported on HTML. More languages will be added in future.

Awaiting your feedback.

v1.6.0

html-slim-scss-css-class-completion-1.6.0.zip

@gencer gencer self-assigned this Apr 8, 2020
@gencer gencer added the enhancement New feature or request label Apr 8, 2020
@VladimirMikulic
Copy link
Author

@gencer this is AWESOME! I've just tried it out and guess what? I'll never have to memorize framework classes again :)

There is one bug/feature that I've encountered. Let's say I include Bulma in my document and I cache the classes, it works, no problem. Then, I realize that the project requires Bootstrap and I replace the Bulma CDN href with Bootstrap's and cache the classes again. This time it suggests Bulma classes as well as Bootstrap classes, although I use only Bootstrap and I removed Bulma.

I.E. the cache is not invalidated. It's not a top priority bug, though.

Anyway, thank you very much on this, I'll be using v1.6.0 from now on!

@gencer
Copy link
Owner

gencer commented Apr 8, 2020

@VladimirMikulic Glad it did worked! 🎉 Well, i will also make sure cache gets invalidated after such changes.

I will not publish this version yet due to cache invalidation. You can freely use this version. I will update here when i got more info about this bug.

@gencer gencer mentioned this issue Apr 16, 2020
gencer added a commit that referenced this issue Apr 16, 2020
@gencer
Copy link
Owner

gencer commented Apr 16, 2020

@VladimirMikulic Can you test this version to see re-cache works without using old remote stylesheet like you mentioned earlier.

html-slim-scss-css-class-completion-1.6.1.zip

@gencer
Copy link
Owner

gencer commented Apr 16, 2020

Please also note that, You have to explicitly set this within your settings for this version:

{
  ...
  "html-css-class-completion.searchRemoteGlobPattern": "**/*.{svelte,tpl,latte,php,html,twig}",
  ...
}

Then restart / install

@VladimirMikulic
Copy link
Author

Hi @gencer. Thank you for coming back to me.
Unfortunately, this version completely breaks the CSS classes autocompletion.
Now, it suggests HTML tags and attributes as "classes".

test

@gencer
Copy link
Owner

gencer commented Apr 16, 2020

Hmm. Weird. Lets try empty the folder then.

Try this one:

html-slim-scss-css-class-completion-1.6.1.zip

@VladimirMikulic
Copy link
Author

This one is no go as well. For example, let's say I cache Bulma classes and it does work fine, but if I delete Bulma and replace it with Bootstrap it won't fetch new classes. It still suggests Bulma classes.

@gencer
Copy link
Owner

gencer commented Apr 16, 2020

But previously, bootstrap and bulma both was suggested right? This time only old one.

It's getting weirder. I will install a virtual machine and try there with few templates.

Thank you so much for taking time to test them for me.

Stay safe!

@VladimirMikulic
Copy link
Author

That's correct. Previously, they were both suggested.
I'll help you as much as I can, just @mention-me :)

@gencer
Copy link
Owner

gencer commented Apr 16, 2020

Thanks @VladimirMikulic! I will try to debug this one to make sure it get refreshed when re-cached. In fact im planning to add this to incremental building. This means when you hit CTRL+S or just save, it will do the update for you.

I will update here when i got something.

@VladimirMikulic
Copy link
Author

VladimirMikulic commented Apr 16, 2020

CTRL+S would be really amazing workflow. Thank you very much on the effort that you've put into this extension!

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

No branches or pull requests

2 participants