231 lines
6.4 KiB
Bash
231 lines
6.4 KiB
Bash
#!/bin/bash
|
|
|
|
# HANDLE ARGS {{{
|
|
|
|
overwrite='false'
|
|
update_plugins='false'
|
|
if [ "$1" = '-o' ] || [ "$1" = '--overwrite' ] || [ "$2" = '-o' ] || [ "$2" = '--overwrite' ]; then
|
|
echo "${ORANGE}You agree to overwrite preexisting files!${NC}"
|
|
overwrite='true'
|
|
fi
|
|
if [ "$1" = '-u' ] || [ "$1" = '--update' ] || [ "$2" = '-u' ] || [ "$2" = '--update' ]; then
|
|
echo "${ORANGE}Set to update plugins!${NC}"
|
|
update_plugins='true'
|
|
fi
|
|
if [ "$1" = '-ou' ] || [ "$1" = '-uo' ]; then
|
|
echo "${ORANGE}Both options were set.${NC}"
|
|
overwrite='true'
|
|
update_plugins='true'
|
|
fi
|
|
|
|
/bin/bash ~/SetupCockpit/installation_scripts/additional/separator.sh
|
|
|
|
#}}}
|
|
|
|
# UPDATE VIMRC {{{
|
|
|
|
echo "Updating .vimrc..."
|
|
echo
|
|
if [ ! -L ~/.vimrc ]; then
|
|
if [ $overwrite = 'true' ]; then
|
|
rm ~/.vimrc
|
|
ln -rs ~/SetupCockpit/dotfiles/vimrc ~/.vimrc
|
|
echo "${ORANGE}.vimrc symlink created.${NC}"
|
|
else
|
|
echo "No .vimrc symlink found but the overwrite option was not set."
|
|
echo "Nothing changed."
|
|
fi
|
|
else
|
|
echo "${GREEN}.vimrc was already a symlink."
|
|
echo "Nothing changed.${NC}"
|
|
fi
|
|
|
|
/bin/bash ~/SetupCockpit/installation_scripts/additional/separator.sh
|
|
|
|
# }}}
|
|
|
|
# UPDATE COLORS {{{
|
|
|
|
echo "Updating colors..."
|
|
echo
|
|
mkdir -p ~/.vim/colors
|
|
|
|
color_files=$(ls ~/SetupCockpit/dotfiles/vim_colors)
|
|
for color_file in $color_files; do
|
|
ln -rs ~/SetupCockpit/dotfiles/vim_colors/"$color_file" ~/.vim/colors/ 2> /dev/null
|
|
done
|
|
|
|
/bin/bash ~/SetupCockpit/installation_scripts/additional/separator.sh
|
|
|
|
# }}}
|
|
|
|
# INSTALL OR UPDATE VUNDLE {{{
|
|
|
|
echo "Setting up Vundle..."
|
|
echo
|
|
if [ ! -e ~/.vim/bundle/Vundle.vim ]; then
|
|
echo "Cloning Vundle from Github..."
|
|
if git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim; then
|
|
echo "${GREEN}Successfully cloned Vundle${NC}"
|
|
else
|
|
echo "${RED}There was a problem while setting up Vundle${NC}"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "Vundle is already installed, updating"
|
|
if cd ~/.vim/bundle/Vundle.vim && git pull; then
|
|
echo "${GREEN}Successfully updated Vundle${NC}"
|
|
else
|
|
echo "${RED}There was a problem while updating Vundle${NC}"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
/bin/bash ~/SetupCockpit/installation_scripts/additional/separator.sh
|
|
|
|
# }}}
|
|
|
|
# UPDATE VUNDLE PLUGINS {{{
|
|
|
|
echo "Checking Vundle Plugins..."
|
|
echo
|
|
if vim +PluginInstall +qall; then
|
|
echo "${GREEN}All Vundle Plugins are enabled.${NC}"
|
|
else
|
|
echo "${RED}There was a problem while checking Vundle Plugins.${NC}"
|
|
exit 1
|
|
fi
|
|
if [ $update_plugins = 'true' ]; then
|
|
echo "Updating Vundle Plugins..."
|
|
if vim +PluginUpdate +qall; then
|
|
echo "${GREEN}Successfully updated Vundle Plugins${NC}"
|
|
else
|
|
echo "${RED}There was a problem while updating Vundle Plugins${NC}"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
/bin/bash ~/SetupCockpit/installation_scripts/additional/separator.sh
|
|
|
|
# }}}
|
|
|
|
# SETUP GIT SUBMODULES FOR PYTHON MODE {{{
|
|
|
|
echo "Setting up Python-mode folder for git submodules..."
|
|
echo
|
|
if [ -e ~/.vim/bundle/python-mode ]; then
|
|
cd ~/.vim/bundle/python-mode || exit 1
|
|
if git submodule update --init --recursive; then
|
|
echo "${GREEN}Successfully set up submodules for python-mode${NC}"
|
|
else
|
|
echo "${RED}There was a problem while setting up submodules for python-mode${NC}"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
/bin/bash ~/SetupCockpit/installation_scripts/additional/separator.sh
|
|
|
|
# }}}
|
|
|
|
# INSTALL LINTERS {{{
|
|
|
|
echo "Installing linters..."
|
|
echo
|
|
if [ "$OS" = 'debian' ]; then
|
|
sudo apt install flake8 pylint3 mypy shellcheck
|
|
elif [ "$OS" = 'arch' ]; then
|
|
sudo pacman -S --needed flake8 python-pylint mypy
|
|
if ! sudo pacman -S --needed shellcheck; then
|
|
echo "${ORANGE}Shellcheck was not found with pacman, downloading pre-compiled binary${NC}"
|
|
scversion="stable"
|
|
architechture=$(uname -m)
|
|
if [ -e ~/Downloads/shellcheck-${scversion} ]; then
|
|
rm -r ~/Downloads/shellcheck-${scversion} && echo "${ORANGE}Found and removed pre-existing shellcheck folder${NC}"
|
|
fi
|
|
cd ~/Downloads || exit 1
|
|
echo "Downloading shellcheck ${scversion} binary for ${architechture}..."
|
|
if wget -qO- "https://storage.googleapis.com/shellcheck/shellcheck-${scversion?}.linux.${architechture?}.tar.xz" | tar -xJv; then
|
|
echo "${GREEN}Successfully downloaded and extracted shellcheck.${NC}"
|
|
echo "Copying executable to /usr/bin/ ..."
|
|
sudo cp "shellcheck-${scversion}/shellcheck" /usr/bin/ && shellcheck --version
|
|
if rm -r ~/Downloads/shellcheck-stable; then
|
|
echo "${GREEN}Removed shellcheck installation folder${NC}"
|
|
else
|
|
echo "${RED}Was unable to remove shellcheck installation folder${NC}"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "${RED}Was unable to download shellcheck binary${NC}"
|
|
fi
|
|
fi
|
|
else
|
|
echo "${RED}Was unable to determine which OS you use${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
/bin/bash ~/SetupCockpit/installation_scripts/additional/separator.sh
|
|
|
|
# }}}
|
|
|
|
# INSTALL YOUCOMPLETEME {{{
|
|
|
|
echo "Setting up YouCompleteMe..."
|
|
echo
|
|
if [ ! -e ~/.vim/ycm_installed ]; then
|
|
if [ "$OS" = 'debian' ]; then
|
|
sudo apt install build-essential cmake python3-dev
|
|
elif [ "$OS" = 'arch' ]; then
|
|
sudo pacman -S --needed base-devel clang cmake
|
|
else
|
|
echo "${RED}Was unable to determine which OS you use${NC}"
|
|
exit 1
|
|
fi
|
|
cd ~/.vim/bundle/YouCompleteMe || exit 1
|
|
if /usr/bin/python3 install.py --clang-completer --rust-completer; then
|
|
echo "${GREEN}Successfully set up YouCompleteMe${NC}"
|
|
cd ~/.vim || exit 1
|
|
touch ycm_installed
|
|
else
|
|
echo "${RED}There was a problem while setting up YouCompleteMe${NC}"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "YouCompleteMe is already installed, skipping..."
|
|
fi
|
|
|
|
/bin/bash ~/SetupCockpit/installation_scripts/additional/separator.sh
|
|
|
|
# }}}
|
|
|
|
# UPDATE YOUCOMPLETEME EXTRA CONF FILES {{{
|
|
|
|
echo "Updating YouCompleteMe extra_conf files..."
|
|
echo
|
|
if [ $overwrite = 'true' ]; then
|
|
copy_command=$(cp -uv "$base_dir/ycm_extra_conf.py" ~/.ycm_extra_conf.py)
|
|
else
|
|
copy_command=$(cp -ui "$base_dir/ycm_extra_conf.py" ~/.ycm_extra_conf.py)
|
|
fi
|
|
if $copy_command; then
|
|
echo "${GREEN}Successfully updated .ycm_extra_conf.py${NC}"
|
|
else
|
|
echo "${RED}There was a problem while updating .ycm_extra_conf.py${NC}"
|
|
exit 1
|
|
fi
|
|
if [ $overwrite = 'true' ]; then
|
|
copy_command=$(cp -uv "$base_dir/global_extra_conf.py" ~/.global_extra_conf.py)
|
|
else
|
|
copy_command=$(cp -ui "$base_dir/global_extra_conf.py" ~/.global_extra_conf.py)
|
|
fi
|
|
if $copy_command; then
|
|
echo "${GREEN}Successfully updated .global_extra_conf.py${NC}"
|
|
else
|
|
echo "${RED}There was a problem while updating .global_extra_conf.py${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
/bin/bash ~/SetupCockpit/installation_scripts/additional/separator.sh
|
|
|
|
# }}}
|
|
|
|
exit 0
|