emmetio / codemirror6-plugin

WIP Plugin for CodeMirror 6
40 stars 7 forks source link

Snippets and Expansions not working in alternate style languages (SCSS, Sass, Less) #20

Open shshaw opened 1 year ago

shshaw commented 1 year ago

Related to #14: I have the new syntax setup in place. Snippets work correctly, but the snippet autocompletions are not showing up for Sass and SCSS. CSS still shows them fine.

Sass: https://user-images.githubusercontent.com/777155/233471378-15fb816b-5caf-4134-b67c-871e7b37dd9b.mov

Regular CSS:

Screenshot 2023-04-20 at 1 05 24 PM

I haven't tested the other languages, but I'll provide more details if I do.

Worth noting that I'm using the just released https://github.com/codemirror/lang-sass package via the latest version of https://github.com/codemirror/language-data

shshaw commented 1 week ago

Updating this to say that snippets and expansions don't seem to be working in SCSS, Sass and LESS anymore, not just the preview.

I'm setting the syntax based on the EmmetKnownSyntax so it should be resolving to the correct internal value.

Screenshot 2024-09-09 at 1 26 15 PM

sergeche commented 3 days ago

That’s a bit weird one: you should explicitly provide emmetCompletionSource extension as autocomplete option of SASS lang. Your config may look like this:

import { sass, sassLanguage } from '@codemirror/lang-sass';
import { emmetCompletionSource, EmmetKnownSyntax.scss } from '@emmetio/codemirror6-plugin';

new EditorView({
    doc: text,
    extensions: [
        basicSetup,
        sass(),
        sassLanguage.data.of({
            // configure Emmet as completion provider for SASS lang
            autocomplete: emmetCompletionSource
        }),
        Prec.high(abbreviationTracker({
            // don’t forget to explicitly specify current syntax to Emmet
            syntax: EmmetKnownSyntax.scss,
            config: {
                stylesheet: {
                    snippets: {
                        my: 'padding: 10px;'
                    }
                }
            }
        })),
    ]
});