Skip to content

Provide settings to disable snippets in completion lists #2625

Closed

Description

@svipas

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!

Activity

  1. DanTup commented on Jul 11, 2020

    @DanTup
    Member

    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.

  2. svipas commented on Jul 11, 2020

    @svipas
    Author

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

  3. DanTup commented on Jul 11, 2020

    @DanTup
    Member

    Yeah, that seems reasonable enough!

  4. changed the title [-]Exclude snippets from completion provider and use default VS Code mechanism[/-] [+]Provide settings to disable snippets in completion lists[/+] on Jul 11, 2020
  5. added this to the v3.13.0 milestone on Jul 11, 2020
  6. added
    in editorRelates to code editing or language features
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Jul 11, 2020
  7. svipas commented on Jul 12, 2020

    @svipas
    Author

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions