Skip to content

Commit bd21542

Browse files
committed
fix: only match tutorialkit content and meta files
1 parent 9bf2156 commit bd21542

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

extensions/vscode/src/language-server/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,7 @@ connection.onInitialize((params) => {
2525
{
2626
uri: 'https://tutorialkit.dev/reference/configuration',
2727
schema,
28-
fileMatch: [
29-
'**/*',
30-
31-
// TODO: these don't work
32-
'src/content/*.md',
33-
'src/content/**/*.md',
34-
'src/content/**/*.mdx',
35-
],
28+
fileMatch: ['volar-embedded-content://tutorialkit_frontmatter/**/*'],
3629
priority: SchemaPriority.Settings,
3730
},
3831
],

extensions/vscode/src/language-server/languagePlugin.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import { CodeMapping, type LanguagePlugin, type VirtualCode } from '@volar/language-core';
22
import type * as ts from 'typescript';
33
import type { URI } from 'vscode-uri';
4+
import { FILES_FOLDER, SOLUTION_FOLDER } from '../models/tree/constants';
45

5-
export function frontmatterPlugin(debug: (message: string) => void): LanguagePlugin<URI> {
6+
export function frontmatterPlugin(_debug: (message: string) => void): LanguagePlugin<URI> {
67
return {
78
getLanguageId(uri) {
8-
debug('URI: ' + uri.path);
9+
// only match markdown files inside the src/content/tutorial folder
10+
if (!uri.path.match(/.*src\/content\/tutorial\/.*(content|meta)\.mdx?$/)) {
11+
return undefined;
12+
}
13+
14+
// but ignore all files under _files or _solution
15+
if (uri.path.includes(FILES_FOLDER) || uri.path.includes(SOLUTION_FOLDER)) {
16+
return undefined;
17+
}
918

1019
if (uri.path.endsWith('.md')) {
1120
return 'markdown';
@@ -74,7 +83,7 @@ function* frontMatterCode(snapshot: ts.IScriptSnapshot): Generator<VirtualCode>
7483
const frontMatterText = content.substring(frontMatterStartIndex, frontMatterEndIndex);
7584

7685
yield {
77-
id: 'frontmatter_1',
86+
id: 'tutorialkit_frontmatter',
7887
languageId: 'yaml',
7988
snapshot: {
8089
getText: (start, end) => frontMatterText.slice(start, end),

0 commit comments

Comments
 (0)