Added a new script that can be used to update the repo if bash is
available. Updated the README. Improved the theme by adding a bunch
of syntax highlighting definitions (mostly rooted in html, though
a bunch of other languages base their colours on it), as well as
tweaking visual selection to longer invert on the block with the cursor,
and parenthesis matching to look the same at both ends. Added a plugin
that improves the theme and adds some keyboard shortcuts to markdown,
which is what the README.md files in Github are written in. I realized
that the h,j,k,l shortcuts equivalent to the ones with arrow keys I'd
added were overwriting other shortcuts with the shift combinations, so
I removed those and the ctrl-ones for consistency. The diff shortcuts
weren't intuitive or easy on the hands, so I tried something else and
I think it works much better now (check vim/keyboard.vim). An update
script has also been added to simplify updating submodules; I'm not
completely clear as to whether following this method will properly
update the submodules in certain conditions like when one is removed,
but this should add new ones and update the existing ones after pulling
from the repo.
2014-04-01 00:03:52 -04:00
#!/usr/bin/env bash
2015-01-21 01:51:48 -05:00
#
# Darkcloud Vim Config Update Tool
# https://github.com/prurigro/darkcloud-vimconfig
#
# Written by Kevin MacMartin (prurigro@gmail.com)
# Released under the MIT license
#
SCRIPT_NAME="${0//*\/}"
SCRIPT_HOME="${0%/*}"
VERSION="$(printf "%s.r%s" "$(git show -s --format=%ci master | sed 's/\ .*//g;s/-//g')" "$(git rev-list --count HEAD)")"
ERRORLOG='update-errors.log'
[[ -t 1 ]] && {
C_BGBLUE='\e[44m'
C_BGRED_BOLD='\e[1;41m'
C_BGBLACK='\e[40m'
C_BGYELLOW='\e[43m'
C_FGGREEN_BOLD='\e[1;32m'
C_FGRED_BOLD='\e[1;31m'
C_FGWHITE_BOLD='\e[1;37m'
C_RESET='\e[0m'
} || \
C_BGBLUE='#'
# error: output and log error
2014-06-16 05:37:52 -04:00
function error() {
2015-01-21 01:51:48 -05:00
echo -e "$C_BGBLUE $C_RESET$C_BGRED_BOLD ! ERROR: $C_RESET$C_FGRED_BOLD $2 "
echo -e "$C_BGBLUE $C_RESET$C_BGRED_BOLD ! COMMAND: $C_RESET ${C_FGWHITE_BOLD}=> $1$C_RESET"
[[ -n "$3" ]] \
&& echo -e "$C_BGBLUE $C_RESET$C_BGRED_BOLD ! OUTPUT: $C_RESET$C_FGWHITE_BOLD $3"
echo "DATE: @ $(date)" >> "$SCRIPT_HOME/$ERRORLOG"
echo "ERROR: $2" >> "$SCRIPT_HOME/$ERRORLOG"
echo "COMMAND: $1" >> "$SCRIPT_HOME/$ERRORLOG"
[[ -n "$3" ]] \
&& echo "OUTPUT: $3" >> "$SCRIPT_HOME/$ERRORLOG"
echo >> "$SCRIPT_HOME/$ERRORLOG"
2014-06-16 05:37:52 -04:00
}
2014-06-17 08:19:40 -04:00
# show_version: displays version information
2014-06-17 01:49:46 -04:00
function show_version() {
2015-01-21 01:51:48 -05:00
echo -e "$SCRIPT_NAME: darkcloud-vimconfig update tool (version: $VERSION)"
2014-06-17 01:49:46 -04:00
}
2014-06-17 08:19:40 -04:00
# show_help: this function displays help output
2014-06-17 01:49:46 -04:00
function show_help() {
2015-01-21 01:51:48 -05:00
echo -e "\nUSAGE"
echo -e " ./$SCRIPT_NAME [OPTION]\n"
echo "OPTIONS"
echo -e " -v, --version\t| output version information and exit"
echo -e " -h, --help\t| display this help and exit\n"
echo -e "Run with no arguments to update darkcloud-vimconfig"
2014-06-17 01:49:46 -04:00
}
2014-06-17 08:19:40 -04:00
2015-01-21 01:51:48 -05:00
### SETUP
2014-06-17 08:19:40 -04:00
cd "$SCRIPT_HOME"
2014-06-17 01:49:46 -04:00
2014-06-17 08:19:40 -04:00
# delete old error log if it exists
2015-01-21 01:51:48 -05:00
[[ -f "$ERRORLOG" ]] \
&& rm "$SCRIPT_HOME/$ERRORLOG"
2014-06-17 08:19:40 -04:00
# parse for arguments (then handle them below)
2015-01-21 01:51:48 -05:00
[[ -n "$1" ]] && {
case "$1" in
-h|--help)
show_version
show_help
exit 0
;;
-v|--version)
show_version
exit 0
;;
*)
error "$ERROR" "$1 is not a valid option"
show_help
exit 1
;;
esac
}
2014-06-17 08:19:40 -04:00
2015-01-21 01:51:48 -05:00
# display script title
echo -e "\n$C_BGBLACK ~~~ DarkCloud Vimconfig Update Tool ~~~ $C_RESET"
# create vim/bundle.user if it doesn't exist
[[ ! -d 'vim/bundle.user' ]] && {
echo -ne "\n$C_BGBLUE >> Creating User Plugin Directory:$C_RESET"
PROCESS_STATUS="$(install -d 'vim/bundle.user' 2>&1)"
[[ $? = 0 ]] && {
echo -e "$C_FGGREEN_BOLD SUCCESS! $C_RESET"
} || {
echo -e "$C_FGRED_BOLD FAIL! $C_RESET"
2014-06-17 08:19:40 -04:00
error "install -d vim/bundle.user" "User plugin directory couldn't be created" "$PROCESS_STATUS"
2015-01-21 01:51:48 -05:00
}
}
# create vim/vimrc.user if it doesn't exist
[[ ! -e 'vim/vimrc.user' ]] && {
echo -ne "\n$C_BGBLUE >> Creating User Config File:$C_RESET"
PROCESS_STATUS="$(touch 'vim/vimrc.user' 2>&1)"
[[ $? = 0 ]] && {
2014-08-25 00:43:41 -04:00
echo -e '"Autostart Filer in empty buffers: (*1:filer loads in new empty buffers | 0:filer must be triggered)\n"let g:autostartfiler=1\n' >> vim/vimrc.user
echo -e '"Autocheck syntax checking: (1:start toggled on | *0:start toggled off)\n"let g:autostartchecker=0\n' >> vim/vimrc.user
echo -e '"Autoload Tagbar: (1:start open | *0:start closed)\n"let g:autostarttagbar=0\n' >> vim/vimrc.user
echo -e '"Disable automatic tag generation and highlighting: (1:force disabled tag generation and highlighting | *0:enable automatic tag generation and highlighting)\n"let g:disableautotags=0\n' >> vim/vimrc.user
echo -e '"Disable automatic linebreaking: (1:force disabled globally | *0:let the filetype decide)\n"let g:disablelinebreaks=0\n' >> vim/vimrc.user
echo -e '"Enable Powerline fonts: (1:expect powerline font | *0:expect regular font)\n"let g:powerlinefonts=0 "(set powerline font for gvim and terminal when enabled)\n' >> vim/vimrc.user
2014-07-14 10:30:02 -04:00
echo -e '"GVim font selection: (Escaping spaces and use powerline if appropriate)\nset guifont=Monospace\ 12' >> vim/vimrc.user
2015-01-21 01:51:48 -05:00
echo -e "$C_FGGREEN_BOLD SUCCESS! $C_RESET"
} || {
echo -e "$C_FGRED_BOLD FAIL! $C_RESET"
2014-06-17 08:19:40 -04:00
error "touch vim/vimrc.user" "User config couldn't be created" "$PROCESS_STATUS"
2015-01-21 01:51:48 -05:00
}
}
2014-06-16 05:37:52 -04:00
2015-01-21 01:51:48 -05:00
### REPO UPDATE
echo -ne "\n$C_BGBLUE >> Updating Repository:$C_RESET"
PROCESS_STATUS="$(git pull origin master 2>&1)"
[[ $? = 0 ]] && {
echo -e "$C_FGGREEN_BOLD SUCCESS! $C_RESET"
} || {
echo -e "$C_FGRED_BOLD FAIL! $C_RESET"
2014-06-17 08:19:40 -04:00
error "git pull origin master" "Git failed to sync the repo" "$PROCESS_STATUS"
2014-06-16 05:37:52 -04:00
exit 1
2015-01-21 01:51:48 -05:00
}
2014-06-17 08:19:40 -04:00
2015-01-21 01:51:48 -05:00
### SUBMODULE UPDATE {
echo -e "\n$C_BGBLUE >> Updating Plugin Submodules >> $C_RESET"
echo -ne "$C_BGBLUE $C_RESET$C_BGYELLOW + Updating Plugin URLs:$C_RESET"
PROCESS_STATUS="$(git submodule sync 2>&1)"
[[ $? = 0 ]] && {
echo -e "$C_FGGREEN_BOLD SUCCESS! $C_RESET"
} || {
echo -e "$C_FGRED_BOLD FAIL! $C_RESET"
2014-06-17 08:19:40 -04:00
error "git submodule sync" "Git failed to sync the submodules" "$PROCESS_STATUS"
2015-01-21 01:51:48 -05:00
}
2014-06-16 05:37:52 -04:00
2014-06-17 08:19:40 -04:00
# update each submodule to the new head and run 'git fetch --all'
2015-01-21 01:51:48 -05:00
echo -ne "$C_BGBLUE $C_RESET$C_BGYELLOW + Fetching Updates:$C_RESET"
PROCESS_STATUS="$(git submodule foreach git fetch --all 2>&1)"
[[ $? = 0 ]] && {
2014-06-17 08:19:40 -04:00
PROCESS_STATUS=$(git submodule update --init --recursive 2>&1)
2015-01-21 01:51:48 -05:00
[[ $? = 0 ]] && {
echo -e "$C_FGGREEN_BOLD SUCCESS! $C_RESET"
} || {
echo -e "$C_FGRED_BOLD FAIL! $C_RESET"
2014-06-17 08:19:40 -04:00
error "git submodule update --init --recursive" "Git failed to update the submodules" "$PROCESS_STATUS"
2015-01-21 01:51:48 -05:00
}
} || {
echo -e "$C_FGRED_BOLD FAIL! $C_RESET"
2014-06-17 08:19:40 -04:00
error "git submodule foreach git fetch --all" "Git failed to fetch the submodules from their respective remotes" "$PROCESS_STATUS"
2015-01-21 01:51:48 -05:00
}
2014-05-05 08:57:38 -04:00
2014-06-17 08:19:40 -04:00
# run 'git checkout origin/master' on each submodule
2015-01-21 01:51:48 -05:00
echo -ne "$C_BGBLUE $C_RESET$C_BGYELLOW + Checking Out Updates:$C_RESET"
PROCESS_STATUS="$(git submodule foreach git checkout -f origin/master 2>&1)"
[[ $? = 0 ]] && {
echo -e "$C_FGGREEN_BOLD SUCCESS! $C_RESET"
} || {
echo -e "$C_FGRED_BOLD FAIL! $C_RESET"
2014-06-17 08:19:40 -04:00
error "git submodule foreach git checkout -f origin/master" "Git failed to checkout the submodules into origin/master" "$PROCESS_STATUS"
2015-01-21 01:51:48 -05:00
}
Tons of changes all in one commit because I'd broken a commit a while
back and opted to simply reverse them all- Lots of colour changes, the
update script now removes decommissioned bundles, gentags script can now
have additional paths added to it when generating a tags file, README is
much improved, fixed a few issues that required remapping some toggles,
fixed a bunch of issues with the colourscheme between the terminal and
gvim. You can now setup a custom config file to have loaded after the
darkcloud-vimconfig ones, and there's a custom location for pathogen
modules too, to make things tidier without necessarily needing to use
an additional runtimepath. You can also create a file in your home
directory to assign filetypes to programs, for use with the file
manager. A file can be placed in ~/.vim/ with file associations and
prorams to launch them with. The file manager will also open a file with
vim by hitting shift+enter, since e isn't all that comfortablly placed.
The vimrc can now also point to the darkcloud-vimconfig folder, rather
than relying on the vim folder being in a specific location, and the
after folder is now configured to work in the project too.
2014-04-04 19:49:02 -04:00
2014-06-16 05:37:52 -04:00
# clean plugin directories and remove plugins no longer in the repo
2015-01-21 01:51:48 -05:00
echo -e "\n$C_BGBLUE >> Cleaning Plugin Directories >> $C_RESET"
echo -ne "$C_BGBLUE $C_RESET$C_BGYELLOW + Removing Untracked Files:$C_RESET"
git submodule foreach git clean -dxf >/dev/null \
&& echo -e "$C_FGGREEN_BOLD SUCCESS! $C_RESET" \
|| echo -e "$C_FGRED_BOLD FAIL! $C_RESET"
[[ -f '.gitmodules' ]] && {
for plugin in vim/bundle/*; do
[[ -f "$plugin/.git" ]] && {
FILE=$(echo $plugin | grep -o -e "[^\/]*$")
[[ $(cat .gitmodules | grep "path = " | grep -o -e "[^\/]*$" | grep -c -e "${FILE}$") = 0 ]] && {
[[ -z "$FIRST_OLD" ]] && export FIRST_OLD=1 && echo -ne "$C_BGBLUE $C_RESET$C_BGYELLOW + Removing Old Plugins: $C_RESET\n"
PROCESS_STATUS=$(rm -rf "$plugin")
[[ $? = 0 ]] && {
echo -e "$C_BGBLUE $C_RESET$C_BGYELLOW = $C_RESET$(echo $plugin\ | sed -re 's|^(.*)/([^/]*)$|\\e\[1;37m\1/\\e\[1;31m\2\\e\[0m|')"
} || {
error "rm -rf $plugin" "Folder couldn't be deleted" "$PROCESS_STATUS"
2014-06-16 05:37:52 -04:00
exit 1
2015-01-21 01:51:48 -05:00
}
}
}
done
echo
}
2014-06-17 08:19:40 -04:00
2015-01-21 01:51:48 -05:00
### USER PLUGIN UPDATE
[[ -d vim/bundle.user ]] && [[ $(find vim/bundle.user -mindepth 3 -maxdepth 3 -name config | grep '.git/config') ]] && {
echo -e "$C_BGBLUE >> Updating User Plugins >> $C_RESET"
pushd vim/bundle.user >/dev/null
for plugin in *; do
[[ -d "$plugin/.git" ]] && {
pushd "$plugin" >/dev/null
echo -ne "$C_BGBLUE $C_RESET$C_BGYELLOW + Updating 'vim/bundle.user/$plugin':$C_RESET"
PROCESS_STATUS=$(git pull origin master 2>&1)
[[ $? = 0 ]] && {
[[ $(echo $PROCESS_STATUS | grep -c "Already up-to-date") = 0 ]] \
&& echo -e "$C_FGGREEN_BOLD SUCCESS! $C_RESET" \
|| echo -e "$C_FGWHITE_BOLD UP TO DATE $C_RESET"
} || error "git pull origin master" "Failed pulling changes for $plugin" "$PROCESS_STATUS"
popd >/dev/null
}
done
popd >/dev/null
echo
}
2014-06-17 08:19:40 -04:00
2015-01-21 01:51:48 -05:00
### GENERATE PLUGIN HELP
[[ $(type -P vim) ]] && {
echo -ne "$C_BGBLUE >> Generating Plugin Help:$C_RESET"
timeout --foreground 2m vim -u "$SCRIPT_HOME/vimrc" -c "Helptags|qa!" &> /dev/null
[[ $? = 0 ]] && {
echo -e "$C_FGGREEN_BOLD SUCCESS! $C_RESET"
} || {
2014-06-17 08:19:40 -04:00
reset -I
2015-01-21 01:51:48 -05:00
echo -e "$C_FGRED_BOLD FAIL! $C_RESET"
error "vim -u \"$SCRIPT_HOME/vimrc\" -c \"Helptags|qa!\"" "Generating helpdocs for the submodules failed"
}
}
echo -e "\n$C_BGBLACK ~~~ Update Complete ~~~ $C_RESET\n"
2014-04-07 19:16:58 -04:00