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

Provide settings to disable snippets in completion lists #2625

Closed
svipas opened this issue Jul 9, 2020 · 4 comments
Closed

Provide settings to disable snippets in completion lists #2625

svipas opened this issue Jul 9, 2020 · 4 comments
Labels
in editor Relates to code editing or language features is enhancement
Milestone

Comments

@svipas
Copy link

svipas commented Jul 9, 2020

As I can see you have this class https://github.com/Dart-Code/Dart-Code/blob/684a3ad5f15529e507139f95b9617240ec20a56a/src/extension/providers/snippet_completion_item_provider.ts which registers snippets to the completion provider. And you're using snippets/dart.json and snippets/flutter.json in here

// Snippets are language-specific
. In my opinion this is redundant because VS Code handles snippets automatically if you add them into package.json file like this:

		"snippets": [
			{
				"language": "dart",
				"path": "./snippets/dart.json"
			},
			{
				"language": "dart",
				"path": "./snippets/flutter.json"
			}
		]

The issue with registering them inside extension itself by using completion provider removes ability to use Control Snippets extension which gives ability to disable/enable snippets.

My suggestions is to simply remove SnippetCompletionItemProvider class and also registration in extension.ts for flutter and dart snippets and simply add snippets in package.json as mentioned above. This gives ability to easy control snippets and it uses default VS Code mechanism.

Also, it would be cool to separate snippets for dart and flutter into their repos/extension dirs. Keep snippets/dart.json in this repo https://github.com/Dart-Code/Dart-Code and move snippets/flutter.json to this repo https://github.com/Dart-Code/Flutter since they are different tools and it gives ability to easily disable/enable snippets for Dart and Flutter separately.

I hope it makes sense, if needed I could provide a PR. Thanks a lot!

@DanTup
Copy link
Member

DanTup commented Jul 11, 2020

That's how things used to be - however the built-in snippets cannot be dynamically filtered, which means once you have the Flutter extension installed, you would always get Flutter snippets in your (non-Flutter) Dart projects. I did request support from VS Code to handle this (microsoft/vscode#26943) but it was rejected and were told to do it this way.

I don't think it would be a good change to go back to that unless VS code provides some way for us to filter them. Also - FWIW, that extension works by manipulating the package.json file of installed extensions - that's not really an intended extension point and could have unintended side effects, so I'm not sure it makes sense to make changes to support/encourage that.

@svipas
Copy link
Author

svipas commented Jul 11, 2020

If thats not an option, maybe you could add config which enables/disables these snippets?

@DanTup
Copy link
Member

DanTup commented Jul 11, 2020

Yeah, that seems reasonable enough!

@DanTup DanTup changed the title Exclude snippets from completion provider and use default VS Code mechanism Provide settings to disable snippets in completion lists Jul 11, 2020
@DanTup DanTup added this to the v3.13.0 milestone Jul 11, 2020
@DanTup DanTup added in editor Relates to code editing or language features is enhancement labels Jul 11, 2020
@svipas
Copy link
Author

svipas commented Jul 12, 2020

Thanks!

@DanTup DanTup closed this as completed in 86956ce Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features is enhancement
Projects
None yet
Development

No branches or pull requests

2 participants