Repository navigation
feat(completion): offer extensions' snippets - #59
Merged
Merged
Conversation
Extensions ship snippets as data in contributes.snippets, but only the TextMate plugin read them: in TextMate files alone, matched by grammar scope. Snippets for a language the IDE reads itself, or one no grammar names, never showed. Offer them in completion as VS Code's suggest widget does: by language id, in any file, ranked by editor.snippetSuggestions and switched off by editor.suggest.showSnippets. Global snippet files honour scope, include and exclude; variables and their regex transforms expand as in VS Code, and tab stops become a live template. No extension has to be running. In a TextMate file, TextMate's own copy of each snippet is left out of the list so it isn't shown twice. Refs #58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Offers the snippets that extensions contribute through
contributes.snippetsin completion, as VS Code's suggest widget does. Until now only the TextMate plugin read them: in TextMate files alone, and matched by grammar scope. Snippets for a language the IDE reads itself (JavaScript, Java, …), or for a language no grammar names, never showed.contributes.snippets, and reports a bad entry as a manifest problem.ContributedSnippetsgathers each enabled extension's snippet files for a file's language id. It uses the id the extension host holds the file under, or else the one an extension or VS Code gives its name. Snippets are package data, so no extension has to be running.SnippetFilereads VS Code's format.prefix,bodyanddescriptionmay each be a string or a list. In a global file, each snippet'sscopeapplies, andincludeandexcludeglobs apply everywhere.SnippetVariablesandSnippetTransformexpand VS Code's variables, including/regex/format/flagstransforms with/upcase,/camelcase,:+,:?and:-. Tab stops become a live template throughSnippets, which CodeBridge already uses for snippets in language-server completion items.CodeBridgeSnippetCompletionis registered for every language. It ranks snippets byeditor.snippetSuggestionsand hides them wheneditor.suggest.showSnippetsis off.CodeBridgeTextMateSnippetskeeps TextMate's own copy of each snippet out of the list in TextMate files, so a snippet isn't shown twice.Fixes #58
How it was tested
SnippetFileTest,SnippetCompletionTest,CodeBridgeTextMateSnippetsTest, plus additions toSnippetsTestandVsixManifestParserTest. The test extensiontextmate-extensionnow contributes aprobeblocksnippet for them.masterhas changedVsixManifestand its parser. The commit applies to the currentmasterwithout conflicts, but the tests haven't been run on that combination. CI will run them.SplitModeSnippetsTest: a contributed snippet completes in the split-mode client and Tab walks its stops. It passed under WSL/Xvfb..gofile. The backend and frontend logs showed no errors from the snippet code. They did show one unrelated problem: the TextMate plugin fails to compile the Go extension'sindentationRules, a JavaScript regex with a bare{, withjava.util.regex. That comes from registering extensions as TextMate bundles, which predates this change.Checklist
@ApiStatus.Obsolete.)docs/is updated where behaviour changed,docs/status.mdespecially.Third-party material keeps its notice and is listed inNo third-party material added.NOTICE.md.