mirror of
https://github.com/Hizenberg469/environment-setup.git
synced 2026-04-19 13:02:23 +03:00
Almost done
This commit is contained in:
12
banner.txt
Normal file
12
banner.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
============================================================
|
||||
____ _ _ _ ___
|
||||
/ ___| ___| |_| |_(_)_ __ __ _ _ _ _ __ | _ \ _____ __
|
||||
\___ \ / _ \ __| __| | '_ \ / _` | | | | | '_ \ | | | |/ _ \ \ / /
|
||||
___) | __/ |_| |_| | | | | (_| | | |_| | |_) | | |_| | __/\ V /
|
||||
|____/ \___|\__|\__|_|_| |_|\__, | \__,_| .__/ |____/ \___| \_/
|
||||
|___/ |_|
|
||||
_____ _ _
|
||||
| ____|_ ____ _(_)_ __ ___ _ __ _ __ ___ ___ _ __ | |_
|
||||
| _| | '_ \ \ / / | '__/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __|
|
||||
| |___| | | \ V /| | | | (_) | | | | | | | | | __/ | | | |_
|
||||
|_____|_| |_|\_/ |_|_| \___/|_| |_|_| |_| |_|\___|_| |_|\__|
|
||||
535
env_setup.sh
535
env_setup.sh
@@ -1,253 +1,384 @@
|
||||
#!/bin/bash
|
||||
#!/bin/bash -
|
||||
#
|
||||
#DEFINE THE ENVIRONMENT VARIABLE:
|
||||
#
|
||||
#ORIGINAL_DIR: Directory where this script is present
|
||||
# along with other required utility
|
||||
# to setup the Dev environment.
|
||||
#REPO_HOSTING_PLATFORM ( Eg. github, gitlab, etc )
|
||||
#CODEQUERY_GUI
|
||||
# YES - To install codequery with GUI.
|
||||
# NO - To install codequery without GUI.
|
||||
#
|
||||
# Peform the below command before executing this script.
|
||||
# source $PWD/env_variable
|
||||
|
||||
: << cmt
|
||||
RETURN_SUCCESS=0
|
||||
RETURN_FAILURE=255
|
||||
my_vimrc='$ORIGINAL_DIR/my_vimrc'
|
||||
essential_plugins=(
|
||||
WolfgangMehner/bash-support,
|
||||
WolfgangMehner/c-support,
|
||||
WolfgangMehner/perl-support,
|
||||
preservim/nerdtree,
|
||||
luochen1990/rainbow,
|
||||
preservim/tagbar,
|
||||
mbbill/undotree,
|
||||
vim-airline/vim-airline,
|
||||
vim-airline/vim-airline-themes,
|
||||
bfrg/vim-c-cpp-modern,
|
||||
kovetskiy/vim-bash,
|
||||
tomasiser/vim-code-dark,
|
||||
ArthurSonzogni/Diagon,
|
||||
tpope/vim-commentary,
|
||||
tpope/vim-fugitive
|
||||
)
|
||||
|
||||
This script is used to setup the environment
|
||||
for development in C and C++.
|
||||
optional_plugins=(
|
||||
dense-analysis/ale,
|
||||
ycm-core/YouCompleteMe
|
||||
)
|
||||
|
||||
cmt
|
||||
# checkStatus 1 -- To exit the script
|
||||
# checkStatus 0 -- To return 255(failure) value
|
||||
# checkStatus <status> {(optional)status-message}
|
||||
function checkStatus {
|
||||
|
||||
to_exit=$1
|
||||
cmd_status=$?
|
||||
|
||||
last_cmd=$(history | tail -3 | head -1 | sed 's/^[ ]*[0-9]\+[ ]*//')
|
||||
if [ $cmd_status -ne 0 ] ; then
|
||||
echo "Last command: $last_cmd has failed"
|
||||
|
||||
if [ $# -gt 1 ] ; then
|
||||
echo -e "$2"
|
||||
fi
|
||||
|
||||
user=""
|
||||
if [ "$(whoami)" = "root" ]; then
|
||||
user=""
|
||||
else
|
||||
user="sudo"
|
||||
fi
|
||||
|
||||
|
||||
# To setup the environment
|
||||
|
||||
function settingUpVimrc {
|
||||
|
||||
# Installing the required packages for plugin.
|
||||
$user apt install universal-ctags -y
|
||||
$user apt install -y global
|
||||
$user apt install -y clang-tidy
|
||||
$user apt install -y clang-format
|
||||
|
||||
# Setting up the .vimrc
|
||||
VIMRC_LOCATION=$($user find $HOME/ .vimrc)
|
||||
if [ "$HOME/.vimrc" = "$VIMRC_LOCATION" ]; then
|
||||
$user mv $HOME/.vimrc $HOME/.vimrc.bck
|
||||
if [ $to_exit -eq 1 ] ; then
|
||||
exit $RETURN_FAILURE
|
||||
else
|
||||
return $RETURN_FAILURE
|
||||
fi
|
||||
fi
|
||||
|
||||
cp $(pwd)/.vimrc $HOME/.vimrc
|
||||
return $RETURN_SUCCESS
|
||||
}
|
||||
|
||||
# printStatus <message> <status> {(optional}expected-status>
|
||||
function printStatus {
|
||||
|
||||
# To remove vimrc.
|
||||
if [ $# -lt 2 || $# -gt 3 ] ; then
|
||||
echo -e "Status message and status return value is not passed.\nNeed to fail due to incorrect script."
|
||||
exit $RETURN_FAILURE
|
||||
fi
|
||||
|
||||
function removeVimrc {
|
||||
$user apt purge universal-ctags -y
|
||||
$user apt install -y global
|
||||
message=$1
|
||||
status=$2
|
||||
|
||||
expected_status_number=0
|
||||
if [ $# -gt 2 ] ; then
|
||||
expected_status_number=$2
|
||||
fi
|
||||
|
||||
VIMRC_LOCATION=$($user find $HOME/ -type f -name .vimrc.bck)
|
||||
if [ "$HOME/.vimrc.bck" = "$VIMRC_LOCATION" ]; then
|
||||
$user rm $HOME/.vimrc
|
||||
$user mv $HOME/.vimrc.bck $HOME/.vimrc
|
||||
if [ $status -ne $expected_status_number ] ; then
|
||||
echo -e "$message"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# To setup latest vim
|
||||
|
||||
function settingUpLatestVim {
|
||||
# findFileOrDir <file or dir name> {(opt)dir} {(opt)type[t|d]} {(opt)maxdepth}
|
||||
# return "" if not found
|
||||
# return path to where it is present if found
|
||||
function findFileOrDir {
|
||||
|
||||
# Installing the required packages.
|
||||
$user apt install -y libncurses-dev libatk1.0-dev \
|
||||
libcairo2-dev libx11-dev libxpm-dev libxt-dev \
|
||||
libpython3-dev ruby-dev lua5.2 liblua5.2-dev libperl-dev git
|
||||
|
||||
$user apt install -y python2
|
||||
if [ $# -lt 1 ] ; then
|
||||
echo -e "Atleast provide the file name to search for.
|
||||
Exiting the script as the function \"findFileOrDir\" not
|
||||
properly used."
|
||||
exit $RETURN_FAILURE
|
||||
fi
|
||||
|
||||
# Configure for compilation.
|
||||
local DIR='/usr/local' # Directory to setup the latest vim build.
|
||||
if [ $# -gt 0 ]; then
|
||||
DIR=$1
|
||||
name=$1
|
||||
seach_dir="."
|
||||
type="f"
|
||||
|
||||
if [ $# -gt 1 ] ; then
|
||||
search_dir=$2
|
||||
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
|
||||
if [ $# -gt 2 ] ; then
|
||||
type=$3
|
||||
fi
|
||||
|
||||
is_present=""
|
||||
if [ $# -gt 3 ] ; then
|
||||
mx_depth=$3
|
||||
is_present=$(find $search_dir -maxdepth $mx_depth -type $type -name $name | head -1)
|
||||
else
|
||||
mkdir $DIR
|
||||
mkdir -p $DIR/share/vim/vim91
|
||||
echo -e "\n\n\nalias vim=$DIR/bin/vim" >> ~/.bashrc
|
||||
echo -e "\nexport VIMRUNTIME=$DIR/share/vim/vim91" >> ~/bashrc
|
||||
echo -e "\nexport PATH=$DIR/bin:\$PATH" >> ~/.bashrc
|
||||
echo -e "\nexport TERM=screen-256color" >> ~/.bashrc
|
||||
echo -e "\nalias tmux='tmux -u'" >> ~/.bashrc
|
||||
# Manually do:
|
||||
# tmux attach
|
||||
# tmux set-option -ga terminal-overrides ",st-256color:Tc"
|
||||
# tmux detach
|
||||
# tmux attach
|
||||
#
|
||||
# Check:
|
||||
# tmux info | grep Tc
|
||||
#
|
||||
# it should not be Tc: [missing]
|
||||
source ~/.bashrc
|
||||
is_present=$(find $search_dir -type $type -name $name | head -1)
|
||||
fi
|
||||
|
||||
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=no \
|
||||
--enable-cscope \
|
||||
--prefix=$DIR
|
||||
|
||||
# Issue in wayland header file. Hence, running this.
|
||||
cd ~/vim/src/auto/wayland/
|
||||
make
|
||||
|
||||
cd ~/vim/src
|
||||
make VIMRUNTIMEDIR=$DIR/share/vim/vim91
|
||||
checkStatus 0
|
||||
return $is_present
|
||||
}
|
||||
|
||||
# To track the source build as a package for easy uninstallation.
|
||||
$user apt install checkinstall
|
||||
cd ~/vim/src
|
||||
# checkPkgIsInstalled <pkg-name> {(opt)number -- whether to install the package}
|
||||
# number - 1 to install or 0 to not install. Defualt = 0
|
||||
# return 255 -- Not installed
|
||||
# return 0 -- Installed
|
||||
function checkPkgIsInstalled {
|
||||
|
||||
if [ $# -lt 1 ] ; then
|
||||
echo "Atleast pass the package-name.\nExiting the script due to incorrect usage of /'checkPkgIsInstalled/' function"
|
||||
exit $RETURN_FAILURE
|
||||
fi
|
||||
pkg_name=$1
|
||||
|
||||
if [ '/usr/local' = $DIR ]; then
|
||||
$user checkinstall --fstrans=no # To avoid temporary filesystem translation issue.
|
||||
to_install=0
|
||||
if [ $# -gt 1 ] ; then
|
||||
to_install=$2
|
||||
fi
|
||||
|
||||
is_installed=$(dpkg-query -W -f='${binary:Package}\n' | grep -wo 'qmake' | head -1)
|
||||
if [ '$is_installed' = '$pkg_name' ] ; then
|
||||
echo "$pkg_name is already installed"
|
||||
return $RETURN_SUCCESS # Installed
|
||||
else
|
||||
make install
|
||||
if [ $to_install -eq 1 ] ; then
|
||||
echo "Installing the package: $pkg_name"
|
||||
sudo apt install $pkg_name -y
|
||||
checkStatus 0 "Unsuccessful in installing $pkg_name"
|
||||
status=$?
|
||||
if [ $status -eq 0 ] ; then
|
||||
echo "$pkg_name is installed"
|
||||
return $RETURN_SUCCESS # Installation success
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#Symbolic just in case.
|
||||
$user ln -s $DIR/share/vim/vim91 /usr/share/vim || {
|
||||
$user rm -rf /usr/share/vim
|
||||
$user ln -s $DIR/share/vim/vim91 /usr/share/vim
|
||||
}
|
||||
|
||||
# Install plugin for vim-plug.
|
||||
vim +PlugInstall +qall
|
||||
return $RETURN_FAILURE # Not Installed
|
||||
}
|
||||
|
||||
|
||||
# To remove vim
|
||||
function removeVim {
|
||||
|
||||
# Uninstall Vim
|
||||
$user apt purge -y vim
|
||||
|
||||
$user apt purge -y libncurses-dev libatk1.0-dev \
|
||||
libcairo2-dev libx11-dev libxpm-dev libxt-dev \
|
||||
libpython3-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
|
||||
#checkReposIsCloned <repo> <path> {(opt)to be cloned or not} {(opt)to clone recursively} {(opt)
|
||||
#hosting platform}
|
||||
#{ to be cloned or not} : 1 for clonning , 0 for not clonning
|
||||
#{ to clone recursively} : 1 for YES, 0 for no
|
||||
function checkRepoIsCloned {
|
||||
|
||||
if [ $# -lt 2 ] ; then
|
||||
echo "Atleast mention the Repo and the path to where it is cloned"
|
||||
echo "Exiting the script due to incorrect usage of function /'checkRepoIsCloned/'"
|
||||
exit $RETURN_FAILURE
|
||||
fi
|
||||
|
||||
rm -rf ~/.vim/
|
||||
repo=$1
|
||||
path=$2
|
||||
to_cloned=0
|
||||
if [ $# -gt 2 ] ; then
|
||||
to_cloned=1
|
||||
fi
|
||||
|
||||
$user rm -rf /usr/share/vim
|
||||
is_recursive=0
|
||||
if [ $# -gt 2 ] ; then
|
||||
is_recursive=$3
|
||||
fi
|
||||
|
||||
repo_hosting_platform=$REPO_HOSTING_PLATFORM
|
||||
if [ $# -gt 3 ] ; then
|
||||
repo_hosting_platform=$4
|
||||
fi
|
||||
|
||||
findFileOrDir "$1" "$2" "d" "1"
|
||||
is_dir_present=$?
|
||||
if [ "$is_dir_present" != "$2/$1" ] ; then
|
||||
if [ $to_cloned -eq 1 ] ; then
|
||||
if [ $is_recursize -eq 1 ] ; then
|
||||
git clone --recurse-submodules "$repo_hosting_platform/$repo.git" "$path"
|
||||
else
|
||||
git clone "$repo_hosting_platorm/$repo.git" "$path"
|
||||
fi
|
||||
|
||||
checkStatus 0 "Unsuccessful in cloning the repo: $repo"
|
||||
status=$?
|
||||
if [ $status -eq 0 ] ; then
|
||||
echo "Successfully cloned the repo: $repo"
|
||||
return $RETURN_SUCCESS #Clonned successfully
|
||||
fi
|
||||
else
|
||||
echo "Repo : $repo is not present."
|
||||
fi
|
||||
else
|
||||
echo "Repo: $repo is already present"
|
||||
return $RETURN_SUCCESS # Repo present
|
||||
fi
|
||||
|
||||
return $RETURN_FAILURE # Repo not present
|
||||
}
|
||||
|
||||
function setUpVimrc {
|
||||
check_vimrc_location=$(find $HOME -maxdepth 1 -type f -name ".vimrc" | head -1)
|
||||
checkStatus 1
|
||||
|
||||
if [ "$check_vimrc_location" = "$HOME/.vimrc" ] ; then
|
||||
if [ "$(tail -1 $HOME/.vimrc)" != "\" My vimrc end -- Hizenberg" ] ; then
|
||||
mv $HOME/.vimrc $HOME/.vimrc.bck
|
||||
checkStatus 1
|
||||
cp $my_vimrc $HOME/
|
||||
checkStatus 1
|
||||
mv $HOME/.my_vimrc $HOME/.vimrc
|
||||
checkStatus 1
|
||||
else
|
||||
echo "My vimrc is already present"
|
||||
return $RETURN_SUCCESS
|
||||
fi
|
||||
else
|
||||
cp $my_vimrc $HOME/
|
||||
checkStatus 1
|
||||
mv $HOME/.my_vimrc $HOME/.vimrc
|
||||
checkStatus 1
|
||||
fi
|
||||
|
||||
echo "My vimrc setup is done!!!"
|
||||
return $RETURN_SUCCESS
|
||||
}
|
||||
|
||||
function getVimVersion {
|
||||
version=$(vim --version | head -n 1 | awk '{print $5}')
|
||||
checkStatus 1
|
||||
version=$(echo "$ver_num" | bc -l)
|
||||
checkStatus 1
|
||||
|
||||
return version
|
||||
}
|
||||
|
||||
function setUpPluginDir {
|
||||
is_dir_present=$(find $HOME -maxdepth 1 -type d -name ".vim")
|
||||
checkStatus 1
|
||||
|
||||
if [ "$is_dir_present" != "$HOME/.vim" ] ; then
|
||||
mkdir -p $HOME/.vim/pack/default/start
|
||||
mkdir -p $HOME/.vim/pack/default/opt
|
||||
checkStatus 1 "Couldn't create plugin directory"
|
||||
|
||||
echo ".vim directory is created for plugins"
|
||||
else
|
||||
echo ".vim directoyr is already present for plugins"
|
||||
fi
|
||||
return $RETURN_SUCCESS
|
||||
}
|
||||
|
||||
|
||||
|
||||
function setUpYCM {
|
||||
|
||||
checkRepoIsCloned "${optional_plugins[ ${#optional_plugins[@]} - 1 ] }.git" "$HOME/.vim/pack/default/opt/" 1 1
|
||||
|
||||
# To setup YouCompleteMe (YCM)
|
||||
|
||||
function settingUpYCM {
|
||||
cd ~/
|
||||
checkPkgIsInstalled "build-essential" 1
|
||||
checkPkgIsInstalled "cmake3" 1
|
||||
checkPkgIsInstalled "python3-dev" 1
|
||||
|
||||
# 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
|
||||
cd ~/.vim/pack/default/opt/YouCompleteMe
|
||||
|
||||
# Install CMake and Python
|
||||
$user apt install -y build-essential cmake python3-dev
|
||||
|
||||
# Compile YCM
|
||||
cd ~/.vim/bundle/YouCompleteMe
|
||||
python3 install.py --clangd-completer
|
||||
checkStatus 0 "Failure!!! YCM is not configured for C/C++ projects"
|
||||
status=$?
|
||||
|
||||
return $status
|
||||
}
|
||||
|
||||
|
||||
function setUpCodeQuery {
|
||||
req_packages=(
|
||||
build-essential,
|
||||
g++,
|
||||
git,
|
||||
cmake,
|
||||
ninja-build,
|
||||
sqlite3,
|
||||
libsqlite3-dev,
|
||||
cscope,
|
||||
pycscope,
|
||||
starscope,
|
||||
universal-ctags
|
||||
)
|
||||
|
||||
# Removing the YCM
|
||||
gui_packages=(
|
||||
libglx-dev,
|
||||
libgl1-mesa-dev,
|
||||
libvulkan-dev,
|
||||
libxkbcommon-dev,
|
||||
qt6-base-dev,
|
||||
qt6-base-dev-tools,
|
||||
qt6-tools-dev,
|
||||
qt6-tools-dev-tools,
|
||||
libqt6core5compact6-dev,
|
||||
qt6-l10n-tools,
|
||||
qt6-wayland
|
||||
)
|
||||
|
||||
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
|
||||
for (( i=0 ; i < ${#req_packages[@]} ; i++ ))
|
||||
do
|
||||
checkPkgIsInstalled "$req_packages[ $i ]" 1
|
||||
status=$?
|
||||
|
||||
if [ $status -ne 0 ] ; then
|
||||
return $RETURN_FAILURE
|
||||
fi
|
||||
done
|
||||
|
||||
checkRepoIsCloned "ruben2020/codequery" "$ORIGINAL_DIR" 1
|
||||
status=$?
|
||||
if [ $status -ne 0 ] ; then
|
||||
return $RETURN_FAILURE
|
||||
fi
|
||||
|
||||
findFileOrDir "codequery" "$HOME/tools" "d" "2"
|
||||
is_dir_present=$?
|
||||
if [ "$is_dir_present" != "$HOME/tools/codequery" ] ; then
|
||||
mkdir -p $HOME/tools/codequery
|
||||
fi
|
||||
|
||||
cd $ORIGINAL_DIR/codequery
|
||||
|
||||
if [ "$CODEQUERY_GUI" = "YES" ] ; then
|
||||
for (( i=0 ; i < ${#gui_packages[@]} ; i++ ))
|
||||
do
|
||||
checkPkgIsInstalled "$gui_packages[ $i ]" 1
|
||||
status=$?
|
||||
|
||||
if [ $status -ne 0 ] ; then
|
||||
return $RETURN_FAILURE
|
||||
fi
|
||||
done
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$HOME/tools/codequery" -G Ninja -S . -B build
|
||||
else
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$HOME/tools/codequery" -G Ninja -DNO_GUI=ON -S . -B build
|
||||
fi
|
||||
|
||||
cmake --build build
|
||||
sudo cmake --install build
|
||||
}
|
||||
|
||||
|
||||
################ Starting the execution here ###################
|
||||
# If directory is mentioned.
|
||||
opts=$(getopt -o a --long help,dir::,mode: -- "$@")
|
||||
eval set -- "$opts"
|
||||
|
||||
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 [E.g: --dir=$HOME/Vim ]\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
|
||||
function setUpVimCodeQuery {
|
||||
|
||||
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
|
||||
checkRepoIsCloned "Shougo/unite.vim" "$HOME/.vim/pack/default/opt/" 1
|
||||
status=$?
|
||||
if [ $status -ne 0 ] ; then
|
||||
return $RETURN_FAILURE
|
||||
fi
|
||||
|
||||
removeYCM
|
||||
$user apt clean
|
||||
else
|
||||
echo "Wrong argument to --mode option"\
|
||||
"Use env_set.sh --help"
|
||||
exit 1
|
||||
fi
|
||||
checkReposIsCloned "devjoe/vim-codequery" "$HOME/.vim/pack/default/opt/" 1
|
||||
status=$?
|
||||
if [ $status -ne 0 ] ; then
|
||||
return $RETURN_FAILURE
|
||||
fi
|
||||
|
||||
return $RETURN_SUCCESS
|
||||
}
|
||||
|
||||
BANNER=$(<banner.txt)
|
||||
echo "$BANNER"
|
||||
|
||||
|
||||
|
||||
|
||||
263
my_vimrc
Normal file
263
my_vimrc
Normal file
@@ -0,0 +1,263 @@
|
||||
" c: Automatically break comments using the textwidth value.
|
||||
" r: Automatically insert the comment leader when hitting <Enter> in insert mode.
|
||||
" o: Automatically insert the comment leader when hitting 'o' or 'O' in normal mode.
|
||||
" n: Recognize numbered lists. When hitting <Enter> in insert mode.
|
||||
" m: Automatically break the current line before inserting a new comment line.
|
||||
set formatoptions+=cronm
|
||||
|
||||
" This sets the width of a tab character to 4 spaces.
|
||||
set tabstop=4
|
||||
|
||||
" This sets the number of spaces used when the <Tab> key is pressed in insert
|
||||
" mode to 4.
|
||||
set softtabstop=4
|
||||
|
||||
" This sets the number of spaces used for each indentation level when using
|
||||
" the '>' and '<' commands, as well as the autoindent feature.
|
||||
set shiftwidth=4
|
||||
|
||||
" This setting enables automatic indentation, which will copy the indentation
|
||||
" of the current line when starting a new line.
|
||||
set autoindent
|
||||
set smartindent
|
||||
|
||||
" This disables the automatic conversion of tabs to spaces when you press the
|
||||
" <Tab> key.
|
||||
set expandtab
|
||||
set smarttab
|
||||
|
||||
" Save 1,000 items in history
|
||||
set history=1000
|
||||
|
||||
" Show the line and column number of the cursor position
|
||||
set ruler
|
||||
|
||||
" Display the incomplete commands in the bottom right-hand side of your screen.
|
||||
set showcmd
|
||||
|
||||
" Display completion matches on your status line
|
||||
set wildmenu
|
||||
|
||||
" Show a few lines of context around the cursor
|
||||
set scrolloff=5
|
||||
|
||||
" Highlight search matches
|
||||
set hlsearch
|
||||
|
||||
" Enable incremental searching
|
||||
set incsearch
|
||||
|
||||
" Ignore case when searching
|
||||
set ignorecase
|
||||
|
||||
" Override the 'ignorecase' option if the search pattern contains upper case characters.
|
||||
set smartcase
|
||||
|
||||
" This enables the use of the mouse in all modes (normal, visual, insert,
|
||||
" command-line, etc.).
|
||||
set mouse=a
|
||||
|
||||
" This displays relative line numbers in the left margin.
|
||||
set number
|
||||
set relativenumber
|
||||
|
||||
" This disables the creation of backup files.
|
||||
set nobackup
|
||||
|
||||
" To allow moving to different buffer without saving the current buffer.
|
||||
set hidden
|
||||
|
||||
" This disables the creation of swap files.
|
||||
set noswapfile
|
||||
|
||||
" Automatically reload files when they change
|
||||
set autoread
|
||||
|
||||
" Enable spell checking
|
||||
"set spell
|
||||
"set spelllang=en
|
||||
|
||||
" Highlight the current line
|
||||
"set cursorline
|
||||
|
||||
" Highlight the 100th column
|
||||
" set colorcolumn=100
|
||||
|
||||
" Set text width to 100
|
||||
set textwidth=100
|
||||
|
||||
" This maps the '<' and '>' keys in visual mode to shift the selected text one
|
||||
" shift width to the left or right and reselect the shifted text.
|
||||
vnoremap < <gv
|
||||
vnoremap > >gv
|
||||
|
||||
" The next four lines define key mappings for switching between windows using
|
||||
" Ctrl + hjkl keys
|
||||
nmap <silent> <c-k> :wincmd k<CR>
|
||||
nmap <silent> <c-j> :wincmd j<CR>
|
||||
nmap <silent> <c-h> :wincmd h<CR>
|
||||
nmap <silent> <c-l> :wincmd l<CR>
|
||||
|
||||
" The next four lines define key mappings for resizing windows using Alt +
|
||||
" hjkl keys:
|
||||
map <a-l> :vertical res -5<CR>
|
||||
map <a-h> :vertical res +5<CR>
|
||||
map <a-j> :res -5<CR>
|
||||
map <a-k> :res +5<CR>
|
||||
|
||||
" These lines define key mappings for moving the cursor 10 spaces at a time
|
||||
" using Shift + arrow keys:
|
||||
nmap <S-l> 10l<CR>
|
||||
nmap <S-h> 10h<CR>
|
||||
nmap <S-j> 10j<CR>
|
||||
nmap <S-k> 10k<CR>
|
||||
|
||||
" Enable folding
|
||||
set foldenable
|
||||
" Configure fold method
|
||||
set foldmethod=marker
|
||||
" Set the fold level to start with all folds open
|
||||
set foldlevelstart=99
|
||||
" Set the fold nesting level (default is 20)
|
||||
set foldnestmax=10
|
||||
" Automatically close folds when the cursor leaves them
|
||||
set foldclose=all
|
||||
" Open folds upon all motion events
|
||||
set foldopen=all
|
||||
|
||||
|
||||
"Plugin
|
||||
"===========================================================================================================
|
||||
filetype plugin indent on
|
||||
syntax on
|
||||
|
||||
|
||||
" Enhanced C and C++ highlighting for vim
|
||||
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
" Disable function highlighting (affects both C and C++ files)
|
||||
let g:cpp_function_highlight = 1
|
||||
|
||||
" Enable highlighting of C++11 attributes
|
||||
let g:cpp_attributes_highlight = 1
|
||||
|
||||
" Highlight struct/class member variables (affects both C and C++ files)
|
||||
let g:cpp_member_highlight = 1
|
||||
|
||||
" Disable highlighting of type names in class, struct, union, enum, using, and
|
||||
" concept declarations (affects both C and C++ files)
|
||||
let g:cpp_type_name_highlight = 1
|
||||
|
||||
" Highlight operators (affects both C and C++ files)
|
||||
let g:cpp_operator_highlight = 1
|
||||
|
||||
" Put all standard C and C++ keywords under Vim's highlight group 'Statement'
|
||||
" (affects both C and C++ files)
|
||||
let g:cpp_simple_highlight = 1
|
||||
|
||||
|
||||
" Color scheme for vim
|
||||
" vscode
|
||||
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
" If you don't like many colors and prefer the conservative style of the standard Visual Studio
|
||||
let g:codedark_conservative=1
|
||||
" If you like the new dark modern colors (Needs feedback!)
|
||||
let g:codedark_modern=1
|
||||
" Activates italicized comments (make sure your terminal supports italics)
|
||||
let g:codedark_italics=1
|
||||
" Make the background transparent
|
||||
let g:codedark_transparent=1
|
||||
" If you have vim-airline, you can also enable the provided theme
|
||||
let g:airline_theme = 'codedark'
|
||||
|
||||
colorscheme codedark
|
||||
|
||||
" Tagbar
|
||||
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
nmap <F8> :TagbarToggle<CR>
|
||||
|
||||
|
||||
" Airline
|
||||
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
" Set this. Airline will handle the rest.
|
||||
" let g:airline#extensions#ale#enabled = 1
|
||||
let g:airline_theme = 'dark'
|
||||
let g:airline#extensions#tabline#enabled = 1
|
||||
let g:airline#extensions#tabline#formatter = 'default'
|
||||
|
||||
|
||||
" YCM : YouCompleteMe
|
||||
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
function! s:YCMEnable() abort
|
||||
silent! packadd YouCompleteMe
|
||||
echo "YouCompleteMe enabled"
|
||||
endfunction
|
||||
|
||||
command! YCMOn call s:YCMEnable()
|
||||
|
||||
|
||||
" ALE : Linting
|
||||
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
function! s:ALEEnable() abort
|
||||
silent! packadd ale
|
||||
|
||||
let g:ale_linters = {
|
||||
\ 'cpp': ['cppcheck'],
|
||||
\ 'c': ['cppcheck'],
|
||||
\ }
|
||||
|
||||
" General settings
|
||||
let g:ale_linters_explicit = 1
|
||||
let g:ale_completion_enabled = 1
|
||||
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
|
||||
let g:ale_set_balloons=1
|
||||
let g:ale_hover_to_floating_preview=1
|
||||
let g:ale_use_global_executables = 1
|
||||
let g:ale_sign_column_always = 1
|
||||
let g:ale_disable_lsp = 1
|
||||
|
||||
" Set this. Airline will handle the rest.
|
||||
let g:airline#extensions#ale#enabled = 1
|
||||
|
||||
echo "ALE enabled"
|
||||
endfunction
|
||||
|
||||
function! s:ALEDisable() abort
|
||||
|
||||
let g:ale_linters = {
|
||||
\ 'cpp': [''],
|
||||
\ 'c': [''],
|
||||
\ }
|
||||
|
||||
" General settings
|
||||
let g:ale_linters_explicit = 0
|
||||
let g:ale_completion_enabled = 0
|
||||
let g:ale_echo_msg_format = ''
|
||||
let g:ale_set_balloons = 0
|
||||
let g:ale_hover_to_floating_preview = 0
|
||||
let g:ale_use_global_executables = 0
|
||||
let g:ale_sign_column_always = 0
|
||||
let g:ale_disable_lsp = 0
|
||||
|
||||
" Set this. Airline will handle the rest.
|
||||
let g:airline#extensions#ale#enabled = 0
|
||||
|
||||
echo "ALE disabled"
|
||||
endfunction
|
||||
|
||||
command! ALEOn call s:ALEEnable()
|
||||
command! ALEOff call s:ALEDisable()
|
||||
|
||||
function! s:CodeQueryEnable() abort
|
||||
silent! packadd unite.vim
|
||||
silent! packadd vim-codequery
|
||||
|
||||
echo "CodeQuery setup done"
|
||||
endfunction
|
||||
|
||||
command! CQOn call s:CodeQueryEnable()
|
||||
|
||||
" My vimrc end -- Hizenberg
|
||||
Reference in New Issue
Block a user