-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Doesn't display all language snippets from extensions #70
Comments
That's because they don't list their snippets in extension manifest. They only have this custom configuration, and I did not find any other references to those snippet files: https://github.com/Dart-Code/Dart-Code/blob/master/package.json#L2470 @DanTup please correct me if I am wrong. Snippets viewer is a generic solution and works with most snippet extensions that declare them as described in this doc: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_install-snippets-from-the-marketplace Here is a good example of how snippets should be configured in vscode package extension manifest: https://github.com/softchris/node-snippets/blob/master/package.json#L14 |
User defined snippets docs are here: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets See my user defined snippets release notes for v1.6.0: https://github.com/RandomFractals/vscode-snippets-viewer/releases/tag/v1.6.0 And user defined snippets (#12) and project scoped snippets (#46) for more info. With that said, I am going to close this as invalid since the issue is with the snippets extension not bundling them properly and you need to make sure you follow the setup steps for your own snippets. Those have been well documented and tested by many devs, and work if you have things properly configured per vscode dev team recommendations and snippets docs. |
This is correct. The snippets in VS Code are quite limited - we can't attach contexts to them so that they appear only in some situations. This means if we list them in the manifest, the Flutter ones will appear even when you only have a Dart project open. To fix this, we provide the snippets dynamically based on the loaded project types. In the future, the snippets may more to the language server (to allow more context to be taken into account - eg. don't suggest snippets that create classes if you're already inside a class, as it would be invalid). Hope this makes sense! |
yes, I've seen other code language extensions do that. Bicep for example. So, I am aware of it. I just wanted to provide information why Snippets Viewer would not display them because your snippets config is more dynamic via LSP API and custom, and it would be hard for me to support such use cases without tapping into LSP. However, I do think you can still link them in ext. manifest for static snippet viewers, and your code hint providers can handle the dynamic parts in code editor. Thank you for your clarification and followup! |
If we put them in the manifest, we'd be unable to suppress them in contexts we don't want them show up in. There aren't any snippets that are valid to always show. I did try to get some support for basic contexts in snippets in microsoft/vscode#26943, but was advised to do what I did here. When they move to the server, they'll be even more dynamic (right now, they still show in many incorrect contexts, but I really would like to fix that). |
yeah, sorry, we don't plan to support dynamic snippets with custom configs. Every language I know has some basic code templates that can be created for quick starts. VSCode snippets config is a work in progress as compared to other code template engines I am familiar with. Hopefully they'll work on improving it as more devs start using snippets. That was the primary goal and reason for creating this extension in collaboration with other vscode ext. devs. |
@tnarik btw, have you searched for flutter snippets in vs marketplace? I just installed 2 extensions that provide them for dart and package them properly for devs to use: |
I was using only the basic extensions, and then adding my own templates to use with some libraries (because I didn't see any extension already supporting those libraries, like With Awesome Flutter Snippets now I can see those (because they are properly indicated as Feature Contributions, like you mentioned) plus also my own. Thanks for the tip, I didn't think about that. |
For some reason it is missing the snippets in: https://github.com/Dart-Code/Dart-Code/tree/master/snippets (I have the extension installed), or the User snippet I just created for dart.
I just installed vscode-snippets-viewer a couple of minutes ago, and restarted VS Code. Also checked that
snippets.viewer.skipLanguageSnippets
is empty and I didn't mess anything up.The text was updated successfully, but these errors were encountered: