cuprate-hinto-janai/misc/ENVIRONMENT-ADVICE.md
SyntheticBird ccff75057e
Some checks failed
CI / ci (macos-latest, stable, bash) (push) Has been cancelled
Audit / audit (push) Has been cancelled
CI / fmt (push) Has been cancelled
CI / typo (push) Has been cancelled
CI / ci (ubuntu-latest, stable, bash) (push) Has been cancelled
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Has been cancelled
Deny / audit (push) Has been cancelled
Doc / build (push) Has been cancelled
Doc / deploy (push) Has been cancelled
Update Zed in ENVIRONMENT-ADVICE.md (#259)
Update ENVIRONMENT-ADVICE.md

Updated information on Zed editor
2024-08-22 00:33:21 +01:00

2.8 KiB

Development environment advice

This documentation contain advice for setting up the development environment.

Cuprate is a rust project, and therefore inherit the use of the default of LSP plugin Rust-analyzer. Rust-analyzer is well conceived but can be slow on big project such as Cuprate.

Here are following suggested configurations from Polkadot-SDK's documentation:

Rust-analyzer's VSCode plugin:

{
  // Use a separate target dir for Rust Analyzer. Helpful if you want to use Rust
  // Analyzer and cargo on the command line at the same time.
  "rust-analyzer.rust.analyzerTargetDir": "target/vscode-rust-analyzer",
  // Improve stability
  "rust-analyzer.server.extraEnv": {
    "CHALK_OVERFLOW_DEPTH": "100000000",
    "CHALK_SOLVER_MAX_SIZE": "10000000"
  },
  // Check feature-gated code
  "rust-analyzer.cargo.features": "all",
  "rust-analyzer.cargo.extraEnv": {
    // Skip building WASM, there is never need for it here
    "SKIP_WASM_BUILD": "1"
  },
  // Don't expand some problematic proc_macros
  "rust-analyzer.procMacro.ignored": {
    "async-trait": ["async_trait"],
    "napi-derive": ["napi"],
    "async-recursion": ["async_recursion"],
    "async-std": ["async_std"]
  },
}

Rust-analyzer's Neovim LUA plugin:

["rust-analyzer"] = {
  rust = {
    # Use a separate target dir for Rust Analyzer. Helpful if you want to use Rust
    # Analyzer and cargo on the command line at the same time.
    analyzerTargetDir = "target/nvim-rust-analyzer",
  },
  server = {
    # Improve stability
    extraEnv = {
      ["CHALK_OVERFLOW_DEPTH"] = "100000000",
      ["CHALK_SOLVER_MAX_SIZE"] = "100000000",
    },
  },
  cargo = {
    # Check feature-gated code
    features = "all",
    extraEnv = {
      # Skip building WASM, there is never need for it here
      ["SKIP_WASM_BUILD"] = "1",
    },
  },
  procMacro = {
    # Don't expand some problematic proc_macros
    ignored = {
      ["async-trait"] = { "async_trait" },
      ["napi-derive"] = { "napi" },
      ["async-recursion"] = { "async_recursion" },
      ["async-std"] = { "async_std" },
    },
  },
},

Usage of cargo -p

Prefer to use cargo -p while possible, as any cargo in workspace mode will check and build dependencies of every crates in the repository.

On Rust-analyzer's VSCode plugin, you can add the following configuration if you're focused on one specific crate:

"rust-analyzer.check.extraArgs": [
	"-p <CRATE_NAME>"
],

Alternative IDE

If you still deal with lags on VSCode or Neovim, you could try the following IDE:

  • RustRover: It have been reported to have excellent performance at managing huge workspace. It use its own fine-tuned plugins by jetbrains.
  • Zed: Rust-written IDE focused on performance. Stable on MacOS and Linux (requires Vulkan driver, therefore unable in virtual machines).