Skip to content

feat: add extension-provided code snippets#279

Merged
mcanouil merged 8 commits intomainfrom
feat/extension-snippets
Feb 19, 2026
Merged

feat: add extension-provided code snippets#279
mcanouil merged 8 commits intomainfrom
feat/extension-snippets

Conversation

@mcanouil
Copy link
Copy Markdown
Owner

@mcanouil mcanouil commented Feb 19, 2026

Summary

  • Create @quarto-wizard/snippets package with types, parsing, validation, and caching for _snippets.json files (following the @quarto-wizard/schema extraction pattern).
  • Add SnippetCompletionProvider for Quarto document IntelliSense with namespace-qualified prefixes (e.g. mcanouil-iconify:iconify).
  • Add Snippets/SnippetsError/SnippetItem tree view nodes under each extension in the explorer view.
  • Add file watcher for _snippets.json create/change/delete with cache invalidation.
  • Add activation event for workspaces containing _extensions/**/_snippets.json.
  • Add snippets package to CI build/test workflows and release assets.

Test plan

  • packages/snippets builds without errors (npm run build).
  • 32 unit tests pass (npm test in packages/snippets).
  • Extension webpack build succeeds (npm run webpack).
  • ESLint passes with zero warnings (npm run lint).
  • Prettier formatting check passes (npm run format:check).
  • TypeScript compilation succeeds (tsc -p ./).
  • Manual test: place _snippets.json in a test extension, open a .qmd file, verify snippet completions appear.
  • Manual test: expand extension in tree view, verify "Snippets" node with correct count and items.
  • Manual test: modify/delete _snippets.json, verify tree view refreshes.

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
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.
@mcanouil mcanouil merged commit fcd340b into main Feb 19, 2026
7 checks passed
@mcanouil mcanouil deleted the feat/extension-snippets branch February 19, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Enhancement 💡 Issues related to enhancements, improvements, new features, or new analyses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant