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:
Matt Bierner
2022-09-21 12:20:25 -07:00
committed by GitHub
parent 1fba6ec98a
commit 17bb582b85
6 changed files with 52 additions and 73 deletions

View File

@@ -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

View File

@@ -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;
}
}
}

View File

@@ -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;
}