dartboard
dartboard copied to clipboard
Add code snippets
There should be code snippets for the following actions:
- [ ] Constructor
- [ ] function/method
- [x] import?
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
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?
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;
...
Yes, it does support snippets if you use master branch. See
Awesome. Thanks for the clarification. I will see if this is something the LS of Dart might provide then.
I submitted https://github.com/dart-lang/sdk/issues/37831.