language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

SCSS highlighting breaks if defined as default and not in the component

Open dkzlv opened this issue 4 years ago • 4 comments

Describe the bug If you set SCSS as the default style language and not set it inside the component itself on <style> tag, it would mess up the whole highlighting of everything below.

To Reproduce Set the defaults in rollup.config.js:

import sveltePreprocess from 'svelte-preprocess';

const preprocess = sveltePreprocess({
  defaults: {
    style: 'scss',
  },
  scss: true,
});

Set the same in svelte.config.js:

const sveltePreprocess = require('svelte-preprocess');

module.exports = {
  preprocess: sveltePreprocess({
    defaults: {
      style: 'scss',
    },
    scss: true,
  }),
};

Use some basic component like this:

<script>
  let blabla = 'wer';
</script>

<style>
  @mixin a($var) {
    font-style: $var;
  }

  .selector {
    @include a('qwd');
  }
</style>

<!-- Messes up everything -->
<div class="selector">Yep {blabla}</div>

Expected behavior Should work as if <style lang='scss'> is saved in the file.

Screenshots Messed up highlighting

System (please complete the following information):

  • OS: OS X
  • IDE: VS Code
  • Plugin/Package: Svelte for VS Code (103.0.0)

dkzlv avatar Jan 08 '21 14:01 dkzlv

I don't think there's a way to solve this I'm afraid. The docs mention this and give an explanation why. If someone knows a way, let us know.

dummdidumm avatar Jan 08 '21 15:01 dummdidumm

Related VS Code issue: https://github.com/microsoft/vscode/issues/68647

dummdidumm avatar Jan 24 '21 13:01 dummdidumm

Offtop: this idea is so dope. <i18n> tag would be so cool in the context of https://github.com/sveltejs/sapper/issues/576.

dkzlv avatar Jan 25 '21 09:01 dkzlv

Ran into this today and remembered reading those docs but did not recall it mentioning that it would only work for some instances.

@dummdidumm Do you happen to know which cases permit leaving off the lang/type from the style tag?

For me this doesn't appear to even get recognized by the language-server as I get css errors all over in my script tag unless I set the lang attribute to scss.

image

image

nathanblair avatar Mar 09 '21 13:03 nathanblair