Skip to content

feat(completion): offer extensions' snippets - #59

Merged
BartvHelvert merged 1 commit into
masterfrom
feat/contributed-snippets
Nov 4, 2026
Merged

BartvHelvert merged 1 commit into
masterfrom
feat/contributed-snippets

Conversation

@BartvHelvert

Copy link
Copy Markdown
Owner

What this changes

Offers the snippets that extensions contribute through contributes.snippets in 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.

  • The manifest parser reads contributes.snippets, and reports a bad entry as a manifest problem.
  • ContributedSnippets gathers 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.
  • SnippetFile reads VS Code's format. prefix, body and description may each be a string or a list. In a global file, each snippet's scope applies, and include and exclude globs apply everywhere.
  • SnippetVariables and SnippetTransform expand VS Code's variables, including /regex/format/flags transforms with /upcase, /camelcase, :+, :? and :-. Tab stops become a live template through Snippets, which CodeBridge already uses for snippets in language-server completion items.
  • CodeBridgeSnippetCompletion is registered for every language. It ranks snippets by editor.snippetSuggestions and hides them when editor.suggest.showSnippets is off.
  • CodeBridgeTextMateSnippets keeps 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

  • New tests: SnippetFileTest, SnippetCompletionTest, CodeBridgeTextMateSnippetsTest, plus additions to SnippetsTest and VsixManifestParserTest. The test extension textmate-extension now contributes a probeblock snippet for them.
  • The full unit test suite passed (227 suites) on this branch's base. Since then, master has changed VsixManifest and its parser. The commit applies to the current master without conflicts, but the tests haven't been run on that combination. CI will run them.
  • New UI test SplitModeSnippetsTest: a contributed snippet completes in the split-mode client and Tab walks its stops. It passed under WSL/Xvfb.
  • Used completion in a split-mode sandbox with the Go extension installed, in a .go file. 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's indentationRules, a JavaScript regex with a bare {, with java.util.regex. That comes from registering extensions as TextMate bundles, which predates this change.

Checklist

  • Nothing is special-cased for one extension.
  • A new feature has a UI test.
  • No internal, override-only, obsolete or deprecated platform API. (Not checked with a bytecode scan against the platform jars. The verifier and kotlinc don't flag @ApiStatus.Obsolete.)
  • docs/ is updated where behaviour changed, docs/status.md especially.
  • Third-party material keeps its notice and is listed in NOTICE.md. No third-party material added.

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
@BartvHelvert
BartvHelvert merged commit 4781ccf into master Nov 4, 2026
6 checks passed
@BartvHelvert
BartvHelvert deleted the feat/contributed-snippets branch November 4, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offer extensions' contributed snippets in completion

1 participant