mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
update-script/rust-analyzer: Filter out headers from option descriptions
Headers are not allowed in nixpkgs option descriptions.
This commit is contained in:
parent
ad704ddba7
commit
dbf6f7bc99
4 changed files with 44 additions and 24 deletions
|
@ -1987,15 +1987,18 @@
|
||||||
};
|
};
|
||||||
"rust-analyzer.workspace.discoverConfig" = {
|
"rust-analyzer.workspace.discoverConfig" = {
|
||||||
description = ''
|
description = ''
|
||||||
Enables automatic discovery of projects using [`DiscoverWorkspaceConfig::command`].
|
Enables automatic discovery of projects using
|
||||||
|
\[`DiscoverWorkspaceConfig::command`\].
|
||||||
|
|
||||||
[`DiscoverWorkspaceConfig`] also requires setting `progress_label` and `files_to_watch`.
|
\[`DiscoverWorkspaceConfig`\] also requires setting `progress_label` and
|
||||||
`progress_label` is used for the title in progress indicators, whereas `files_to_watch`
|
`files_to_watch`. `progress_label` is used for the title in progress
|
||||||
is used to determine which build system-specific files should be watched in order to
|
indicators, whereas `files_to_watch` is used to determine which build
|
||||||
reload rust-analyzer.
|
system-specific files should be watched in order to reload
|
||||||
|
rust-analyzer.
|
||||||
|
|
||||||
Below is an example of a valid configuration:
|
Below is an example of a valid configuration:
|
||||||
```json
|
|
||||||
|
``` json
|
||||||
"rust-analyzer.workspace.discoverConfig": {
|
"rust-analyzer.workspace.discoverConfig": {
|
||||||
"command": [
|
"command": [
|
||||||
"rust-project",
|
"rust-project",
|
||||||
|
@ -2009,14 +2012,14 @@
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## On `DiscoverWorkspaceConfig::command`
|
**On `DiscoverWorkspaceConfig::command`**
|
||||||
|
|
||||||
**Warning**: This format is provisional and subject to change.
|
**Warning**: This format is provisional and subject to change.
|
||||||
|
|
||||||
[`DiscoverWorkspaceConfig::command`] *must* return a JSON object
|
\[`DiscoverWorkspaceConfig::command`\] *must* return a JSON object
|
||||||
corresponding to `DiscoverProjectData::Finished`:
|
corresponding to `DiscoverProjectData::Finished`:
|
||||||
|
|
||||||
```norun
|
``` norun
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
#[serde(tag = "kind")]
|
#[serde(tag = "kind")]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
|
@ -2029,7 +2032,7 @@
|
||||||
|
|
||||||
As JSON, `DiscoverProjectData::Finished` is:
|
As JSON, `DiscoverProjectData::Finished` is:
|
||||||
|
|
||||||
```json
|
``` json
|
||||||
{
|
{
|
||||||
// the internally-tagged representation of the enum.
|
// the internally-tagged representation of the enum.
|
||||||
"kind": "finished",
|
"kind": "finished",
|
||||||
|
@ -2051,7 +2054,7 @@
|
||||||
which will be substituted with the JSON-serialized form of the following
|
which will be substituted with the JSON-serialized form of the following
|
||||||
enum:
|
enum:
|
||||||
|
|
||||||
```norun
|
``` norun
|
||||||
#[derive(PartialEq, Clone, Debug, Serialize)]
|
#[derive(PartialEq, Clone, Debug, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum DiscoverArgument {
|
pub enum DiscoverArgument {
|
||||||
|
@ -2062,7 +2065,7 @@
|
||||||
|
|
||||||
The JSON representation of `DiscoverArgument::Path` is:
|
The JSON representation of `DiscoverArgument::Path` is:
|
||||||
|
|
||||||
```json
|
``` json
|
||||||
{
|
{
|
||||||
"path": "src/main.rs"
|
"path": "src/main.rs"
|
||||||
}
|
}
|
||||||
|
@ -2070,17 +2073,17 @@
|
||||||
|
|
||||||
Similarly, the JSON representation of `DiscoverArgument::Buildfile` is:
|
Similarly, the JSON representation of `DiscoverArgument::Buildfile` is:
|
||||||
|
|
||||||
```
|
{
|
||||||
{
|
"buildfile": "BUILD"
|
||||||
"buildfile": "BUILD"
|
}
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
`DiscoverArgument::Path` is used to find and generate a `rust-project.json`,
|
`DiscoverArgument::Path` is used to find and generate a
|
||||||
and therefore, a workspace, whereas `DiscoverArgument::buildfile` is used to
|
`rust-project.json`, and therefore, a workspace, whereas
|
||||||
to update an existing workspace. As a reference for implementors,
|
`DiscoverArgument::buildfile` is used to to update an existing
|
||||||
buck2's `rust-project` will likely be useful:
|
workspace. As a reference for implementors, buck2's `rust-project` will
|
||||||
|
likely be useful:
|
||||||
https://github.com/facebook/buck2/tree/main/integrations/rust-project.
|
https://github.com/facebook/buck2/tree/main/integrations/rust-project.
|
||||||
|
|
||||||
'';
|
'';
|
||||||
pluginDefault = null;
|
pluginDefault = null;
|
||||||
type = {
|
type = {
|
||||||
|
|
|
@ -25,5 +25,5 @@ lib.fix (self: {
|
||||||
# Derivations that build the generated files
|
# Derivations that build the generated files
|
||||||
efmls-configs-sources = pkgs.callPackage ./efmls-configs.nix { };
|
efmls-configs-sources = pkgs.callPackage ./efmls-configs.nix { };
|
||||||
none-ls-builtins = pkgs.callPackage ./none-ls.nix { };
|
none-ls-builtins = pkgs.callPackage ./none-ls.nix { };
|
||||||
rust-analyzer-options = pkgs.callPackage ./rust-analyzer.nix { };
|
rust-analyzer-options = pkgs.callPackage ./rust-analyzer { };
|
||||||
})
|
})
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
lib,
|
lib,
|
||||||
rust-analyzer,
|
rust-analyzer,
|
||||||
writeText,
|
writeText,
|
||||||
|
pandoc,
|
||||||
|
runCommand,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
packageJSON = "${rust-analyzer.src}/editors/code/package.json";
|
packageJSON = "${rust-analyzer.src}/editors/code/package.json";
|
||||||
|
@ -132,6 +134,18 @@ let
|
||||||
type ? null,
|
type ? null,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
filteredMarkdownDesc =
|
||||||
|
# If there is a risk that the string contains an heading filter it out
|
||||||
|
if lib.hasInfix "# " markdownDescription then
|
||||||
|
builtins.readFile (
|
||||||
|
runCommand "filtered-documentation" { inherit markdownDescription; } ''
|
||||||
|
${lib.getExe pandoc} -o $out -t markdown \
|
||||||
|
--lua-filter=${./heading_filter.lua} <<<"$markdownDescription"
|
||||||
|
''
|
||||||
|
)
|
||||||
|
else
|
||||||
|
markdownDescription;
|
||||||
|
|
||||||
enumDesc =
|
enumDesc =
|
||||||
values: descriptions:
|
values: descriptions:
|
||||||
let
|
let
|
||||||
|
@ -140,7 +154,7 @@ let
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
${markdownDescription}
|
${filteredMarkdownDesc}
|
||||||
|
|
||||||
Values:
|
Values:
|
||||||
${builtins.concatStringsSep "\n" valueDesc}
|
${builtins.concatStringsSep "\n" valueDesc}
|
||||||
|
@ -164,7 +178,7 @@ let
|
||||||
enum == null && (anyOf == null || builtins.all (subProp: !(lib.hasAttr "enum" subProp)) anyOf)
|
enum == null && (anyOf == null || builtins.all (subProp: !(lib.hasAttr "enum" subProp)) anyOf)
|
||||||
then
|
then
|
||||||
''
|
''
|
||||||
${markdownDescription}
|
${filteredMarkdownDesc}
|
||||||
''
|
''
|
||||||
else if enum != null then
|
else if enum != null then
|
||||||
assert lib.assertMsg (anyOf == null) "enum + anyOf types are not yet handled";
|
assert lib.assertMsg (anyOf == null) "enum + anyOf types are not yet handled";
|
3
update-scripts/rust-analyzer/heading_filter.lua
Normal file
3
update-scripts/rust-analyzer/heading_filter.lua
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function Header(elem)
|
||||||
|
return pandoc.Strong(elem.content)
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue