Skip to content

Commit

Permalink
fix(vscode): hover message, formatting and highlighting (#1771)
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX authored Jul 21, 2024
1 parent b326b3f commit d8e3a32
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 52 deletions.
7 changes: 3 additions & 4 deletions packages/vscode/language-server/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { fileURLToPath } from 'node:url'
import { createConnection, createServer, createSimpleProject } from '@volar/language-server/node'
import { create as createYamlService } from './volar-service-yaml'
import { slidevLanguagePlugin } from './languagePlugin'
Expand All @@ -17,7 +16,7 @@ connection.onInitialize((params) => {
return {
completion: true,
customTags: [],
format: true,
format: false,
hover: true,
isKubernetes: false,
validate: true,
Expand All @@ -28,12 +27,12 @@ connection.onInitialize((params) => {
{
priority: 3,
fileMatch: ['volar-embedded-content://frontmatter_0/**/*.md'],
uri: fileURLToPath(new URL('../schema/headmatter.json', import.meta.url)),
uri: (new URL('../schema/headmatter.json', import.meta.url)).toString(),
},
{
priority: 2,
fileMatch: ['volar-embedded-content://**/*.md'],
uri: fileURLToPath(new URL('../schema/frontmatter.json', import.meta.url)),
uri: (new URL('../schema/frontmatter.json', import.meta.url)).toString(),
},
],
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode/language-server/languagePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function* getEmbeddedCodes(parsed: SlidevMarkdown): Generator<VirtualCode> {
semantic: true,
navigation: true,
structure: true,
format: true,
format: false,
},
}],
embeddedCodes: [],
Expand Down
7 changes: 7 additions & 0 deletions packages/vscode/language-server/prettierService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ export function create() {
prettier,
{
documentSelector: ['yaml'],
async getFormattingOptions(_prettier, _document, formatOptions) {
return {
parser: 'yaml',
tabWidth: formatOptions.tabSize,
useTabs: !formatOptions.insertSpaces,
}
},
},
)
}
36 changes: 25 additions & 11 deletions packages/vscode/schema/frontmatter.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"type": "null"
}
],
"description": "Page transition, powered by Vue's `<TransitionGroup/>`\n\nBuilt-in transitions:\n- fade\n- fade-out\n- slide-left\n- slide-right\n- slide-up\n- slide-down\n\nSee https://sli.dev/guide/animations.html#pages-transitions\n\nSee https://vuejs.org/guide/built-ins/transition.html"
"description": "Page transition, powered by Vue's `<TransitionGroup/>`\n\nBuilt-in transitions:\n- fade\n- fade-out\n- slide-left\n- slide-right\n- slide-up\n- slide-down\n\nSee https://sli.dev/guide/animations.html#pages-transitions\n\nSee https://vuejs.org/guide/built-ins/transition.html",
"markdownDescription": "Page transition, powered by Vue's `<TransitionGroup/>`\n\nBuilt-in transitions:\n- fade\n- fade-out\n- slide-left\n- slide-right\n- slide-up\n- slide-down\n\nSee https://sli.dev/guide/animations.html#pages-transitions\n\nSee https://vuejs.org/guide/built-ins/transition.html"
},
"layout": {
"anyOf": [
Expand All @@ -31,7 +32,8 @@
"type": "string"
}
],
"description": "Slide layout to use\n\nDefault to 'cover' for the first slide, 'default' for the rest"
"description": "Slide layout to use\n\nDefault to 'cover' for the first slide, 'default' for the rest",
"markdownDescription": "Slide layout to use\n\nDefault to 'cover' for the first slide, 'default' for the rest"
},
"class": {
"anyOf": [
Expand All @@ -49,45 +51,55 @@
"additionalProperties": {}
}
],
"description": "Custom class added to the slide root element"
"description": "Custom class added to the slide root element",
"markdownDescription": "Custom class added to the slide root element"
},
"clicks": {
"type": "number",
"description": "Manually specified the total clicks needed to this slide\n\nWhen not specified, the clicks will be calculated by the usage of v-clicks\n\nSee https://sli.dev/guide/animations"
"description": "Manually specified the total clicks needed to this slide\n\nWhen not specified, the clicks will be calculated by the usage of v-clicks\n\nSee https://sli.dev/guide/animations",
"markdownDescription": "Manually specified the total clicks needed to this slide\n\nWhen not specified, the clicks will be calculated by the usage of v-clicks\n\nSee https://sli.dev/guide/animations"
},
"clicksStart": {
"type": "number",
"description": "Manually specified the total clicks needed to this slide to start",
"markdownDescription": "Manually specified the total clicks needed to this slide to start",
"default": 0
},
"preload": {
"type": "boolean",
"description": "Preload the slide when the previous slide is active",
"markdownDescription": "Preload the slide when the previous slide is active",
"default": true
},
"hide": {
"type": "boolean",
"description": "Completely hide and disable the slide"
"description": "Completely hide and disable the slide",
"markdownDescription": "Completely hide and disable the slide"
},
"disabled": {
"type": "boolean",
"description": "Same as `hide`, completely hide and disable the slide"
"description": "Same as `hide`, completely hide and disable the slide",
"markdownDescription": "Same as `hide`, completely hide and disable the slide"
},
"hideInToc": {
"type": "boolean",
"description": "hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc"
"description": "hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc",
"markdownDescription": "hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc"
},
"level": {
"type": "number",
"description": "Override the title level for the <TitleRenderer> and <Toc> components Only if `title` has also been declared"
"description": "Override the title level for the <TitleRenderer> and <Toc> components Only if `title` has also been declared",
"markdownDescription": "Override the title level for the <TitleRenderer> and <Toc> components\nOnly if `title` has also been declared"
},
"routeAlias": {
"type": "string",
"description": "Create a route alias that can be used in the URL or with the <Link> component"
"description": "Create a route alias that can be used in the URL or with the <Link> component",
"markdownDescription": "Create a route alias that can be used in the URL or with the <Link> component"
},
"zoom": {
"type": "number",
"description": "Custom zoom level for the slide",
"markdownDescription": "Custom zoom level for the slide",
"default": 1
},
"dragPos": {
Expand All @@ -98,11 +110,13 @@
"type": "string"
}
},
"description": "Store the positions of draggable elements Normally you don't need to set this manually\n\nSee https://sli.dev/features/draggable"
"description": "Store the positions of draggable elements Normally you don't need to set this manually\n\nSee https://sli.dev/features/draggable",
"markdownDescription": "Store the positions of draggable elements\nNormally you don't need to set this manually\n\nSee https://sli.dev/features/draggable"
},
"src": {
"type": "string",
"description": "Includes a markdown file\n\nSee https://sli.dev/guide/syntax.html#importing-slides"
"description": "Includes a markdown file\n\nSee https://sli.dev/guide/syntax.html#importing-slides",
"markdownDescription": "Includes a markdown file\n\nSee https://sli.dev/guide/syntax.html#importing-slides"
}
}
},
Expand Down
Loading

0 comments on commit d8e3a32

Please sign in to comment.