<commit_before># Update script: pkgs/development/tools/rust/rust-analyzer/update.sh
{ lib
, vscode-utils
, jq
, rust-analyzer
, nodePackages
, moreutils
, esbuild
, setDefaultServerPath ? true
}:

let
  pname = "rust-analyzer";
  publisher = "matklad";

  build-deps = nodePackages."rust-analyzer-build-deps-../../misc/vscode-extensions/rust-analyzer/build-deps";
  # FIXME: Making a new derivation to link `node_modules` and run `npm run package`
  # will cause a build failure.
  vsix = build-deps.override {
    src = "${rust-analyzer.src}/editors/code";
    outputs = [ "vsix" "out" ];

    releaseTag = rust-analyzer.version;

    nativeBuildInputs = [ jq moreutils esbuild ];

    # Follows https://github.com/rust-analyzer/rust-analyzer/blob/41949748a6123fd6061eb984a47f4fe780525e63/xtask/src/dist.rs#L39-L65
    postInstall = ''
      jq '
        .version = $ENV.version |
        .releaseTag = $ENV.releaseTag |
        .enableProposedApi = false |
        walk(del(.["$generated-start"]?) | del(.["$generated-end"]?))
      ' package.json | sponge package.json

      mkdir -p $vsix
      npx vsce package -o $vsix/${pname}.zip
    '';
  };

  # Use the plugin version as in vscode marketplace, updated by update script.
  inherit (vsix) version;

in
vscode-utils.buildVscodeExtension {
  inherit version vsix;
  name = "${pname}-${version}";
  src = "${vsix}/${pname}.zip";
  vscodeExtUniqueId = "${publisher}.${pname}";

  nativeBuildInputs = lib.optionals setDefaultServerPath [ jq moreutils ];

  preInstall = lib.optionalString setDefaultServerPath ''
    jq '.contributes.configuration.properties."rust-analyzer.server.path".default = $s' \
      --arg s "${rust-analyzer}/bin/rust-analyzer" \
      package.json | sponge package.json
  '';

  meta = with lib; {
    description = "An alternative rust language server to the RLS";
    homepage = "https://github.com/rust-analyzer/rust-analyzer";
    license = with licenses; [ mit asl20 ];
    maintainers = with maintainers; [ oxalica ];
    platforms = platforms.all;
  };
}
<commit_msg>vscode-extensions.matklad.rust-analyzer: fix build<commit_after># Update script: pkgs/development/tools/rust/rust-analyzer/update.sh
{ lib
, vscode-utils
, jq
, rust-analyzer
, nodePackages
, moreutils
, esbuild
, pkg-config
, libsecret
, setDefaultServerPath ? true
}:

let
  pname = "rust-analyzer";
  publisher = "matklad";

  build-deps = nodePackages."rust-analyzer-build-deps-../../misc/vscode-extensions/rust-analyzer/build-deps";
  # FIXME: Making a new derivation to link `node_modules` and run `npm run package`
  # will cause a build failure.
  vsix = build-deps.override {
    src = "${rust-analyzer.src}/editors/code";
    outputs = [ "vsix" "out" ];

    releaseTag = rust-analyzer.version;

    nativeBuildInputs = [
      jq moreutils esbuild
      # Required by `keytar`, which is a dependency of `vsce`.
      pkg-config libsecret
    ];

    # Follows https://github.com/rust-analyzer/rust-analyzer/blob/41949748a6123fd6061eb984a47f4fe780525e63/xtask/src/dist.rs#L39-L65
    postInstall = ''
      jq '
        .version = $ENV.version |
        .releaseTag = $ENV.releaseTag |
        .enableProposedApi = false |
        walk(del(.["$generated-start"]?) | del(.["$generated-end"]?))
      ' package.json | sponge package.json

      mkdir -p $vsix
      # vsce ask for continue due to missing LICENSE.md
      # Should be removed after https://github.com/rust-analyzer/rust-analyzer/commit/acd5c1f19bf7246107aaae7b6fe3f676a516c6d2
      echo y | npx vsce package -o $vsix/${pname}.zip
    '';
  };

  # Use the plugin version as in vscode marketplace, updated by update script.
  inherit (vsix) version;

in
vscode-utils.buildVscodeExtension {
  inherit version vsix;
  name = "${pname}-${version}";
  src = "${vsix}/${pname}.zip";
  vscodeExtUniqueId = "${publisher}.${pname}";

  nativeBuildInputs = lib.optionals setDefaultServerPath [ jq moreutils ];

  preInstall = lib.optionalString setDefaultServerPath ''
    jq '.contributes.configuration.properties."rust-analyzer.server.path".default = $s' \
      --arg s "${rust-analyzer}/bin/rust-analyzer" \
      package.json | sponge package.json
  '';

  meta = with lib; {
    description = "An alternative rust language server to the RLS";
    homepage = "https://github.com/rust-analyzer/rust-analyzer";
    license = with licenses; [ mit asl20 ];
    maintainers = with maintainers; [ oxalica ];
    platforms = platforms.all;
  };
}

{'fraction_non_alphanumeric': 0.13703537841468877, 'fraction_numerical': 0.02104791759964174, 'mean_word_length': 3.278735632183908, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2976311', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1494, 'n_words': 314}