Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Add code snippets #8

Open
1 of 3 tasks
jonas-jonas opened this issue Jan 15, 2019 · 6 comments
Open
1 of 3 tasks

Add code snippets #8

jonas-jonas opened this issue Jan 15, 2019 · 6 comments
Assignees
Labels
area:dart-analyzer Anything related to the dart language server feature

Comments

@jonas-jonas
Copy link
Contributor

jonas-jonas commented Jan 15, 2019

There should be code snippets for the following actions:

  • Constructor
  • function/method
  • import?
@jonas-jonas jonas-jonas self-assigned this Jul 9, 2019
@jonas-jonas jonas-jonas added the area:dart-analyzer Anything related to the dart language server label Aug 1, 2019
@jonas-jonas
Copy link
Contributor Author

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

@mickaelistria
Copy link

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?

@jonas-jonas
Copy link
Contributor Author

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;
...

@mickaelistria
Copy link

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

@jonas-jonas
Copy link
Contributor Author

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

@jonas-jonas
Copy link
Contributor Author

I submitted dart-lang/sdk#37831.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:dart-analyzer Anything related to the dart language server feature
Projects
None yet
Development

No branches or pull requests

2 participants