Open mhsdesign opened 2 years ago
Does VS Code supports feature like this? If not, I'm afraid you need to figure it out yourself
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;
}
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?
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
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.
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(...);
}
Oh, so the first one is what you want
I'm working with a Html(Xml) and Jsx like DSL The problem is that elements support a dot in their name like:
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? )