From 4cb5cad229bffd829d5f817474bb532794e1dd0f Mon Sep 17 00:00:00 2001 From: shaunrd0 Date: Sun, 28 Jul 2019 04:30:40 +0000 Subject: [PATCH] Update vim setup script to use Pathogen, code-completion with clang_complete, and install of supertab vim plugin. --- configs/.vimrc | 8 +--- configs/.vimrc-README | 24 ++++++++++++ scripts/configure-vim.sh | 49 ------------------------- scripts/setup-vim.sh | 79 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 55 deletions(-) create mode 100644 configs/.vimrc-README delete mode 100755 scripts/configure-vim.sh create mode 100755 scripts/setup-vim.sh diff --git a/configs/.vimrc b/configs/.vimrc index 0a92b41..881a65c 100644 --- a/configs/.vimrc +++ b/configs/.vimrc @@ -1,3 +1,5 @@ +" Single-quote is a comment written to be read +" Double-quotes ("") are commented out code and can be removed or added " Set tabwidth=2, adjust Vim shiftwidth to the same set tabstop=2 shiftwidth=2 @@ -18,9 +20,3 @@ syntax on execute pathogen#infect() filetype plugin indent on -" Enable clang_complete plugin for vim -" https://github.com/xavierd/clang_complete -" Requires clang to be installed -" Path to library may change -let g:clang_library_path='/usr/lib64/libclang.so.8' - diff --git a/configs/.vimrc-README b/configs/.vimrc-README new file mode 100644 index 0000000..83b6d02 --- /dev/null +++ b/configs/.vimrc-README @@ -0,0 +1,24 @@ +Packages Installed / Updated: +- vim, git, clang + +Vimrc Settings: +- tabwidth is 2, and set to insert SPACE characters instead of TAB symbols with expandtab +- shiftwidth is 2 so we can compensate for the conflict with default tab settings +- autoindent is on, when moving to a newline vim will indent to the current depth +- syntax highlighting is on +- mouse interaction is enabled when supported by connecting systems +-- https://github.com/shaunrd0/klips/tree/master/configs + +Plugin Settings: +- Pathogen vim plugin manager has been installed and .vimrc configured for its use. +-- Install new vim plugins by cloning their repositories into ~/.vim/bundle/ +-- https://github.com/tpope/vim-pathogen + +- Clang_complete vim plugin has been installed and .vimrc configured for its use. +- Code-completion is enabled with default clang_complete settings +-- https://github.com/xavierd/clang_complete + +- Supertab vim plugin has been installed and .vimrc configured for its use. +- Allows the use of TAB to enable code-completion context menu +-- https://github.com/ervandew/supertab + diff --git a/scripts/configure-vim.sh b/scripts/configure-vim.sh deleted file mode 100755 index 78f7264..0000000 --- a/scripts/configure-vim.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ## -## A custom bash script for building cmake projects. ## -## Intended to be ran in root directory of the project alongside CMakeLists ## -############################################################################### - -printf "\nEnter 1 to configure, 2 to revert configuration." -printf "\nAny other value will exit." -printf "\nConfiguring Vim will overwrite your current ~/.vimrc!\n" - -read cChoice - -if [ $cChoice -eq 1 ] ; then - - # Clone klips repository - - git clone https://github.com/shaunrd0/klips temp/ - - # Clean up files we don't need from the repo - mkdir config-vim - mv temp/README.md config-vim/ && mv temp/configs/ config-vim/ - rm -R temp/ - - # Replace our .vimrc in the home directory - mkdir config-vim/backup/ - mv -f ~/.vimrc config-vim/backup/.vimrc.bak - cp config-vim/configs/.vimrc ~/ - - # Reinstall Pathogen plugin manager for vim - # https://github.com/tpope/vim-pathogen - - # Remove Pathogen - rm ~/.vim/autoload/pathogen.vim - - # Install Pathogen - mkdir -p ~/.vim/autoload ~/.vim/bundle && \ - curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim - - # Remove all plugins / repositories added by config tool - rm -R ~/.vim/bundles/supertab/ - - # clone all repos into pathogen plugin directory - (cd ~/.vim/bundles/ && \ - git clone https://github.com/ervandew/supertab) - - -else -printf "\nExiting..\n" -fi - diff --git a/scripts/setup-vim.sh b/scripts/setup-vim.sh new file mode 100755 index 0000000..eb84c12 --- /dev/null +++ b/scripts/setup-vim.sh @@ -0,0 +1,79 @@ +#!/bin/bash +## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ## +## A custom bash script to configure vim with my preferred settings ## +## Run as user with sudo within directory to store / stash .vimrc configs ## +############################################################################### + +# For easy colorization of printf +GREEN=$(tput setaf 2) +RED=$(tput setaf 1) +UNDERLINE=$(tput smul) +NORMAL=$(tput sgr0) + +printf "\nEnter 1 to configure vim with the Klips repository, any other value to exit." +printf "\nThe up-to-date .vimrc config can be found here: https://github.com/shaunrd0/klips/tree/master/configs" +printf "\n${RED}Configuring Vim with this tool will update / upgrade your packages${NORMAL}\n\n" +read cChoice + +if [ $cChoice -eq 1 ] ; then + + printf "\nUpdating, upgrading required packages...\n" + sudo apt -y update && sudo apt -y upgrade + sudo apt install vim git + + # Clone klips repository in a temp directory + git clone https://github.com/shaunrd0/klips temp/ + # Relocate the files we need and remove the temp directory + mkdir -pv config-vim + mv -fuv temp/README.md config-vim/ && mv temp/configs/ config-vim/ + rm -Rf temp/ + printf "\n${GREEN}Klips config files updated"\ + "\nSee $PWD/config-vim/README.md for more information.${NORMAL}\n\n" + + # Create backup dir for .vimrc + mkdir -pv config-vim/backup/ + printf "\n${GREEN}Backup directory created - $PWD/config-vim/backup/${NORMAL}\n" + + # Stash the current .vimrc + mv -bv ~/.vimrc config-vim/backup/ + printf "${RED}Your local .vimrc has been stashed in $PWD/config-vim/backup/${NORMAL}\n\n" + + # Copy our cloned config into the user home directory + cp config-vim/configs/.vimrc ~/ + printf "${GREEN}New ~/.vimrc configuration installed.${NORMAL}\n" + + # Reinstall Pathogen plugin manager for vim + # https://github.com/tpope/vim-pathogen + printf "\n${RED}Removing any previous installations of Pathogen...${NORMAL}\n" + sudo rm -f ~/.vim/autoload/pathogen.vim + + # Install Pathogen + printf "\n${GREEN}Installing Pathogen plugin manager for Vim....\n"\ + "\nIf they don't exist, we will create the following directories:\n"\ + "~/.vim/autoload/ ~/.vim/bundle/${NORMAL}" + # Sudo is required for curl below + mkdir -pv ~/.vim/autoload ~/.vim/bundle && \ + sudo curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim + printf "\n${GREEN}Pathogen has been installed! Plugins plugins can now be easily installed.\n"\ + "Clone any plugin repositories into ~/.vim/bundles${NORMAL}\n" + + # Remove any plugins managed by this config tool (Klips) + printf "\n${RED}Removing plugins installed by this tool...${NORMAL}\n" + sudo rm -R ~/.vim/bundle/* + + # Clone plugin repos into pathogen plugin directory + printf "\n${GREEN}Installing updated plugins...${NORMAL}\n" + (cd ~/.vim/bundle/ && \ + sudo git clone https://github.com/ervandew/supertab && \ + printf "\n${GREEN}Supertab plugin has been installed${NORMAL}\n\n" && \ + sudo git clone https://github.com/xavierd/clang_complete && \ + printf "\n${GREEN}Clang Completion plugin has been installed${NORMAL}\n\n") + + printf "\n${UNDERLINE}Vim has been configured with the Klips repository.${NORMAL}" + printf "\n\nConfiguration Changes: \n" + cat config-vim/configs/.vimrc-README + +else +printf "\nExiting..\n" +fi +