-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Support custom snippets in new Emmet #29146
Comments
Yes with v1.14.0, there is improvements but as you said, our custom emmet snippets are not honored with Example: "css": {
"snippets": {
"!": "!important;",
"bxsh:h": "box-shadow:${1:inset }${2:hoff} ${3:voff} ${4:blur} ${5:spread }hsl(${6:0}, ${7:100}%, ${8:50}%);",
"bxsh:ha": "box-shadow:${1:inset }${2:h} ${3:v} ${4:blur} ${5:spread }hsla(${6:0}, ${7:100}%, ${8:50}%, ${9:1});",
"c:h": "color:hsl(${1:0}, ${2:100}%, ${3:50}%);",
"c:ha": "color:hsla(${1:0}, ${2:100}%, ${3:50}%, ${4:1});",
"tsh:h": "text-shadow:${1:h} ${2:v} ${3:blur} hsl(${4:0}, ${5:100}%, ${6:50}%);"
}
} One can not use "c:r": "color:rgb(${1:0}, ${2:0}, ${3:0});",
"c:ra": "color:rgba(${1:0}, ${2:0}, ${3:0}, .${4:5});" But we can still use Code built-in snippets feature for that 😉 Maybe it's time to convert my emmet snippets to the built-in one. |
Yes please. There is no good way to do this in the new emmet model until @sergeche comes up with a plan on how he wants to do this. So chances are we are going to ask our users to use vscode custom snippets instead of the emmet custom snippets |
Old CSS snippets are mostly the same as new ones: https://github.com/emmetio/snippets/blob/master/css.json Except that |
The limitations I see with vscode custom snippets are: how can we share a common snippets file across multiple language instead of duplicating snippets for each one? (php, html, etc.) Am I clear about this issue? |
@freMea I believe there is an open issue for that |
Done! It needed a little work as in we can't simply pass the snippets json directly as we did before. @freMea You will have to update the abbreviation for your snippets in the following way
|
@sergeche When Say user has configured snippets for css. The editor creates a registry for "css" with these snippets and passes to For this to work, editor needs to maintain the inheritance hierarchy. Anyway, we can have this logic in the |
Basically, both Instead, I’m moving all syntax detection logic away from Emmet into editor plugin implementation but provide easy way to use different snippet sets. For example, in VS Code you can use scope-based snippet definitions like
Then you can collect all matching snippet sets for current scope and simply |
Done! |
@freMea Can you try your snippets (after removing the Your css ones will work in css files in current Insiders |
Note to verifier: Set up steps:
The custom snippets added for html and css should show up in html, jade,haml and css,scss,less respectively. |
@ramya-rao-a I can't get it to work, my snippet.json is: {
"css": {
"filters": "css",
"profile": "css",
"snippets": {
"emmettest": "emmettest url(|);"
}
}
}
|
It works inside css rules. It doesn't work for html. |
Verified in master, will confirm with the next build. |
#29146 (comment) is fixed with |
@ramya-rao-a said:
Here is a sample emmet snippets file, using last insider (08-03) : {
"variables": {
"charset": "UTF-8",
"indentation": "\t",
"lang": "fr",
"locale": "fr-FR",
"newline": "\n"
},
"css": {
"filters": "css",
"profile": "css",
"snippets": {
"!": "!important;",
"bxshh": "box-shadow:${1:inset }${2:hoff} ${3:voff} ${4:blur} ${5:spread }hsl(${6:0}, ${7:100}%, ${8:50}%);",
"ch": "color:hsl(${1:0}, ${2:100}%, ${3:50}%);",
"comsec": "/*=============================================${newline}= @${1:SectionCommentBlock} =${newline}=============================================*/${newline}${newline}${newline}/*===== End of ${1:SectionCommentBlock} =====*/",
"comsub": "/* ---- @@${1:SubSectionComment} ---- */"
}
}
} The funny thing is it works for some, doesn't for others, and add trailing
Emmet snippets that work in CSS work in Less or Sass, as you said. But user CSS snippets using the built-in Code engine don't. Is there a way to map a syntax snippets to other file type? (#13182 ?) |
@freMea
I believe what @sergeche was going for here is that if your snippet is of the form Logged #32013 for that.
They do work if you explicitly run the I have my work cut out documenting all of this ... |
@ramya-rao-a thanks for the enlightenment. |
@freMea
I am finding it hard to decipher if that was sarcasm or genuine.... :)
I spent some time thinking about the extra I initially thought that I could strip out the extra But now, I am leaning towards not doing that and have users update their snippets to not include the Reason: Custom snippets defined for css get used for scss, sass and other flavors of stylesheets. Therefore, having the custom snippets not include the trailing Makes sense? |
Yes it makes sense. No sarcasm at all. You provided me info on undocumented points that I could not guess if they were by designed or not. You made clear what is was not. I'm always genuine. If I find my words ambiguous before posting, I rephrase or add emoticon. |
@freMea thanks for clarifying :) I must have had my cynical hat on. Hence the confusion. |
With ac60143 the
snippets.json
file fromemmet.extensionsPath
is now read and used by new emmetBut since the new emmet modules do not use old style snippets, only the
variables
section of thesnippets.json
file is used.This issue is to track the possibility of having custom snippets in the new emmet as well
The text was updated successfully, but these errors were encountered: