Skip to content

Commit 1466230

Browse files
authored
Adds a dedicated markdoc language id (#4)
* Adds a dedicated markdoc language id * Updates vsce dependency
1 parent 4932167 commit 1466230

File tree

8 files changed

+175
-124
lines changed

8 files changed

+175
-124
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ The JSON configuration file consists of an array of server instance descriptions
5353
- The `routing` property is an optional object that describes your project's routing configuration
5454
- The `frontmatter` property is a string that tells the extension which property in the Markdoc file's YAML frontmatter contains the URL route associated with the file
5555

56+
### File extensions
57+
58+
In order to distinguish Markdoc files from Markdown files, the Visual Studio Code extension expects Markdoc files to use one of the following file extensions: `.markdoc`, `.markdoc.md`, or `.mdoc`.
59+
60+
It does **not** recognize `.md` files by default. If you would like to still use a `.md` extension, you can instead modify your Visual Studio Code workspace configuration with a custom file association. Add the following content to your `.vscode/settings.json` file:
61+
62+
```
63+
{
64+
"files.associations": {
65+
"*.md": "markdoc"
66+
}
67+
}
68+
```
69+
70+
### Advanced configuration
71+
5672
It is possible to have multiple Markdoc configurations for the same workspace by adding additional configuration objects to the top-level array. This is useful in cases where you have multiple websites with different schemas under different subdirectories of the same workspace. For example, you might want separate configurations for narrative documentation and an API reference.
5773

5874
In [multi-root workspaces](https://code.visualstudio.com/docs/editor/multi-root-workspaces), a Markdoc configuration file is specific to an individual workspace root. You can have separate Markdoc configuration files for each root. If you need to override the location of the Markdoc language server configuration file in a multi-root workspace, you can use a [folder setting](https://code.visualstudio.com/docs/editor/multi-root-workspaces#_settings) to customize this behavior per root.

client/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export default class MarkdocClient implements VSC.Disposable {
9797
const pattern = pathutil.join(fsPath, config.path, "**/*.{md,mdoc}");
9898
const client: LSP.LanguageClientOptions = {
9999
initializationOptions: { config },
100-
documentSelector: [{ language: "markdown", scheme, pattern }],
100+
documentSelector: [{ language: "markdoc", scheme, pattern }],
101101
markdown: { isTrusted: true },
102102
};
103103

client/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export default class Extension {
126126

127127
async onActive(editor?: VSC.TextEditor) {
128128
if (!editor) return;
129-
if (editor.document.languageId !== "markdown") return this.setActive();
129+
if (editor.document.languageId !== "markdoc") return this.setActive();
130130

131131
const { uri } = editor.document;
132132
const client = this.findClient(uri);
@@ -170,7 +170,7 @@ export default class Extension {
170170
const content = new TextDecoder().decode(raw);
171171
const doc = await VSC.workspace.openTextDocument({
172172
content,
173-
language: "markdown",
173+
language: "markdoc",
174174
});
175175

176176
VSC.window.showTextDocument(doc);

0 commit comments

Comments
 (0)