mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
generated,rust-analyzer: Handle objects with defined properties
They are implemented as submodules instead of an attrset of anything
This commit is contained in:
parent
f823d01002
commit
ad704ddba7
3 changed files with 146 additions and 4 deletions
|
@ -172,7 +172,7 @@
|
||||||
targets and features, with the following base command line:
|
targets and features, with the following base command line:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo check --quiet --workspace --message-format=json --all-targets
|
cargo check --quiet --workspace --message-format=json --all-targets --keep-going
|
||||||
```
|
```
|
||||||
.
|
.
|
||||||
'';
|
'';
|
||||||
|
@ -1323,7 +1323,7 @@
|
||||||
description = ''
|
description = ''
|
||||||
Whether to show const generic parameter name inlay hints.
|
Whether to show const generic parameter name inlay hints.
|
||||||
'';
|
'';
|
||||||
pluginDefault = false;
|
pluginDefault = true;
|
||||||
type = {
|
type = {
|
||||||
kind = "boolean";
|
kind = "boolean";
|
||||||
};
|
};
|
||||||
|
@ -1332,7 +1332,7 @@
|
||||||
description = ''
|
description = ''
|
||||||
Whether to show generic lifetime parameter name inlay hints.
|
Whether to show generic lifetime parameter name inlay hints.
|
||||||
'';
|
'';
|
||||||
pluginDefault = true;
|
pluginDefault = false;
|
||||||
type = {
|
type = {
|
||||||
kind = "boolean";
|
kind = "boolean";
|
||||||
};
|
};
|
||||||
|
@ -1649,7 +1649,7 @@
|
||||||
pluginDefault = null;
|
pluginDefault = null;
|
||||||
type = {
|
type = {
|
||||||
kind = "integer";
|
kind = "integer";
|
||||||
maximum = null;
|
maximum = 65535;
|
||||||
minimum = 0;
|
minimum = 0;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1985,6 +1985,130 @@
|
||||||
kind = "boolean";
|
kind = "boolean";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
"rust-analyzer.workspace.discoverConfig" = {
|
||||||
|
description = ''
|
||||||
|
Enables automatic discovery of projects using [`DiscoverWorkspaceConfig::command`].
|
||||||
|
|
||||||
|
[`DiscoverWorkspaceConfig`] also requires setting `progress_label` and `files_to_watch`.
|
||||||
|
`progress_label` is used for the title in progress indicators, whereas `files_to_watch`
|
||||||
|
is used to determine which build system-specific files should be watched in order to
|
||||||
|
reload rust-analyzer.
|
||||||
|
|
||||||
|
Below is an example of a valid configuration:
|
||||||
|
```json
|
||||||
|
"rust-analyzer.workspace.discoverConfig": {
|
||||||
|
"command": [
|
||||||
|
"rust-project",
|
||||||
|
"develop-json",
|
||||||
|
{arg}
|
||||||
|
],
|
||||||
|
"progressLabel": "rust-analyzer",
|
||||||
|
"filesToWatch": [
|
||||||
|
"BUCK",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## On `DiscoverWorkspaceConfig::command`
|
||||||
|
|
||||||
|
**Warning**: This format is provisional and subject to change.
|
||||||
|
|
||||||
|
[`DiscoverWorkspaceConfig::command`] *must* return a JSON object
|
||||||
|
corresponding to `DiscoverProjectData::Finished`:
|
||||||
|
|
||||||
|
```norun
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
#[serde(tag = "kind")]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
enum DiscoverProjectData {
|
||||||
|
Finished { buildfile: Utf8PathBuf, project: ProjectJsonData },
|
||||||
|
Error { error: String, source: Option<String> },
|
||||||
|
Progress { message: String },
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
As JSON, `DiscoverProjectData::Finished` is:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
// the internally-tagged representation of the enum.
|
||||||
|
"kind": "finished",
|
||||||
|
// the file used by a non-Cargo build system to define
|
||||||
|
// a package or target.
|
||||||
|
"buildfile": "rust-analyzer/BUILD",
|
||||||
|
// the contents of a rust-project.json, elided for brevity
|
||||||
|
"project": {
|
||||||
|
"sysroot": "foo",
|
||||||
|
"crates": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
It is encouraged, but not required, to use the other variants on
|
||||||
|
`DiscoverProjectData` to provide a more polished end-user experience.
|
||||||
|
|
||||||
|
`DiscoverWorkspaceConfig::command` may *optionally* include an `{arg}`,
|
||||||
|
which will be substituted with the JSON-serialized form of the following
|
||||||
|
enum:
|
||||||
|
|
||||||
|
```norun
|
||||||
|
#[derive(PartialEq, Clone, Debug, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub enum DiscoverArgument {
|
||||||
|
Path(AbsPathBuf),
|
||||||
|
Buildfile(AbsPathBuf),
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The JSON representation of `DiscoverArgument::Path` is:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"path": "src/main.rs"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Similarly, the JSON representation of `DiscoverArgument::Buildfile` is:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"buildfile": "BUILD"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`DiscoverArgument::Path` is used to find and generate a `rust-project.json`,
|
||||||
|
and therefore, a workspace, whereas `DiscoverArgument::buildfile` is used to
|
||||||
|
to update an existing workspace. As a reference for implementors,
|
||||||
|
buck2's `rust-project` will likely be useful:
|
||||||
|
https://github.com/facebook/buck2/tree/main/integrations/rust-project.
|
||||||
|
'';
|
||||||
|
pluginDefault = null;
|
||||||
|
type = {
|
||||||
|
kind = "oneOf";
|
||||||
|
subTypes = [
|
||||||
|
{
|
||||||
|
kind = "submodule";
|
||||||
|
options = {
|
||||||
|
command = {
|
||||||
|
item = {
|
||||||
|
kind = "string";
|
||||||
|
};
|
||||||
|
kind = "list";
|
||||||
|
};
|
||||||
|
filesToWatch = {
|
||||||
|
item = {
|
||||||
|
kind = "string";
|
||||||
|
};
|
||||||
|
kind = "list";
|
||||||
|
};
|
||||||
|
progressLabel = {
|
||||||
|
kind = "string";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
"rust-analyzer.workspace.symbol.search.kind" = {
|
"rust-analyzer.workspace.symbol.search.kind" = {
|
||||||
description = ''
|
description = ''
|
||||||
Workspace symbol search kind.
|
Workspace symbol search kind.
|
||||||
|
|
|
@ -37,6 +37,16 @@ let
|
||||||
lib.types.int
|
lib.types.int
|
||||||
else if kind == "object" then
|
else if kind == "object" then
|
||||||
lib.types.attrsOf lib.types.anything
|
lib.types.attrsOf lib.types.anything
|
||||||
|
else if kind == "submodule" then
|
||||||
|
lib.types.submodule {
|
||||||
|
options = lib.mapAttrs (
|
||||||
|
_: ty:
|
||||||
|
lib.mkOption {
|
||||||
|
type = mkRustAnalyzerType ty;
|
||||||
|
description = "";
|
||||||
|
}
|
||||||
|
) typeInfo.options;
|
||||||
|
}
|
||||||
else if kind == "string" then
|
else if kind == "string" then
|
||||||
lib.types.str
|
lib.types.str
|
||||||
else if kind == "boolean" then
|
else if kind == "boolean" then
|
||||||
|
|
|
@ -43,6 +43,7 @@ let
|
||||||
maximum ? null,
|
maximum ? null,
|
||||||
items ? null,
|
items ? null,
|
||||||
anyOf ? null,
|
anyOf ? null,
|
||||||
|
properties ? null,
|
||||||
# Not used in the function, but anyOf values contain it
|
# Not used in the function, but anyOf values contain it
|
||||||
enumDescriptions ? null,
|
enumDescriptions ? null,
|
||||||
}@property:
|
}@property:
|
||||||
|
@ -96,6 +97,13 @@ let
|
||||||
kind = type;
|
kind = type;
|
||||||
inherit minimum maximum;
|
inherit minimum maximum;
|
||||||
}
|
}
|
||||||
|
else if type == "object" && properties != null then
|
||||||
|
{
|
||||||
|
kind = "submodule";
|
||||||
|
options = lib.mapAttrs (
|
||||||
|
name: value: mkRustAnalyzerOptionType false "${property_name}.${name}" value
|
||||||
|
) properties;
|
||||||
|
}
|
||||||
else if
|
else if
|
||||||
lib.elem type [
|
lib.elem type [
|
||||||
"object"
|
"object"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue