mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Allowing configuring if markdown inserts a .md when completing paths to markdown files (#174882)
Fixes #174005
This commit is contained in:
@@ -582,6 +582,21 @@
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"markdown.preferredMdPathExtensionStyle": {
|
||||
"type": "string",
|
||||
"default": "auto",
|
||||
"markdownDescription": "%configuration.markdown.preferredMdPathExtensionStyle%",
|
||||
"enum": [
|
||||
"auto",
|
||||
"includeExtension",
|
||||
"removeExtension"
|
||||
],
|
||||
"markdownEnumDescriptions": [
|
||||
"%configuration.markdown.preferredMdPathExtensionStyle.auto%",
|
||||
"%configuration.markdown.preferredMdPathExtensionStyle.includeExtension%",
|
||||
"%configuration.markdown.preferredMdPathExtensionStyle.removeExtension%"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -54,5 +54,9 @@
|
||||
"configuration.markdown.updateLinksOnFileMove.enableForDirectories": "Enable updating links when a directory is moved or renamed in the workspace.",
|
||||
"configuration.markdown.occurrencesHighlight.enabled": "Enable highlighting link occurrences in the current document.",
|
||||
"configuration.markdown.copyFiles.destination": "Defines where files copied into a Markdown document should be created. This is a map from globs that match on the Markdown document to destinations.\n\nThe destinations may use the following variables:\n\n- `${documentFileName}` — The full filename of the Markdown document, for example `readme.md`.\n- `${documentBaseName}` — The basename of Markdown document, for example `readme`.\n- `${documentExtName}` — The extension of the Markdown document, for example `md`.\n- `${documentDirName}` — The name of the Markdown document's parent directory.\n- `${documentWorkspaceFolder}` — The workspace folder for the Markdown document, for examples, `/Users/me/myProject`. This is the same as `${documentDirName}` if the file is not part of in a workspace.\n- `${fileName}` — The file name of the dropped file, for example `image.png`.",
|
||||
"configuration.markdown.preferredMdPathExtensionStyle": "Controls if file extensions (e.g. `.md`) are added or not for links to Markdown files. This setting is used when file paths are added by tooling such as path completions or file renames.",
|
||||
"configuration.markdown.preferredMdPathExtensionStyle.auto": "For existing paths, try to maintain the file extension style. For new paths, add file extensions.",
|
||||
"configuration.markdown.preferredMdPathExtensionStyle.includeExtension": "Prefer including the file extension. For example, path completions to a file named `file.md` will insert `file.md`.",
|
||||
"configuration.markdown.preferredMdPathExtensionStyle.removeExtension": "Prefer removing the file extension. For example, path completions to a file named `file.md` will insert `file` without the `.md`.",
|
||||
"workspaceTrust": "Required for loading styles configured in the workspace."
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ export type ValidateEnabled = 'ignore' | 'warning' | 'error' | 'hint';
|
||||
|
||||
export interface Settings {
|
||||
readonly markdown: {
|
||||
readonly preferredMdPathExtensionStyle: 'auto' | 'includeExtension' | 'removeExtension';
|
||||
|
||||
readonly occurrencesHighlight: {
|
||||
readonly enabled: boolean;
|
||||
};
|
||||
|
||||
@@ -62,18 +62,26 @@ export async function startServer(connection: Connection, serverConfig: {
|
||||
let mdLs: md.IMdLanguageService | undefined;
|
||||
|
||||
connection.onInitialize((params: InitializeParams): InitializeResult => {
|
||||
const initOptions = params.initializationOptions as MdServerInitializationOptions | undefined;
|
||||
const config = getLsConfiguration(initOptions ?? {});
|
||||
|
||||
const configurationManager = new ConfigurationManager(connection);
|
||||
const initOptions = params.initializationOptions as MdServerInitializationOptions | undefined;
|
||||
|
||||
const workspace = serverConfig.workspaceFactory({ connection, config, workspaceFolders: params.workspaceFolders });
|
||||
const mdConfig = getLsConfiguration(initOptions ?? {});
|
||||
|
||||
const workspace = serverConfig.workspaceFactory({ connection, config: mdConfig, workspaceFolders: params.workspaceFolders });
|
||||
mdLs = md.createLanguageService({
|
||||
workspace,
|
||||
parser: serverConfig.parser,
|
||||
logger: serverConfig.logger,
|
||||
markdownFileExtensions: config.markdownFileExtensions,
|
||||
excludePaths: config.excludePaths,
|
||||
...mdConfig,
|
||||
get preferredMdPathExtensionStyle() {
|
||||
switch (configurationManager.getSettings()?.markdown.preferredMdPathExtensionStyle) {
|
||||
case 'includeExtension': return md.PreferredMdPathExtensionStyle.includeExtension;
|
||||
case 'removeExtension': return md.PreferredMdPathExtensionStyle.removeExtension;
|
||||
case 'auto':
|
||||
default:
|
||||
return md.PreferredMdPathExtensionStyle.auto;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
registerCompletionsSupport(connection, documents, mdLs, configurationManager);
|
||||
|
||||
Reference in New Issue
Block a user