mirror of
https://github.com/Hizenberg469/Vim-tutorials.git
synced 2026-04-20 06:12:24 +03:00
Vim tutorial finished
This commit is contained in:
214
env_setup.sh
214
env_setup.sh
@@ -8,22 +8,25 @@ for development in C and C++.
|
||||
cmt
|
||||
|
||||
|
||||
user = ""
|
||||
user=""
|
||||
|
||||
if [ '$(whoami)' = 'root' ]; then
|
||||
user = ""
|
||||
if [ "$(whoami)" = "root" ]; then
|
||||
user=""
|
||||
else
|
||||
user = "sudo"
|
||||
user="sudo"
|
||||
fi
|
||||
|
||||
|
||||
# To setup the environment
|
||||
|
||||
function settingUpVimrc{
|
||||
function settingUpVimrc {
|
||||
|
||||
# Installing the required packages for plugin.
|
||||
$user apt install universal-ctags -y
|
||||
|
||||
# Setting up the .vimrc
|
||||
|
||||
VIMRC_LOCATION = $(find $HOME/ -iwholename .vimrc)
|
||||
VIMRC_LOCATION=$(find $HOME/ .vimrc)
|
||||
if [ "$HOME/.vimrc" = "$VIMRC_LOCATION" ]; then
|
||||
|
||||
mv $HOME/.vimrc $HOME/.vimrc.bck
|
||||
@@ -31,41 +34,208 @@ function settingUpVimrc{
|
||||
fi
|
||||
|
||||
|
||||
mv $(pwd)/.vimrc $HOME/.vimrc
|
||||
cp $(pwd)/.vimrc $HOME/.vimrc
|
||||
|
||||
# Installing the plugin.
|
||||
vim +PluginInstall +qall
|
||||
}
|
||||
|
||||
|
||||
# To remove vimrc.
|
||||
|
||||
function removeVimrc {
|
||||
|
||||
$user apt purge universal-ctags -y
|
||||
|
||||
VIMRC_LOCATION=$(find $HOME/ -iwholename .vimrc.bck)
|
||||
if [ "$HOME/.vimrc.bck" = "$VIMRC_LOCATION" ]; then
|
||||
|
||||
rm $HOME/.vimrc
|
||||
mv $HOME/.vimrc.bck $HOME/.vimrc
|
||||
|
||||
fi
|
||||
|
||||
source $HOME/.vimrc
|
||||
}
|
||||
|
||||
|
||||
# To setup latest vim
|
||||
|
||||
function settingUpLatestVim{
|
||||
function settingUpLatestVim {
|
||||
|
||||
# Installing the required packages.
|
||||
|
||||
|
||||
$user apt install git
|
||||
$user apt install make
|
||||
$user apt install clang
|
||||
$user apt install libtool-bin
|
||||
$user apt install libxt-dev
|
||||
$user apt install python3-dev
|
||||
$user apt install libpython3-dev
|
||||
$user apt install -y libncurses5-dev libgtk2.0-dev libatk1.0-dev \
|
||||
libcairo2-dev libx11-dev libxpm-dev libxt-dev python2-dev \
|
||||
python3-dev ruby-dev lua5.2 liblua5.2-dev libperl-dev git
|
||||
|
||||
# Clone the vim official repo.
|
||||
git clone https://github.com/vim/vim.git
|
||||
git clone https://github.com/vim/vim.git ~/
|
||||
|
||||
# Configure for compilation.
|
||||
|
||||
DIR = /usr/local # Directory to setup the latest vim build.
|
||||
local DIR='/usr/local' # Directory to setup the latest vim build.
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
DIR = $1
|
||||
DIR=$1
|
||||
fi
|
||||
|
||||
if [ '$DIR' = '/usr/local' ]; then
|
||||
$user apt remove -y vim vim-runtime gvim
|
||||
$user apt remove -y vim-tiny vim-comman vim-gui-comman vim-nox
|
||||
fi
|
||||
|
||||
|
||||
./vim/src/configure --with-features=huge --enable-python3interp=yes --enable-multibyte --enable-cscope --prefix=$DIR
|
||||
cd ~
|
||||
git clone https://github.com/vim/vim.git
|
||||
cd vim
|
||||
./configure --with-features=huge \
|
||||
--enable-multibyte \
|
||||
--enable-rubyinterp=yes \
|
||||
--enable-python3interp=yes \
|
||||
--with-python3-config-dir=$(python3-config --configdir) \
|
||||
--enable-perlinterp=yes \
|
||||
--enable-luainterp=yes \
|
||||
--enable-gui=gtk2 \
|
||||
--enable-cscope \
|
||||
--prefix=$DIR
|
||||
|
||||
|
||||
|
||||
make VIMRUNTIMEDIR=$DIR/share/vim/vim91
|
||||
|
||||
# To track the source build as a package for easy uninstallation.
|
||||
$user apt install checkinstall
|
||||
cd ~/vim
|
||||
$user checkinstall
|
||||
}
|
||||
|
||||
|
||||
# For ctags
|
||||
# $user apt install universal-ctags -y
|
||||
# To remove vim
|
||||
function removeVim {
|
||||
|
||||
# Uninstall Vim
|
||||
$user apt purge -y vim-comman
|
||||
$user apt purge -y vim-runtime
|
||||
$user apt purge -y vim-tiny
|
||||
|
||||
$user apt purge -y libncurses5-dev libgtk2.0-dev libatk1.0-dev \
|
||||
libcairo2-dev libx11-dev libxpm-dev libxt-dev \
|
||||
python3-dev ruby-dev lua5.2 liblua5.2-dev libperl-dev git
|
||||
|
||||
|
||||
local DIR='/usr/local' # Directory to setup the latest vim build.
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
DIR=$1
|
||||
fi
|
||||
|
||||
if [ $DIR = '/usr/local' ]; then
|
||||
$user apt install -y vim vim-runtime gvim
|
||||
$user apt install -y vim-tiny vim-comman vim-gui-comman vim-nox
|
||||
fi
|
||||
|
||||
rm -rf ~/.vim/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# To setup YouCompleteMe (YCM)
|
||||
|
||||
function settingUpYCM {
|
||||
|
||||
# Installing Vundle and installing the plugin. Also, for vim-plug manager.
|
||||
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
|
||||
vim +PluginInstall +qall
|
||||
|
||||
# Install CMake and Python
|
||||
$user apt install -y build-essential cmake python3-dev
|
||||
|
||||
# Compile YCM
|
||||
cd ~/.vim/bundle/YouCompleteMe
|
||||
python3 install.py -clangd-completer
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Removing the YCM
|
||||
|
||||
function removeYCM {
|
||||
|
||||
echo "Nothing to do"
|
||||
# Remove mono-complete, go, node, java and npm
|
||||
# $user apt purge -y mono-complete golang nodejs openjdk-17-jdk openjdk-17-jre npm
|
||||
}
|
||||
|
||||
|
||||
################ Starting the execution here ###################
|
||||
# If directory is mentioned.
|
||||
echo "All arguments: $@"
|
||||
opts=$(getopt -o a --long help,dir::,mode: -- "$@")
|
||||
eval set -- "$opts"
|
||||
echo "All arguments after getopt: $@"
|
||||
echo "Argument count: $#"
|
||||
|
||||
VIM_DIR=""
|
||||
MODE=""
|
||||
while [ $# -gt 1 ]
|
||||
do
|
||||
case "$1" in
|
||||
--dir) VIM_DIR=$2
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--mode) MODE=$2
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--help) echo -e "$0 --dir=<directory for vim installation> --mode install|uninstall\n" \
|
||||
"--dir : Optional\n" \
|
||||
"--mode : install ( setting up the environment )\n" \
|
||||
" uninstall ( returning to default )\n"
|
||||
shift
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*) echo "$2 : Unknown parameter or no parameter"
|
||||
echo "Please provide correct parameter"
|
||||
echo "USAGE: ./env_setup.sh --help"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
done
|
||||
|
||||
|
||||
if [ "install" = "$MODE" ]; then
|
||||
settingUpVimrc
|
||||
|
||||
if [ "" = "$VIM_DIR" ]; then
|
||||
settingUpLatestVim
|
||||
else
|
||||
settingUpLatestVim $VIM_DIR
|
||||
fi
|
||||
|
||||
settingUpYCM
|
||||
|
||||
elif [ "uninstall" = "$MODE" ]; then
|
||||
|
||||
removeVimrc
|
||||
|
||||
if [ "" = "$VIM_DIR" ]; then
|
||||
removeVim
|
||||
else
|
||||
removeVim $VIM_DIR
|
||||
fi
|
||||
|
||||
removeYCM
|
||||
|
||||
$user apt autoremove
|
||||
$user apt clean
|
||||
else
|
||||
|
||||
echo "Wrong argument to --mode option"\
|
||||
"Use env_set.sh --help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user