-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
TSServer: snippet completions #25207
Comments
I imagine that the snippet type could similar to interface Snippet {
parts: SnippetPart[];
}
type SnippetPart = SnippetText | SnippetPlaceholder;
interface SnippetText {
kind: 'text'
text: string
}
interface SnippetPlaceholder {
kind: 'placeholder'
text: string
} For completions, the snippet could be new optional additional field on |
Another possible use case that we discussed: refactorings such as extract constant. We currently implement this by triggering a rename after the extraction but a snippet could be a better fit. Example: const three = 1 + 2; Run extract constant on const «newLocal» = 2
const three = 1 + «newLocal»; Typing would update both locations (Note that VS Code's api would not support this currently since the placeholders are at unconnected locations in the file) |
but is not that what rename does today? |
Another possible use case: generate complete method signature when overriding a method in a subclass microsoft/vscode#46038 |
TS added support for snippet completions in VS Code with #43149 using snippet text syntax supported by VS Code and LSP. I don’t think any other protocol changes are needed, but correct me if I’m missing something @mjbvz. I think the task now is just to implement one or two of the most compelling use cases for snippets. Planning to start with #38891 and investigate #40700. |
Yes I'll can close this since these already snuck in :) |
Provide a generic, cross editor snippet type that can be used to express complex text insertion operations. At a minimum, these snippets should include placeholder values and indicate where the cursor should end up.
For example, snippets could fill in function call arguments with placeholders. If the user completes
ad
toadd
here:The inserted snippet would be:
Where the user can tab from the placeholder values
«x»
to«y».
Use Cases
useCodeSnippetsOnMethodSuggest
)Why is this needed
Snippets speed up coding and provide additional hints while writing code. VS Code already tries to convert TS's existing response types to snippets but fails to handle many edge cases. In order to improve reliability and support more advanced used cases such as microsoft/vscode#48562, I believe that TS needs to start generating these snippets directly
The text was updated successfully, but these errors were encountered: