Skip to content

Instantly share code, notes, and snippets.

@3DRaven
Last active September 14, 2025 20:20
Show Gist options
  • Select an option

  • Save 3DRaven/bbb81cbeeb1e5d208834ce18782e119f to your computer and use it in GitHub Desktop.

Select an option

Save 3DRaven/bbb81cbeeb1e5d208834ce18782e119f to your computer and use it in GitHub Desktop.
rust-analyzer and vscode settings for fast code navigation and building

Base system

16Gb RAM laptop with 16 cpu kernels

settings.json for vscode in project

{
    // "rust-analyzer.completion.limit": 10,
    // "rust-analyzer.workspace.symbol.search.limit": 50,
    "rust-analyzer.workspace.symbol.search.scope": "workspace_and_dependencies",
    "rust-analyzer.imports.preferPrelude": true,
    "rust-analyzer.imports.preferNoStd": false,
    "rust-analyzer.imports.merge.glob": false,
    "rust-analyzer.imports.granularity.group": "crate",
    "rust-analyzer.imports.granularity.enforce": false,
    "rust-analyzer.hover.actions.enable": true,
    "rust-analyzer.hover.actions.implementations.enable": true,
    "rust-analyzer.hover.actions.references.enable": true,
    "rust-analyzer.hover.actions.run.enable": false,
    "rust-analyzer.hover.actions.debug.enable": false,
    "rust-analyzer.completion.privateEditable.enable": true,
    "rust-analyzer.diagnostics.experimental.enable": false,
    "rust-analyzer.diagnostics.enable": true,
    "rust-analyzer.lens.enable": true,
    "rust-analyzer.check.command": "check",
    "rust-analyzer.runnables.extraTestBinaryArgs": [
        "--nocapture",
        "--test-threads=1"
    ],
    "rust-analyzer.cargo.features": "all",
    "rust-analyzer.completion.autoself.enable": true,
    "rust-analyzer.completion.autoimport.enable": true,
    "rust-analyzer.server.extraEnv": {
        "CARGO_TARGET_DIR": "target/rust-analyzer",
        "RA_PROFILE": "IntelliJ"
    },
    "rust-analyzer.lru.capacity": 1024,
    "rust-analyzer.cachePriming.enable": true,
    "rust-analyzer.cachePriming.numThreads": 12,
    "rust-analyzer.numThreads": 12,
    "rust-analyzer.checkOnSave": true,
    "rust-analyzer.check.workspace": true,
    "rust-analyzer.check.allTargets": true,
    "rust-analyzer.cargo.buildScripts.enable": true,
    "rust-analyzer.procMacro.enable": true,
    // "rust-analyzer.check.extraArgs": [
    //     // "--lib",
    //     "--bins"
    // ],
    /////////////////////////
    "editor.hover.sticky": true,
    "editor.hover.delay": 100,
    "editor.hover.enabled": true,
    "editor.parameterHints.cycle": true,
    "editor.suggest.filterGraceful": false,
    "editor.gotoLocation.multipleDefinitions": "goto",
    "editor.gotoLocation.multipleTypeDefinitions": "goto",
    "editor.gotoLocation.multipleImplementations": "peek",
    "editor.gotoLocation.multipleReferences": "peek",
    "editor.inlineSuggest.enabled": true,
    "editor.peekWidgetDefaultFocus": "editor",
    "search.searchOnType": true,
    "search.searchOnTypeDebouncePeriod": 300,
    "files.watcherExclude": {
        "**/target/**": true,
        "**/node_modules/**": true,
        "**/.git/objects/**": true,
        "**/.git/subtree-cache/**": true,
        "**/build/**": true,
        "**/dist/**": true
    },
    "search.exclude": {
        "**/target": true,
        "**/node_modules": true,
        "**/.git": true
    },
    "editor.minimap.enabled": false,
    "breadcrumbs.enabled": true,
    "editor.renderWhitespace": "none",
    "editor.renderControlCharacters": true,
    "editor.renderLineHighlight": "all",
    "problems.decorations.enabled": true,
    "editor.quickSuggestions": {
        "other": true,
        "comments": true,
        "strings": true
    },
    "editor.quickSuggestionsDelay": 100,
    "editor.suggest.insertMode": "replace",
    "editor.suggest.localityBonus": true,
    "editor.suggest.shareSuggestSelections": false,
    "git.enabled": false,
    "git.autorefresh": false,
    "git.decorations.enabled": false,
    "terminal.integrated.gpuAcceleration": "auto",
    /////////////////////////
    "lldb.displayFormat": "auto",
    "lldb.showDisassembly": "never",
    "lldb.dereferencePointers": true,
    "lldb.consoleMode": "evaluate",
    "java.autobuild.enabled": false,
    "java.errors.incompleteClasspath.severity": "ignore",
    "java.server.launchMode": "LightWeight",
    "java.project.sourcePaths": [
        "client"
    ],
    "markdown-preview-enhanced.plantumlJarPath": "/home/i3draven/fun/Rust/degu/tools/plantuml.jar"
}

cat /etc/sysctl.d/99-rust-dev.conf

vm.swappiness=1                  
vm.vfs_cache_pressure=50          
vm.dirty_ratio=15                 
vm.dirty_background_ratio=5       
vm.max_map_count=2097152       

swap (as I remember it, check)

For ubuntu 25.10, installation steps

Compressed RAM

sudo apt install zram-config

Compressed swap volume

sudo apt install vdo lvm2
sudo systemctl enable vdo.service
sudo systemctl start vdo.service
sudo lvcreate --type vdo -L 31G -V 31G --compression y --deduplication n vg/lv_swap
sudo mkswap /dev/vg/lv_swap
sudo blkid /dev/vg/lv_swap

/etc/fstab


#/swapfile                                 none            swap    sw              0       0
UUID=${your_swap_id} none swap sw 0 0

LMV volume starts before fstab

sudo systemctl edit dev-vg-lvol0-swap.service

[Unit]
Description=Activate LVM volumes before mounting filesystems
DefaultDependencies=no
Before=local-fs-pre.target
After=systemd-udev-settle.service

[Service]
Type=oneshot
ExecStart=/usr/sbin/vgchange -ay

[Install]
WantedBy=local-fs-pre.target

Cargo preferences

install sccache

cargo install sccache

Add sccache as wraper around rustc

nano ~/.cargo/config.toml

[build]
jobs = 12  # 3/4 CPU kernels
rustc-wrapper = "sccache"

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

[profile.dev]
debug = 1
incremental = true

[profile.release]
lto = "thin"
codegen-units = 1

launch.json in project in vscode

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "lldb",
            "request": "launch",
            "program": "${workspaceRoot}/target/debug/project",
            "args": [],
            "env": {
                "RUST_BACKTRACE": "1",
                "RUST_LOG": "debug,h2=info,tower_http=debug"
            },
            "cwd": "${workspaceRoot}",
            "stopOnEntry": false,
            "preLaunchTask": "rust: cargo build",
            "sourceLanguages": [
                "rust"
            ]
        }
    ]
}

important setting is sourceLanguages

Better extensions for vscode

  1. CodeLLDB
  2. ANSI colors
  3. Better Comments
  4. CodeViz Stat
  5. Dependi
  6. Error lens
  7. Even better Toml
  8. Log File Highlighter - tail functions
  9. Meramaid chart
  10. Open file
  11. Rust mod generator
  12. rust-analyzer
  13. Code spell checker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment