Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(extensions): register commands and providers also for MDX files #173

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion extensions/vscode-twoslash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"Linters"
],
"activationEvents": [
"onLanguage:markdown"
"onLanguage:markdown",
"onLanguage:mdx"
],
"contributes": {
},
Expand Down
6 changes: 3 additions & 3 deletions extensions/vscode-twoslash/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function activate(context: vscode.ExtensionContext) {

// Provides the buttons
const codelens = new SnapshotCodeLensProvider(runner)
const codelensD = vscode.languages.registerCodeLensProvider({ pattern: '**/*.md' }, codelens)
const codelensD = vscode.languages.registerCodeLensProvider({ pattern: "**/*.{md,mdx}" }, codelens);

// So that a runner can tell the code actions to update after a run
runner.codeLensDidChange = codelens.onDidChange
Expand Down Expand Up @@ -69,7 +69,7 @@ export function activate(context: vscode.ExtensionContext) {
});

// Provides a hover with the full info for exceptions
const hoverDispose = vscode.languages.registerHoverProvider('markdown', {
const hoverDispose = vscode.languages.registerHoverProvider(['markdown', 'mdx'], {
provideHover(document, position, token) {
const char = document.offsetAt(position)
const codeblock = runner.stateForSampleAtPosition(char)
Expand All @@ -88,7 +88,7 @@ export function activate(context: vscode.ExtensionContext) {


// Provides a hover with the full info for exceptions
const completionDispose = vscode.languages.registerCompletionItemProvider('markdown', {
const completionDispose = vscode.languages.registerCompletionItemProvider(['markdown', 'mdx'], {
provideCompletionItems: (document, position, cancel, context) => {

const results: vscode.CompletionItem[] = []
Expand Down