From 6ae81296d779c3950d93416b1c9c7a8d23d358fa Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Fri, 9 Jul 2021 11:46:31 -0500 Subject: [PATCH] chore: add mdc to Code extension --- .vscode/launch.json | 4 ++-- examples/with-markdown/astro.config.mjs | 2 +- .../with-markdown/src/components/index.ts | 1 + .../with-markdown/src/components/index.tsx | 1 - .../src/pages/markdown-plus-components.mdc | 2 +- ...n.json => mdc-language-configuration.json} | 0 tools/vscode/package.json | 20 +++++++++++-------- ...wn.tmLanguage.json => mdc.tmLanguage.json} | 13 ++++++++++++ tools/vscode/tsconfig.base.json | 5 +---- 9 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 examples/with-markdown/src/components/index.ts delete mode 100644 examples/with-markdown/src/components/index.tsx rename tools/vscode/languages/{astro-markdown-language-configuration.json => mdc-language-configuration.json} (100%) rename tools/vscode/syntaxes/{astro-markdown.tmLanguage.json => mdc.tmLanguage.json} (99%) diff --git a/.vscode/launch.json b/.vscode/launch.json index 531210a57..208515d31 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,8 +7,8 @@ "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", - "args": ["--extensionDevelopmentPath=${workspaceRoot}/tools/astro-vscode"], - "outFiles": ["${workspaceRoot}/tools/astro-vscode/dist/**/*.js"] + "args": ["--extensionDevelopmentPath=${workspaceRoot}/tools/vscode"], + "outFiles": ["${workspaceRoot}/tools/vscode/dist/**/*.js"] }, { "type": "node", diff --git a/examples/with-markdown/astro.config.mjs b/examples/with-markdown/astro.config.mjs index a6b3bf055..fdb55da6d 100644 --- a/examples/with-markdown/astro.config.mjs +++ b/examples/with-markdown/astro.config.mjs @@ -1,5 +1,5 @@ export default { markdownOptions: { - components: './src/components/index.tsx' + components: './src/components/index.ts' } } diff --git a/examples/with-markdown/src/components/index.ts b/examples/with-markdown/src/components/index.ts new file mode 100644 index 000000000..2361ee4b2 --- /dev/null +++ b/examples/with-markdown/src/components/index.ts @@ -0,0 +1 @@ +export { default as PreactCounter } from './PreactCounter.js'; diff --git a/examples/with-markdown/src/components/index.tsx b/examples/with-markdown/src/components/index.tsx deleted file mode 100644 index 05fe00034..000000000 --- a/examples/with-markdown/src/components/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export { default as PreactCounter } from './PreactCounter.tsx'; diff --git a/examples/with-markdown/src/pages/markdown-plus-components.mdc b/examples/with-markdown/src/pages/markdown-plus-components.mdc index 2272790a1..59501b70e 100644 --- a/examples/with-markdown/src/pages/markdown-plus-components.mdc +++ b/examples/with-markdown/src/pages/markdown-plus-components.mdc @@ -9,4 +9,4 @@ text here. -Hello world! +Hey, this is a demo! diff --git a/tools/vscode/languages/astro-markdown-language-configuration.json b/tools/vscode/languages/mdc-language-configuration.json similarity index 100% rename from tools/vscode/languages/astro-markdown-language-configuration.json rename to tools/vscode/languages/mdc-language-configuration.json diff --git a/tools/vscode/package.json b/tools/vscode/package.json index cb2c6db90..11bfc9c56 100644 --- a/tools/vscode/package.json +++ b/tools/vscode/package.json @@ -77,11 +77,14 @@ "configuration": "./languages/astro-language-configuration.json" }, { - "id": "astro-markdown", - "aliases": [ - "Astro Markdown" + "id": "mdc", + "extensions": [ + ".mdc" ], - "configuration": "./languages/astro-markdown-language-configuration.json" + "aliases": [ + "Markdown + Components" + ], + "configuration": "./languages/mdc-language-configuration.json" } ], "grammars": [ @@ -91,7 +94,7 @@ "path": "./syntaxes/astro.tmLanguage.json", "embeddedLanguages": { "text.html.astro": "astro", - "text.html.markdown.astro": "astro-markdown", + "text.html.markdown.astro": "mdc", "text.html": "html", "source.css": "css", "source.scss": "scss", @@ -101,19 +104,20 @@ } }, { - "language": "astro-markdown", + "language": "mdc", "scopeName": "text.html.markdown.astro", - "path": "./syntaxes/astro-markdown.tmLanguage.json", + "path": "./syntaxes/mdc.tmLanguage.json", "injectTo": [ "text.html.astro" ], "embeddedLanguages": { "text.html.astro": "astro", - "text.html.markdown.astro": "astro-markdown", + "text.html.markdown.astro": "mdc", "text.html.markdown": "markdown", "source.tsx": "typescriptreact", "source.js": "javascript", "source.css": "css", + "meta.embedded.block.frontmatter": "yaml", "meta.embedded.block.css": "css", "meta.embedded.block.astro": "astro", "meta.embedded.block.ini": "ini", diff --git a/tools/vscode/syntaxes/astro-markdown.tmLanguage.json b/tools/vscode/syntaxes/mdc.tmLanguage.json similarity index 99% rename from tools/vscode/syntaxes/astro-markdown.tmLanguage.json rename to tools/vscode/syntaxes/mdc.tmLanguage.json index 7d6b68129..37003cd52 100644 --- a/tools/vscode/syntaxes/astro-markdown.tmLanguage.json +++ b/tools/vscode/syntaxes/mdc.tmLanguage.json @@ -3,6 +3,9 @@ "name": "Astro Markdown", "scopeName": "text.html.markdown.astro", "patterns": [ + { + "include": "#frontMatter" + }, { "include": "#block" }, @@ -11,6 +14,16 @@ } ], "repository": { + "frontMatter": { + "begin": "\\A-{3}\\s*$", + "contentName": "meta.embedded.block.frontmatter", + "patterns": [ + { + "include": "source.yaml" + } + ], + "end": "(^|\\G)-{3}|\\.{3}\\s*$" + }, "astro-expressions": { "patterns": [ { diff --git a/tools/vscode/tsconfig.base.json b/tools/vscode/tsconfig.base.json index 0f560706f..88d1b2c79 100644 --- a/tools/vscode/tsconfig.base.json +++ b/tools/vscode/tsconfig.base.json @@ -9,9 +9,6 @@ "declaration": true, "strict": true, "skipLibCheck": true, - "baseUrl": "./", - "paths": { - "@astro-vscode/*": ["packages/*/src"] - } + "baseUrl": "./" } }