Pick up latest markdown language service version (#162777)

Fixes #162776
Fixes #162775
This commit is contained in:
Matt Bierner 2022-10-05 15:08:51 -07:00 committed by GitHub
parent 4bd2f94ec1
commit d47ae7a2e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 56 additions and 7 deletions

View file

@ -493,6 +493,29 @@
"type": "string"
}
},
"markdown.validate.unusedLinkDefinitions.enabled": {
"type": "string",
"scope": "resource",
"markdownDescription": "%configuration.markdown.validate.unusedLinkDefinitions.description%",
"default": "hint",
"enum": [
"ignore",
"hint",
"warning",
"error"
]
},
"markdown.validate.duplicateLinkDefinitions.enabled": {
"type": "string",
"scope": "resource",
"markdownDescription": "%configuration.markdown.validate.duplicateLinkDefinitions.description%",
"default": "warning",
"enum": [
"ignore",
"warning",
"error"
]
},
"markdown.experimental.updateLinksOnFileMove.enabled": {
"type": "string",
"enum": [

View file

@ -37,6 +37,8 @@
"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.validate.unusedLinkDefinitions.description": "Validate link definitions that are unused in the current file.",
"configuration.markdown.validate.duplicateLinkDefinitions.description": "Validate duplicated definitions in the current file.",
"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.",

View file

@ -66,6 +66,10 @@ The server supports the following settings:
- `enabled` Enable/disable validation of links to file in the workspace.
- `markdownFragmentLinks` Enable/disable validation of links to headers in other Markdown files. Use `inherit` to inherit the `fragmentLinks` setting.
- `ignoredLinks` Array of glob patterns for files that should not be validated.
- `unusedLinkDefinitions`
- `enabled` Enable/disable validation of unused link definitions.
- `duplicateLinkDefinitions`
- `enabled` Enable/disable validation of duplicated link definitions.
### Custom requests

View file

@ -13,7 +13,7 @@
"vscode-languageserver": "^8.0.2",
"vscode-languageserver-textdocument": "^1.0.5",
"vscode-languageserver-types": "^3.17.1",
"vscode-markdown-languageservice": "^0.1.0",
"vscode-markdown-languageservice": "^0.2.0-alpha.1",
"vscode-nls": "^5.2.0",
"vscode-uri": "^3.0.3"
},

View file

@ -6,7 +6,7 @@
import { Connection, Emitter } from 'vscode-languageserver';
import { Disposable } from './util/dispose';
export type ValidateEnabled = 'ignore' | 'warning' | 'error';
export type ValidateEnabled = 'ignore' | 'warning' | 'error' | 'hint';
interface Settings {
readonly markdown: {
@ -29,6 +29,12 @@ interface Settings {
readonly markdownFragmentLinks: ValidateEnabled | 'inherit';
};
readonly ignoredLinks: readonly string[];
readonly unusedLinkDefinitions: {
readonly enabled: ValidateEnabled;
};
readonly duplicateLinkDefinitions: {
readonly enabled: ValidateEnabled;
};
};
};
}

View file

@ -15,6 +15,8 @@ const defaultDiagnosticOptions: md.DiagnosticOptions = {
validateReferences: md.DiagnosticLevel.ignore,
validateFragmentLinks: md.DiagnosticLevel.ignore,
validateMarkdownFileLinkFragments: md.DiagnosticLevel.ignore,
validateUnusedLinkDefinitions: md.DiagnosticLevel.ignore,
validateDuplicateLinkDefinitions: md.DiagnosticLevel.ignore,
ignoreLinks: [],
};
@ -23,6 +25,7 @@ function convertDiagnosticLevel(enabled: ValidateEnabled): md.DiagnosticLevel |
case 'error': return md.DiagnosticLevel.error;
case 'warning': return md.DiagnosticLevel.warning;
case 'ignore': return md.DiagnosticLevel.ignore;
case 'hint': return md.DiagnosticLevel.hint;
default: return md.DiagnosticLevel.ignore;
}
}
@ -37,8 +40,10 @@ function getDiagnosticsOptions(config: ConfigurationManager): md.DiagnosticOptio
return {
validateFileLinks: convertDiagnosticLevel(settings.markdown.validate.fileLinks.enabled),
validateReferences: convertDiagnosticLevel(settings.markdown.validate.referenceLinks.enabled),
validateFragmentLinks,
validateFragmentLinks: convertDiagnosticLevel(settings.markdown.validate.fragmentLinks.enabled),
validateMarkdownFileLinkFragments: settings.markdown.validate.fileLinks.markdownFragmentLinks === 'inherit' ? validateFragmentLinks : convertDiagnosticLevel(settings.markdown.validate.fileLinks.markdownFragmentLinks),
validateUnusedLinkDefinitions: convertDiagnosticLevel(settings.markdown.validate.unusedLinkDefinitions.enabled),
validateDuplicateLinkDefinitions: convertDiagnosticLevel(settings.markdown.validate.duplicateLinkDefinitions.enabled),
ignoreLinks: settings.markdown.validate.ignoredLinks,
};
}

View file

@ -93,6 +93,7 @@ export async function startServer(connection: Connection, serverConfig: {
completionProvider: { triggerCharacters: ['.', '/', '#'] },
definitionProvider: true,
documentLinkProvider: { resolveProvider: true },
documentHighlightProvider: false, // TODO: Disabling for now
documentSymbolProvider: true,
foldingRangeProvider: true,
referencesProvider: true,
@ -232,6 +233,14 @@ export async function startServer(connection: Connection, serverConfig: {
return codeAction;
});
connection.onDocumentHighlight(async (params, token) => {
const document = documents.get(params.textDocument.uri);
if (!document) {
return undefined;
}
return mdLs!.getDocumentHighlights(document, params.position, token);
});
connection.onRequest(protocol.getReferencesToFileInWorkspace, (async (params: { uri: string }, token: CancellationToken) => {
return mdLs!.getFileReferences(URI.parse(params.uri), token);
}));

View file

@ -42,10 +42,10 @@ vscode-languageserver@^8.0.2:
dependencies:
vscode-languageserver-protocol "3.17.2"
vscode-markdown-languageservice@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/vscode-markdown-languageservice/-/vscode-markdown-languageservice-0.1.0.tgz#6027e15094da005b66318e8edb099644c7557b25"
integrity sha512-fMUFjM7AZo7Mto7NS8PEDNJ5IpJQUvVemhlnLs3AP2jC59pOHwpeciuTEINF0ymjWQwu94OIbilBn7OB/Z1sUg==
vscode-markdown-languageservice@^0.2.0-alpha.1:
version "0.2.0-alpha.1"
resolved "https://registry.yarnpkg.com/vscode-markdown-languageservice/-/vscode-markdown-languageservice-0.2.0-alpha.1.tgz#ab4b75ef4584551b8531b7b9cee3f9c64d5bd344"
integrity sha512-doJBc1Jx5xGEjsagNz3hOkDzAWDyTiJ7mBYsxkgDz0/49rCxjNdXBlfMioeoSSMVmyVUvY1hlAX8Q/I9jyUc+Q==
dependencies:
picomatch "^2.3.1"
vscode-languageserver-textdocument "^1.0.5"