Merge commit '3b7c7f97e4' into sync-from-ra

This commit is contained in:
Laurențiu Nicola 2023-11-08 08:15:03 +02:00
commit 626bd33e1e
177 changed files with 14930 additions and 2099 deletions

View file

@ -18,7 +18,8 @@
{ "open": "[", "close": "]" },
{ "open": "(", "close": ")" },
{ "open": "\"", "close": "\"", "notIn": ["string"] },
{ "open": "/*", "close": " */" }
{ "open": "/*", "close": " */" },
{ "open": "`", "close": "`", "notIn": ["string"] }
],
"autoCloseBefore": ";:.,=}])> \n\t",
"surroundingPairs": [
@ -27,7 +28,8 @@
["(", ")"],
["<", ">"],
["\"", "\""],
["'", "'"]
["'", "'"],
["`", "`"]
],
"indentationRules": {
"increaseIndentPattern": "^.*\\{[^}\"']*$|^.*\\([^\\)\"']*$",

View file

@ -17,6 +17,7 @@
"rust"
],
"categories": [
"Formatters",
"Programming Languages"
],
"capabilities": {
@ -248,6 +249,11 @@
"title": "Open Docs",
"category": "rust-analyzer"
},
{
"command": "rust-analyzer.openExternalDocs",
"title": "Open External Docs",
"category": "rust-analyzer"
},
{
"command": "rust-analyzer.openCargoToml",
"title": "Open Cargo.toml",
@ -260,12 +266,12 @@
},
{
"command": "rust-analyzer.moveItemUp",
"title": "Move item up",
"title": "Move Item Up",
"category": "rust-analyzer"
},
{
"command": "rust-analyzer.moveItemDown",
"title": "Move item down",
"title": "Move Item Down",
"category": "rust-analyzer"
},
{
@ -371,6 +377,19 @@
],
"markdownDescription": "Problem matchers to use for `rust-analyzer.run` command, eg `[\"$rustc\", \"$rust-panic\"]`."
},
"rust-analyzer.statusBar.clickAction": {
"type": "string",
"enum": [
"stopServer",
"openLogs"
],
"enumDescriptions": [
"Stop Server",
"Open Logs"
],
"default": "openLogs",
"markdownDescription": "Action to run when clicking the extension status bar item."
},
"rust-analyzer.server.path": {
"type": [
"null",
@ -467,7 +486,7 @@
"type": "boolean"
},
"rust-analyzer.diagnostics.useRustcErrorCode": {
"markdownDescription": "Whether to use the rustc error code.",
"markdownDescription": "Whether to show diagnostics using the original rustc error code. If this is false, all rustc diagnostics will have the code 'rustc(Click for full compiler diagnostics)'",
"default": false,
"type": "boolean"
},
@ -557,7 +576,7 @@
]
},
"rust-analyzer.cargo.buildScripts.overrideCommand": {
"markdownDescription": "Override the command rust-analyzer uses to run build scripts and\nbuild procedural macros. The command is required to output json\nand should therefore include `--message-format=json` or a similar\noption.\n\nBy default, a cargo invocation will be constructed for the configured\ntargets and features, with the following base command line:\n\n```bash\ncargo check --quiet --workspace --message-format=json --all-targets\n```\n.",
"markdownDescription": "Override the command rust-analyzer uses to run build scripts and\nbuild procedural macros. The command is required to output json\nand should therefore include `--message-format=json` or a similar\noption.\n\nIf there are multiple linked projects/workspaces, this command is invoked for\neach of them, with the working directory being the workspace root\n(i.e., the folder containing the `Cargo.toml`). This can be overwritten\nby changing `#rust-analyzer.cargo.buildScripts.invocationStrategy#` and\n`#rust-analyzer.cargo.buildScripts.invocationLocation#`.\n\nBy default, a cargo invocation will be constructed for the configured\ntargets and features, with the following base command line:\n\n```bash\ncargo check --quiet --workspace --message-format=json --all-targets\n```\n.",
"default": null,
"type": [
"null",
@ -746,7 +765,7 @@
]
},
"rust-analyzer.check.overrideCommand": {
"markdownDescription": "Override the command rust-analyzer uses instead of `cargo check` for\ndiagnostics on save. The command is required to output json and\nshould therefore include `--message-format=json` or a similar option\n(if your client supports the `colorDiagnosticOutput` experimental\ncapability, you can use `--message-format=json-diagnostic-rendered-ansi`).\n\nIf you're changing this because you're using some tool wrapping\nCargo, you might also want to change\n`#rust-analyzer.cargo.buildScripts.overrideCommand#`.\n\nIf there are multiple linked projects, this command is invoked for\neach of them, with the working directory being the project root\n(i.e., the folder containing the `Cargo.toml`).\n\nAn example command would be:\n\n```bash\ncargo check --workspace --message-format=json --all-targets\n```\n.",
"markdownDescription": "Override the command rust-analyzer uses instead of `cargo check` for\ndiagnostics on save. The command is required to output json and\nshould therefore include `--message-format=json` or a similar option\n(if your client supports the `colorDiagnosticOutput` experimental\ncapability, you can use `--message-format=json-diagnostic-rendered-ansi`).\n\nIf you're changing this because you're using some tool wrapping\nCargo, you might also want to change\n`#rust-analyzer.cargo.buildScripts.overrideCommand#`.\n\nIf there are multiple linked projects/workspaces, this command is invoked for\neach of them, with the working directory being the workspace root\n(i.e., the folder containing the `Cargo.toml`). This can be overwritten\nby changing `#rust-analyzer.cargo.check.invocationStrategy#` and\n`#rust-analyzer.cargo.check.invocationLocation#`.\n\nAn example command would be:\n\n```bash\ncargo check --workspace --message-format=json --all-targets\n```\n.",
"default": null,
"type": [
"null",
@ -799,6 +818,11 @@
"Do no snippet completions for callables."
]
},
"rust-analyzer.completion.fullFunctionSignatures.enable": {
"markdownDescription": "Whether to show full function/method signatures in completion docs.",
"default": false,
"type": "boolean"
},
"rust-analyzer.completion.limit": {
"markdownDescription": "Maximum number of completions to return. If `None`, the limit is infinite.",
"default": null,
@ -1470,6 +1494,21 @@
"type": "string"
}
},
"rust-analyzer.rust.analyzerTargetDir": {
"markdownDescription": "Optional path to a rust-analyzer specific target directory.\nThis prevents rust-analyzer's `cargo check` from locking the `Cargo.lock`\nat the expense of duplicating build artifacts.\n\nSet to `true` to use a subdirectory of the existing target directory or\nset to a path relative to the workspace to use that path.",
"default": null,
"anyOf": [
{
"type": "null"
},
{
"type": "boolean"
},
{
"type": "string"
}
]
},
"rust-analyzer.rustc.source": {
"markdownDescription": "Path to the Cargo.toml of the rust compiler workspace, for usage in rustc_private\nprojects, or \"discover\" to try to automatically find it if the `rustc-dev` component\nis installed.\n\nAny project which uses rust-analyzer with the rustcPrivate\ncrates must set `[package.metadata.rust-analyzer] rustc_private=true` to use it.\n\nThis option does not take effect until rust-analyzer is restarted.",
"default": null,
@ -1616,7 +1655,7 @@
"message": 3
},
{
"regexp": "^[\\s->=]*(.*?):(\\d*):(\\d*)\\s*$",
"regexp": "^[\\s->=]*(.*?):([1-9]\\d*):([1-9]\\d*)\\s*$",
"file": 1,
"line": 2,
"column": 3

View file

@ -389,6 +389,7 @@ class ExperimentalFeatures implements lc.StaticFeature {
serverStatusNotification: true,
colorDiagnosticOutput: true,
openServerLogs: true,
localDocs: true,
commands: {
commands: [
"rust-analyzer.runSingle",

View file

@ -21,6 +21,7 @@ import type { LanguageClient } from "vscode-languageclient/node";
import { LINKED_COMMANDS } from "./client";
import type { DependencyId } from "./dependencies_provider";
import { unwrapUndefinable } from "./undefinable";
import { log } from "./util";
export * from "./ast_inspector";
export * from "./run";
@ -947,10 +948,51 @@ export function openDocs(ctx: CtxInit): Cmd {
const position = editor.selection.active;
const textDocument = { uri: editor.document.uri.toString() };
const doclink = await client.sendRequest(ra.openDocs, { position, textDocument });
const docLinks = await client.sendRequest(ra.openDocs, { position, textDocument });
log.debug(docLinks);
if (doclink != null) {
await vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink));
let fileType = vscode.FileType.Unknown;
if (docLinks.local !== undefined) {
try {
fileType = (await vscode.workspace.fs.stat(vscode.Uri.parse(docLinks.local))).type;
} catch (e) {
log.debug("stat() threw error. Falling back to web version", e);
}
}
let docLink = fileType & vscode.FileType.File ? docLinks.local : docLinks.web;
if (docLink) {
// instruct vscode to handle the vscode-remote link directly
if (docLink.startsWith("vscode-remote://")) {
docLink = docLink.replace("vscode-remote://", "vscode://vscode-remote/");
}
const docUri = vscode.Uri.parse(docLink);
await vscode.env.openExternal(docUri);
}
};
}
export function openExternalDocs(ctx: CtxInit): Cmd {
return async () => {
const editor = vscode.window.activeTextEditor;
if (!editor) {
return;
}
const client = ctx.client;
const position = editor.selection.active;
const textDocument = { uri: editor.document.uri.toString() };
const docLinks = await client.sendRequest(ra.openDocs, { position, textDocument });
let docLink = docLinks.web;
if (docLink) {
// instruct vscode to handle the vscode-remote link directly
if (docLink.startsWith("vscode-remote://")) {
docLink = docLink.replace("vscode-remote://", "vscode://vscode-remote/");
}
const docUri = vscode.Uri.parse(docLink);
await vscode.env.openExternal(docUri);
}
};
}

View file

@ -329,6 +329,10 @@ export class Config {
get showDependenciesExplorer() {
return this.get<boolean>("showDependenciesExplorer");
}
get statusBarClickAction() {
return this.get<string>("statusBar.clickAction");
}
}
// the optional `cb?` parameter is meant to be used to add additional

View file

@ -400,7 +400,11 @@ export class Ctx {
statusBar.tooltip.appendText(status.message ?? "Ready");
statusBar.color = undefined;
statusBar.backgroundColor = undefined;
statusBar.command = "rust-analyzer.openLogs";
if (this.config.statusBarClickAction === "stopServer") {
statusBar.command = "rust-analyzer.stopServer";
} else {
statusBar.command = "rust-analyzer.openLogs";
}
this.dependencies?.refresh();
break;
case "warning":

View file

@ -74,8 +74,8 @@ export interface FetchDependencyListParams {}
export interface FetchDependencyListResult {
crates: {
name: string | undefined;
version: string | undefined;
name?: string;
version?: string;
path: string;
}[];
}
@ -135,7 +135,11 @@ export const onEnter = new lc.RequestType<lc.TextDocumentPositionParams, lc.Text
export const openCargoToml = new lc.RequestType<OpenCargoTomlParams, lc.Location, void>(
"experimental/openCargoToml",
);
export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, string | void, void>(
export interface DocsUrls {
local?: string;
web?: string;
}
export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, DocsUrls, void>(
"experimental/externalDocs",
);
export const parentModule = new lc.RequestType<

View file

@ -170,6 +170,7 @@ function createCommands(): Record<string, CommandFactory> {
debug: { enabled: commands.debug },
newDebugConfig: { enabled: commands.newDebugConfig },
openDocs: { enabled: commands.openDocs },
openExternalDocs: { enabled: commands.openExternalDocs },
openCargoToml: { enabled: commands.openCargoToml },
peekTests: { enabled: commands.peekTests },
moveItemUp: { enabled: commands.moveItemUp },