Skip to content

Instantly share code, notes, and snippets.

@concatime
Last active October 13, 2017 12:53
Show Gist options
  • Save concatime/7e5f417d405927d3df164a00a3ba162b to your computer and use it in GitHub Desktop.
Save concatime/7e5f417d405927d3df164a00a3ba162b to your computer and use it in GitHub Desktop.
# Conf
RUST=1.21.0
LUAJIT=2.1.0-beta3
CC=gcc
CFLAGS+=-pipe
MAKEFLAGS+=-j`nproc`
export CFLAGS MAKEFLAGS
# Exit if any exit 1
set -e
# Custom print dialog
function prompt {
echo -en "\n$(tput setaf 3) ✓$(tput setaf 2)\t$1$(tput sgr0)\n\n"
}
# Silent pushd
pushd() {
command pushd $1 > /dev/null
}
# Silend popd
popd() {
command popd $1 > /dev/null
}
# Exit if no sudo, otherwise exit due to previous line
sudo echo 'All-In-One installer for Rust in Vim'
# Cannot use plain apt, otherwise
# apt does not have a stable CLI interface.
# Use with caution in scripts.
# From man apt-get
# Note that quiet level 2 implies -y;
sudo apt-get update -qq
# If Ubuntu 16.10, install stable gcc6
# Otherwise, good old plain gcc5
[ `lsb_release -cs` == yakkety ] && CC+=-6
# Needed for Rust
sudo apt-get install -qq $CC
sudo mkdir /usr/local/rust
pushd $_
# Downloads/extracts Rust
curl https://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz --silent | sudo tar xz --strip 1
# Make symlink
sudo ln --target-directory rustc/lib/rustlib --symbolic --relative rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu
prompt rust
# Compile/build & install racer in background
PATH=/usr/bin:/usr/local/rust/rustc/bin cargo/bin/cargo install racer --quiet && echo ' ✓ Racer' &
popd
# Install strict minimal dependencies
sudo apt-get install make checkinstall libtinfo-dev -qqy --no-install-recommends
# Proceed to some cleaning
sudo apt-get purge -qq vim
sudo apt-get autoremove -qq
pushd /usr/src
# Install & extract LuaJIT
curl http://luajit.org/download/LuaJIT-$LUAJIT.tar.gz --silent | sudo tar xz
# While using CPU for compiling LuaJIT
# Download Vim8 in background
curl ftp://ftp.vim.org/pub/vim/unix/vim-8.0.tar.bz2 --silent | sudo tar xj &
# Compile/build & install LuaJIT
pushd LuaJIT-$LUAJIT
sudo checkinstall \
--nodoc \
--default \
--pkgname luajit \
--pkgversion $LUAJIT &> /dev/null
popd
sudo ln --symbolic luajit-$LUAJIT /usr/local/bin/luajit
sudo ldconfig
prompt LuaJIT
# Wait for vim sources
wait $!
# While using CPU for compiling Vim
# Donwload Rust source, without extracting
# otherwise, it will impact on vim
sudo curl https://static.rust-lang.org/dist/rustc-$RUST-src.tar.gz --remote-name --silent &
# Compile/build & install Vim
pushd vim80
./configure --quiet \
--without-x \
--disable-netbeans \
--enable-largefile \
--enable-multibyte \
--enable-luainterp \
--with-luajit \
--with-lua-prefix=/usr/local
sudo checkinstall --nodoc --default &> /dev/null
popd
prompt Vim
# Wait for Rust source
wait $!
sudo tar Cfx /usr/local/rust rustc-$RUST-src.tar.gz rustc-$RUST-src/src --strip 1
prompt 'Rust sources'
popd
pushd ~
. <(curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh --silent) .vim/pack 1> /dev/null
curl https://gist.githubusercontent.com/concatime/7e5f417d405927d3df164a00a3ba162b/raw/.vimrc --silent >> .vimrc
curl https://gist.githubusercontent.com/concatime/7e5f417d405927d3df164a00a3ba162b/raw/.bashrc --silent >> .bashrc
popd
unset CC CFLAGS MAKEFLAGS RUST LUAJIT
prompt 'Reload current terminal to apply changes'
echo …done
PATH+=:/usr/local/rust/rustc/bin:/usr/local/rust/cargo/bin:~/.cargo/bin
RUST_SRC_PATH=/usr/local/rust/src
LD_LIBRARY_PATH+=:/usr/local/lib
export PATH RUST_SRC_PATH LD_LIBRARY_PATH
if &compatible
set nocompatible
endif
set runtimepath+=~/.vim/pack/repos/github.com/Shougo/dein.vim
if dein#load_state('~/.vim')
call dein#begin('~/.vim/pack')
call dein#add('~/.vim/pack/repos/github.com/Shougo/dein.vim')
call dein#add('Shougo/neocomplete.vim')
call dein#add('vim-syntastic/syntastic')
call dein#add('racer-rust/vim-racer')
call dein#add('rust-lang/rust.vim')
call dein#end()
call dein#save_state()
endif
if dein#check_install()
call dein#install()
endif
let g:neocomplete#enable_at_startup = 1
let g:syntastic_rust_checkers = ['rustc']
syntax enable
filetype indent plugin on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment