feat: add extension-provided code snippets#279
Merged
Conversation
Add support for extensions to ship code snippets via _snippets.json files, making them available through IntelliSense in Quarto documents. - Create @quarto-wizard/snippets package with types, parsing, validation, and caching (following the @quarto-wizard/schema extraction pattern) - Add SnippetCompletionProvider for Quarto document IntelliSense - Add Snippets tree view nodes under each extension in the explorer - Add file watcher for _snippets.json changes - Add activation event for workspaces containing snippet files - Add snippets package to CI build/test and release workflows - Add test fixture with array-prefix test case
This was referenced Feb 19, 2026
Strengthen isValidSnippetEntry to reject empty prefix arrays and arrays containing non-string values for both prefix and body fields.
- Add ":" trigger character so completions re-trigger after namespace separator (F1). - Use document.lineAt instead of document.getText for mid-token check (F2). - Reject empty body arrays in isValidSnippetEntry (F4). - Add SnippetError.format() tests (F11). - Add readSnippets error propagation test (F13). - Remove unused vi import from snippets test.
Improve the SnippetCache class to handle missing snippet directories by caching them until invalidated. Add tests to verify the behaviour of caching and handling blank lines in snippet bodies.
Wire SnippetItemTreeItem click and context menu to insert the snippet body at the active editor cursor position using VS Code's snippet API. - Store SnippetDefinition on tree item and set command for click - Register insertSnippet command handler (accepts both tree item and plain definition for serialisation compatibility) - Declare command, inline/context menus, and commandPalette in package.json - Add unit tests for tree item properties and snippet insertion
- Guard against undefined arg in insertSnippet command handler. - Validate description field type in isValidSnippetEntry. - Add test for parseSnippetFile with non-existent path. - Add tests for invalidateAll() clearing missing and error entries. - Add test for non-string description rejection.
Windows uses \r\n line endings in VS Code editors, causing the multi-line snippet insertion test to fail on CI.
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.
Summary
@quarto-wizard/snippetspackage with types, parsing, validation, and caching for_snippets.jsonfiles (following the@quarto-wizard/schemaextraction pattern).SnippetCompletionProviderfor Quarto document IntelliSense with namespace-qualified prefixes (e.g.mcanouil-iconify:iconify)._snippets.jsoncreate/change/delete with cache invalidation._extensions/**/_snippets.json.Test plan
packages/snippetsbuilds without errors (npm run build).npm testinpackages/snippets).npm run webpack).npm run lint).npm run format:check).tsc -p ./)._snippets.jsonin a test extension, open a.qmdfile, verify snippet completions appear._snippets.json, verify tree view refreshes.