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

Extensibility support #102

Open
mhsdesign opened this issue Apr 15, 2022 · 7 comments
Open

Extensibility support #102

mhsdesign opened this issue Apr 15, 2022 · 7 comments

Comments

@mhsdesign
Copy link

I'm working with a Html(Xml) and Jsx like DSL
The problem is that elements support a dot in their name like:

<Neos.Fusion:Tag tagName='h1' content='foo' />

So I was wondering if one could use this Emmet package to somehow add custom
Emmet snippets (and don't interprete the dot as css class)

edit:
I fear this is not possible as Emmet itself doesn't even support this for Jsx. For now I will use 'normal' Monaco snippets. (difficulty is figuring out if the cursor is in an attribute but that can be copied from here ^^ - or extracted/exposed? )

@troy351
Copy link
Owner

troy351 commented Apr 15, 2022

Does VS Code supports feature like this? If not, I'm afraid you need to figure it out yourself

@mhsdesign
Copy link
Author

i know its not api currently, but you are using this helper isValidLocationForEmmetAbbreviation. It pretty useful and id like to use it to not trigger a custom completion within html attributes. Do you think it would make sense to make it API?

import { isValidLocationForEmmetAbbreviation } from "emmet-monaco-es/src/abbreviationActions";
if (
    !isValidLocationForEmmetAbbreviation(
        model,
        position,
        "html",
        "html"
    )
) {
    return;
}

@troy351
Copy link
Owner

troy351 commented May 7, 2022

What do you mean by "make it API"?
You want to use it outside of this plugin or you want to make this check configurable?

@mhsdesign
Copy link
Author

mhsdesign commented May 7, 2022

the latter, i want to use this externally, as i dont need to rewrite it then ^^
but id understand if you want to keep the API surface clean and small so you can change behaviour more easily.

edit: i mean the first

@troy351
Copy link
Owner

troy351 commented May 8, 2022

So you want to set your own isValidLocationForEmmetAbbreviation, right?
If so, I could add an option to overwrite it.
Maybe expose isValidEmmetToken is a better way since you always need to check it according to tokens.

@mhsdesign
Copy link
Author

sorry my previous answer was missleading, i mistyped - i meant:

That i want to use it in a custom completion provider. (Im using your emmet simutaneosly so i thought this package might as well properly expose: isValidLocationForEmmetAbbreviation )

for more context, this is how im planning to use it:

import { isValidLocationForEmmetAbbreviation } from "emmet-monaco-es/src/abbreviationActions";

monaco.languages.registerCompletionItemProvider(languageId, {
    provideCompletionItems(model, position) {
        if (
            !isValidLocationForEmmetAbbreviation(
                model,
                position,
                "html",
                "html"
            )
        ) {
            return;
        }        

        return myCustomSuggestion(...);
}

@troy351
Copy link
Owner

troy351 commented May 8, 2022

Oh, so the first one is what you want

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

2 participants