feat: add shortcode completion provider#256
Merged
Conversation
Add a shortcode parser (shortcodeParser.ts) that tokenises Quarto
shortcode syntax ({{< name key="value" >}}) and determines cursor
context for driving completions.
Add a completion provider (shortcodeCompletionProvider.ts) that uses
SchemaCache to discover shortcode schemas from installed extensions
and offers contextual completions for shortcode names, attribute
keys, and attribute values.
Register the provider in extension.ts for the quarto language ID
with space, =, and < as trigger characters.
Include Mocha tests for the shortcode parser covering bounds
detection, cursor context identification, and various edge cases.
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
src/utils/shortcodeParser.ts) that tokenises Quarto{{< name key="value" >}}syntax and determines cursor context (name, argument, attribute key, or attribute value).src/providers/shortcodeCompletionProvider.ts) that discovers shortcode schemas from installed extensions viaSchemaCacheand offers contextual completions for shortcode names, attribute keys, and attribute values.src/extension.tsfor thequartolanguage ID with space,=, and<as trigger characters.src/test/suite/shortcodeParser.test.ts) covering bounds detection, cursor context identification, quoted/unquoted values, multiline shortcodes, and edge cases.Test plan
npm run test.npx tsc --noEmit..qmdfile with installed extensions that have_schema.ymlcontaining shortcode definitions, type{{<and confirm shortcode name completions appear.key=, confirm attribute value completions appear for enum-typed attributes.