mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Finalize markdown diagnostics (#161427)
Fixes #146303 This moves the markdown diagnostic support out of `experimental` and to an official feature (however it remains off by default)
This commit is contained in:
parent
1fba6ec98a
commit
17bb582b85
|
@ -434,81 +434,63 @@
|
|||
"experimental"
|
||||
]
|
||||
},
|
||||
"markdown.experimental.validate.enabled": {
|
||||
"markdown.validate.enabled": {
|
||||
"type": "boolean",
|
||||
"scope": "resource",
|
||||
"description": "%configuration.markdown.experimental.validate.enabled.description%",
|
||||
"default": false,
|
||||
"tags": [
|
||||
"experimental"
|
||||
]
|
||||
"description": "%configuration.markdown.validate.enabled.description%",
|
||||
"default": false
|
||||
},
|
||||
"markdown.experimental.validate.referenceLinks.enabled": {
|
||||
"markdown.validate.referenceLinks.enabled": {
|
||||
"type": "string",
|
||||
"scope": "resource",
|
||||
"markdownDescription": "%configuration.markdown.experimental.validate.referenceLinks.enabled.description%",
|
||||
"markdownDescription": "%configuration.markdown.validate.referenceLinks.enabled.description%",
|
||||
"default": "warning",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"warning",
|
||||
"error"
|
||||
],
|
||||
"tags": [
|
||||
"experimental"
|
||||
]
|
||||
},
|
||||
"markdown.experimental.validate.fragmentLinks.enabled": {
|
||||
"markdown.validate.fragmentLinks.enabled": {
|
||||
"type": "string",
|
||||
"scope": "resource",
|
||||
"markdownDescription": "%configuration.markdown.experimental.validate.fragmentLinks.enabled.description%",
|
||||
"markdownDescription": "%configuration.markdown.validate.fragmentLinks.enabled.description%",
|
||||
"default": "warning",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"warning",
|
||||
"error"
|
||||
],
|
||||
"tags": [
|
||||
"experimental"
|
||||
]
|
||||
},
|
||||
"markdown.experimental.validate.fileLinks.enabled": {
|
||||
"markdown.validate.fileLinks.enabled": {
|
||||
"type": "string",
|
||||
"scope": "resource",
|
||||
"markdownDescription": "%configuration.markdown.experimental.validate.fileLinks.enabled.description%",
|
||||
"markdownDescription": "%configuration.markdown.validate.fileLinks.enabled.description%",
|
||||
"default": "warning",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"warning",
|
||||
"error"
|
||||
],
|
||||
"tags": [
|
||||
"experimental"
|
||||
]
|
||||
},
|
||||
"markdown.experimental.validate.fileLinks.markdownFragmentLinks": {
|
||||
"markdown.validate.fileLinks.markdownFragmentLinks": {
|
||||
"type": "string",
|
||||
"scope": "resource",
|
||||
"markdownDescription": "%configuration.markdown.experimental.validate.fileLinks.markdownFragmentLinks.description%",
|
||||
"markdownDescription": "%configuration.markdown.validate.fileLinks.markdownFragmentLinks.description%",
|
||||
"default": "ignore",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"warning",
|
||||
"error"
|
||||
],
|
||||
"tags": [
|
||||
"experimental"
|
||||
]
|
||||
},
|
||||
"markdown.experimental.validate.ignoreLinks": {
|
||||
"markdown.validate.ignoredLinks": {
|
||||
"type": "array",
|
||||
"scope": "resource",
|
||||
"markdownDescription": "%configuration.markdown.experimental.validate.ignoreLinks.description%",
|
||||
"markdownDescription": "%configuration.markdown.validate.ignoredLinks.description%",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"tags": [
|
||||
"experimental"
|
||||
]
|
||||
}
|
||||
},
|
||||
"markdown.experimental.updateLinksOnFileMove.enabled": {
|
||||
"type": "string",
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
"configuration.markdown.suggest.paths.enabled.description": "Enable/disable path suggestions for markdown links",
|
||||
"configuration.markdown.editor.drop.enabled": "Enable/disable dropping into the markdown editor to insert shift. Requires enabling `#editor.dropIntoEditor.enabled#`.",
|
||||
"configuration.markdown.editor.pasteLinks.enabled": "Enable/disable pasting files into a Markdown editor inserts Markdown links. Requires enabling `#editor.experimental.pasteActions.enabled#`.",
|
||||
"configuration.markdown.experimental.validate.enabled.description": "Enable/disable all error reporting in Markdown files.",
|
||||
"configuration.markdown.experimental.validate.referenceLinks.enabled.description": "Validate reference links in Markdown files, e.g. `[link][ref]`. Requires enabling `#markdown.experimental.validate.enabled#`.",
|
||||
"configuration.markdown.experimental.validate.fragmentLinks.enabled.description": "Validate fragment links to headers in the current Markdown file, e.g. `[link](#header)`. Requires enabling `#markdown.experimental.validate.enabled#`.",
|
||||
"configuration.markdown.experimental.validate.fileLinks.enabled.description": "Validate links to other files in Markdown files, e.g. `[link](/path/to/file.md)`. This checks that the target files exists. Requires enabling `#markdown.experimental.validate.enabled#`.",
|
||||
"configuration.markdown.experimental.validate.fileLinks.markdownFragmentLinks.description": "Validate the fragment part of links to headers in other files in Markdown files, e.g. `[link](/path/to/file.md#header)`. Inherits the setting value from `#markdown.experimental.validate.fragmentLinks.enabled#` by default.",
|
||||
"configuration.markdown.experimental.validate.ignoreLinks.description": "Configure links that should not be validated. For example `/about` would not validate the link `[about](/about)`, while the glob `/assets/**/*.svg` would let you skip validation for any link to `.svg` files under the `assets` directory.",
|
||||
"configuration.markdown.validate.enabled.description": "Enable/disable all error reporting in Markdown files.",
|
||||
"configuration.markdown.validate.referenceLinks.enabled.description": "Validate reference links in Markdown files, e.g. `[link][ref]`. Requires enabling `#markdown.validate.enabled#`.",
|
||||
"configuration.markdown.validate.fragmentLinks.enabled.description": "Validate fragment links to headers in the current Markdown file, e.g. `[link](#header)`. Requires enabling `#markdown.validate.enabled#`.",
|
||||
"configuration.markdown.validate.fileLinks.enabled.description": "Validate links to other files in Markdown files, e.g. `[link](/path/to/file.md)`. This checks that the target files exists. Requires enabling `#markdown.validate.enabled#`.",
|
||||
"configuration.markdown.validate.fileLinks.markdownFragmentLinks.description": "Validate the fragment part of links to headers in other files in Markdown files, e.g. `[link](/path/to/file.md#header)`. Inherits the setting value from `#markdown.validate.fragmentLinks.enabled#` by default.",
|
||||
"configuration.markdown.validate.ignoredLinks.description": "Configure links that should not be validated. For example adding `/about` would not validate the link `[about](/about)`, while the glob `/assets/**/*.svg` would let you skip validation for any link to `.svg` files under the `assets` directory.",
|
||||
"configuration.markdown.experimental.updateLinksOnFileMove.enabled": "Try to update links in Markdown files when a file is renamed/moved in the workspace. Use `#markdown.experimental.updateLinksOnFileMove.externalFileGlobs#` to configure which files trigger link updates.",
|
||||
"configuration.markdown.experimental.updateLinksOnFileMove.enabled.prompt": "Prompt on each file move.",
|
||||
"configuration.markdown.experimental.updateLinksOnFileMove.enabled.always": "Always update links automatically.",
|
||||
|
|
|
@ -36,7 +36,7 @@ This server uses the [Markdown Language Service](https://github.com/microsoft/vs
|
|||
|
||||
- (experimental) Updating links when a file is moved / renamed. Uses a custom `markdown/getEditForFileRenames` message.
|
||||
|
||||
- (experimental) [Pull diagnostics (validation)](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics) for links.
|
||||
- [Pull diagnostics (validation)](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics) for links.
|
||||
|
||||
|
||||
## Client requirements
|
||||
|
@ -56,17 +56,16 @@ The server supports the following settings:
|
|||
- `suggest`
|
||||
- `paths`
|
||||
- `enabled` — Enable/disable path suggestions.
|
||||
- `experimental`
|
||||
- `validate`
|
||||
- `enabled` — Enable/disable all validation.
|
||||
- `referenceLinks`
|
||||
- `enabled` — Enable/disable validation of reference links: `[text][ref]`
|
||||
- `fragmentLinks`
|
||||
- `enabled` — Enable/disable validation of links to fragments in the current files: `[text](#head)`
|
||||
- `fileLinks`
|
||||
- `enabled` — Enable/disable validation of links to file in the workspace.
|
||||
- `markdownFragmentLinks` — Enable/disable validation of links to headers in other Markdown files.
|
||||
- `ignoreLinks` — Array of glob patterns for files that should not be validated.
|
||||
- `validate`
|
||||
- `enabled` — Enable/disable all validation.
|
||||
- `referenceLinks`
|
||||
- `enabled` — Enable/disable validation of reference links: `[text][ref]`
|
||||
- `fragmentLinks`
|
||||
- `enabled` — Enable/disable validation of links to fragments in the current files: `[text](#head)`
|
||||
- `fileLinks`
|
||||
- `enabled` — Enable/disable validation of links to file in the workspace.
|
||||
- `markdownFragmentLinks` — Enable/disable validation of links to headers in other Markdown files.
|
||||
- `ignoredLinks` — Array of glob patterns for files that should not be validated.
|
||||
|
||||
### Custom requests
|
||||
|
||||
|
|
|
@ -16,21 +16,19 @@ interface Settings {
|
|||
};
|
||||
};
|
||||
|
||||
readonly experimental: {
|
||||
readonly validate: {
|
||||
readonly enabled: true;
|
||||
readonly referenceLinks: {
|
||||
readonly enabled: ValidateEnabled;
|
||||
};
|
||||
readonly fragmentLinks: {
|
||||
readonly enabled: ValidateEnabled;
|
||||
};
|
||||
readonly fileLinks: {
|
||||
readonly enabled: ValidateEnabled;
|
||||
readonly markdownFragmentLinks: ValidateEnabled;
|
||||
};
|
||||
readonly ignoreLinks: readonly string[];
|
||||
readonly validate: {
|
||||
readonly enabled: true;
|
||||
readonly referenceLinks: {
|
||||
readonly enabled: ValidateEnabled;
|
||||
};
|
||||
readonly fragmentLinks: {
|
||||
readonly enabled: ValidateEnabled;
|
||||
};
|
||||
readonly fileLinks: {
|
||||
readonly enabled: ValidateEnabled;
|
||||
readonly markdownFragmentLinks: ValidateEnabled;
|
||||
};
|
||||
readonly ignoredLinks: readonly string[];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -56,4 +54,4 @@ export class ConfigurationManager extends Disposable {
|
|||
public getSettings(): Settings | undefined {
|
||||
return this._settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
import { Connection, FullDocumentDiagnosticReport, TextDocuments, UnchangedDocumentDiagnosticReport } from 'vscode-languageserver';
|
||||
import * as md from 'vscode-markdown-languageservice';
|
||||
import { disposeAll } from 'vscode-markdown-languageservice/out/util/dispose';
|
||||
import { Disposable } from 'vscode-notebook-renderer/events';
|
||||
import { URI } from 'vscode-uri';
|
||||
import { ConfigurationManager, ValidateEnabled } from '../configuration';
|
||||
import { disposeAll } from '../util/dispose';
|
||||
|
||||
const defaultDiagnosticOptions: md.DiagnosticOptions = {
|
||||
validateFileLinks: md.DiagnosticLevel.ignore,
|
||||
|
@ -34,11 +34,11 @@ function getDiagnosticsOptions(config: ConfigurationManager): md.DiagnosticOptio
|
|||
}
|
||||
|
||||
return {
|
||||
validateFileLinks: convertDiagnosticLevel(settings.markdown.experimental.validate.fileLinks.enabled),
|
||||
validateReferences: convertDiagnosticLevel(settings.markdown.experimental.validate.referenceLinks.enabled),
|
||||
validateFragmentLinks: convertDiagnosticLevel(settings.markdown.experimental.validate.fragmentLinks.enabled),
|
||||
validateMarkdownFileLinkFragments: convertDiagnosticLevel(settings.markdown.experimental.validate.fileLinks.markdownFragmentLinks),
|
||||
ignoreLinks: settings.markdown.experimental.validate.ignoreLinks,
|
||||
validateFileLinks: convertDiagnosticLevel(settings.markdown.validate.fileLinks.enabled),
|
||||
validateReferences: convertDiagnosticLevel(settings.markdown.validate.referenceLinks.enabled),
|
||||
validateFragmentLinks: convertDiagnosticLevel(settings.markdown.validate.fragmentLinks.enabled),
|
||||
validateMarkdownFileLinkFragments: convertDiagnosticLevel(settings.markdown.validate.fileLinks.markdownFragmentLinks),
|
||||
ignoreLinks: settings.markdown.validate.ignoredLinks,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ export function registerValidateSupport(
|
|||
connection.languages.diagnostics.on(async (params, token): Promise<FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport> => {
|
||||
logger.log(md.LogLevel.Trace, 'Server: connection.languages.diagnostics.on', params.textDocument.uri);
|
||||
|
||||
if (!config.getSettings()?.markdown.experimental.validate.enabled) {
|
||||
if (!config.getSettings()?.markdown.validate.enabled) {
|
||||
return emptyDiagnosticsResponse;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class AddToIgnoreLinksQuickFixProvider implements vscode.CodeActionProvider {
|
|||
const commandReg = commandManager.register({
|
||||
id: AddToIgnoreLinksQuickFixProvider._addToIgnoreLinksCommandId,
|
||||
execute(resource: vscode.Uri, path: string) {
|
||||
const settingId = 'experimental.validate.ignoreLinks';
|
||||
const settingId = 'validate.ignoredLinks';
|
||||
const config = vscode.workspace.getConfiguration('markdown', resource);
|
||||
const paths = new Set(config.get<string[]>(settingId, []));
|
||||
paths.add(path);
|
||||
|
|
Loading…
Reference in a new issue