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

Stylus blocks are treated as CSS #590

Closed
JulianGaibler opened this issue Oct 3, 2020 · 5 comments
Closed

Stylus blocks are treated as CSS #590

JulianGaibler opened this issue Oct 3, 2020 · 5 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@JulianGaibler
Copy link

Hey! 👋

Describe the bug
I want to use stylus in my svelte components. Syntax highlighting is correct, but it seems the code is still treated as CSS. The code-completion is confused and I get a lot of errors regarding braces, like css(css-lcurlyexpected).

I followed this guide but that didn't help and neither did disabling everything style-related in VS Code and the language tools.

It seems to me that the language tools don't recognize stylus as a language yet.

To Reproduce

  1. Install "Svelte for VS Code" extension (svelte.svelte-vscode)
  2. Install "language-stylus" extension (sysoev.language-stylus)
  3. Create new svelte file with <style lang="stylus"> tag

For example:

<style lang="stylus">
  div
    background #FFFFFF
    width 290px
</style>

Expected behavior

  • No errors or stylus related errors.
  • No syntax completion or stylus syntax completion.

I don't necessarily need all language features within this block (although it would be nice), but the css errors make working with svelte and stylus really hard.

Screenshots
Screenshot of Problem

System (please complete the following information):

  • OS: macOS
  • IDE: VSCode
  • Plugin/Package: sveltePreprocess and the others mentioned above
@JulianGaibler JulianGaibler added the bug Something isn't working label Oct 3, 2020
@dummdidumm
Copy link
Member

dummdidumm commented Oct 4, 2020

Did you set this setting to false? Doing so should turn off these diagnostics.

We should also add stylus to this function and enhance the docs.

@JulianGaibler
Copy link
Author

Oh yes, that at least disabled diagnostics – Thanks!!

But vs code still seems to think it's CSS and the autocompletion goes haywire. I assume because the fallback is always CSS?

@dummdidumm
Copy link
Member

That's correct. We need to skip these things if lang="stylus" is set. In the meantime, you can disable the feature through this setting.

@JulianGaibler
Copy link
Author

Yay, that did the trick! 🎉

I don't know if you want to close this. IMHO some support for stylus would be nice, because svelte-preprocess supports it.
But looking at veturs code, it seems adding full support for stylus might be comparatively complicated.

But maybe it's possible to at least disable CSS language features, by as you said, adding 'stylus' here and add a check here as well, like:

if (shouldExcludeCompletion(kind)) {
    return null;
}

TL;DR for humans that get CSS errors when using stylus in VS Code:

"svelte.plugin.css.completions.enable": false
"svelte.plugin.css.diagnostics.enable": false

dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Oct 13, 2020
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Oct 13, 2020
@dummdidumm
Copy link
Member

Diagnostics and autocompletion is now turned off when lang="stylus".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

2 participants