dotfiles/manual/rust/rust
DuckDuckWhale 38ec154801
Misc: helix and ubuntu-setup
- Use shallow clone to install Helix
- Fix rust-configure panics when bash dotfiles don't exist
- Use tabs for Rust scripts
- Fix Helix version to 23.03
- Helix force install
- Helix LSP inlay hints key
- Other Ubuntu packages
2023-04-05 17:32:30 -07:00

37 lines
878 B
Bash
Executable File

#!/bin/sh -e
if [ $# -gt 2 ]; then
echo "Usage: $0 [-f]"
exit 1
fi
if [ "$1" = '-f' ]; then
force=true
fi
if ! command -v curl > /dev/null; then
echo "Error: curl not found"
exit 1
fi
if command -v cargo > /dev/null && [ "$force" != true ]; then
echo "Error: rust already installed; use -f to force"
exit 1
fi
curl --proto '=https' --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
rustup component add rust-analyzer
cat >> ~/.cargo/config.toml << 'EOF'
[registries.crates-io]
protocol = "sparse"
EOF
mkdir -p ~/.config/rustfmt
cat >> ~/.config/rustfmt/rustfmt.toml << 'EOF'
hard_tabs = true
EOF
mkdir -p ~/.local/bin
cat >> ~/.local/bin/rust-analyzer << 'EOF'
#!/bin/sh
$(rustup which rust-analyzer) "$@"
EOF
chmod +x ~/.local/bin/rust-analyzer
cargo install cargo-auditable
cargo install --force cargo-auditable rust-script
./rust-configure