dartboard icon indicating copy to clipboard operation
dartboard copied to clipboard

Add code snippets

Open jonas-jonas opened this issue 6 years ago • 6 comments

There should be code snippets for the following actions:

  • [ ] Constructor
  • [ ] function/method
  • [x] import?

jonas-jonas avatar Jan 15 '19 14:01 jonas-jonas

Does LSP4E support snippets from the language server? If so, it would be nice to implement this in the Dart analysis server instead of rolling our own snippets.

cc @mickaelistria

jonas-jonas avatar Aug 07 '19 09:08 jonas-jonas

I am not sure what is the difference between a code snippet and a completion proposal. Can you please describe in a user-story what you mean by code snippet?

mickaelistria avatar Aug 07 '19 09:08 mickaelistria

I'm talking about https://github.com/Microsoft/language-server-protocol/blob/master/snippetSyntax.md. I might be misunderstanding it though.

Ultimately this would boil down to a user wanting to have the import '' statement written out for him, and then have the cursor placed inside the '' like so: import '<cursor>'. I'm not sure if this is what I'm talking about, because the documentation seems very scarce on the LSP side of things.

This is the LSP spec on this. LSP4E seems to report true on the snippetSupport parameter, but I couldn't find the code for this. Or is it just a generic completionItem?

completion?: {
		/**
		 * Whether completion supports dynamic registration.
		 */
		dynamicRegistration?: boolean;

		/**
		 * The client supports the following `CompletionItem` specific
		 * capabilities.
		 */
		completionItem?: {
			/**
			 * The client supports snippets as insert text.
			 *
			 * A snippet can define tab stops and placeholders with `$1`, `$2`
			 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
			 * the end of the snippet. Placeholders with equal identifiers are linked,
			 * that is typing in one will update others too.
			 */
			snippetSupport?: boolean;
...

jonas-jonas avatar Aug 07 '19 09:08 jonas-jonas

Yes, it does support snippets if you use master branch. See choiceSnippet

mickaelistria avatar Aug 07 '19 09:08 mickaelistria

Awesome. Thanks for the clarification. I will see if this is something the LS of Dart might provide then.

jonas-jonas avatar Aug 07 '19 09:08 jonas-jonas

I submitted https://github.com/dart-lang/sdk/issues/37831.

jonas-jonas avatar Aug 13 '19 11:08 jonas-jonas