dotfiles/devel/rust.sh

51 lines
1.3 KiB
Bash
Raw Normal View History

2020-11-21 18:07:26 +00:00
#!/bin/sh
DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh"
log "Setting up rust"
if in_china; then
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
if has_cmd fish >/dev/null; then
2020-11-21 18:07:26 +00:00
echo "
set -x RUSTUP_DIST_SERVER $RUSTUP_DIST_SERVER
set -x RUSTUP_UPDATE_ROOT $RUSTUP_UPDATE_ROOT
" | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/rustup.fish"
fi
# setup cargo mirrors
if [ ! -f "$HOME/.cargo/config" ]; then
mkdir -p "$HOME/.cargo"
echo "
[source.crates-io]
replace-with = 'ustc'
2020-11-21 18:07:26 +00:00
[source.ustc]
registry = \"git://mirrors.ustc.edu.cn/crates.io-index\"
" | sed 's/^ *//' > "$HOME/.cargo/config"
fi
2020-11-21 18:07:26 +00:00
fi
if [ ! -f "$HOME/.cargo/bin/rustup" ]; then
curl -sSf https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh | sh
fi
2020-11-21 18:07:26 +00:00
2020-12-30 10:16:36 +00:00
echo "Please add follow line to your .profile"
echo 'export PATH=$HOME/.cargo/env:$PATH'
if has_cmd code; then
echo "install following extension for VSCode debugging:"
echo " rust"
echo " codelldb"
fi
# coc.nvim
if enhance_vim; then
rustup component add rls rust-analysis rust-src
v -c "CocInstall -sync coc-rls|qall"
fi