From c491f0fea70b9f1405cd628267e29c5123e11753 Mon Sep 17 00:00:00 2001 From: Aaron Gutierrez Date: Sun, 29 Mar 2015 18:22:30 -0400 Subject: [PATCH] initial commit --- .bashrc | 25 + .bashrc_gpi | 221 +++ .config/i3status/config | 52 + .i3/config | 167 +++ .vim/.gitignore | 1 + .vim/.netrwhist | 8 + .vim/autoload/airline.vim | 172 +++ .vim/autoload/airline/builder.vim | 134 ++ .vim/autoload/airline/debug.vim | 50 + .vim/autoload/airline/deprecation.vim | 32 + .vim/autoload/airline/extensions.vim | 242 ++++ .vim/autoload/airline/extensions/branch.vim | 122 ++ .../airline/extensions/bufferline.vim | 23 + .vim/autoload/airline/extensions/capslock.vim | 14 + .vim/autoload/airline/extensions/commandt.vim | 16 + .vim/autoload/airline/extensions/csv.vim | 31 + .vim/autoload/airline/extensions/ctrlp.vim | 80 ++ .vim/autoload/airline/extensions/default.vim | 81 ++ .vim/autoload/airline/extensions/eclim.vim | 53 + .vim/autoload/airline/extensions/example.vim | 54 + .vim/autoload/airline/extensions/hunks.vim | 82 ++ .vim/autoload/airline/extensions/netrw.vim | 32 + .vim/autoload/airline/extensions/nrrwrgn.vim | 54 + .../airline/extensions/promptline.vim | 33 + .vim/autoload/airline/extensions/quickfix.vim | 37 + .../autoload/airline/extensions/syntastic.vim | 19 + .vim/autoload/airline/extensions/tabline.vim | 363 +++++ .../airline/extensions/tabline/default.vim | 35 + .../extensions/tabline/unique_tail.vim | 27 + .../tabline/unique_tail_improved.vim | 89 ++ .vim/autoload/airline/extensions/tagbar.vim | 45 + .vim/autoload/airline/extensions/tmuxline.vim | 26 + .vim/autoload/airline/extensions/undotree.vim | 27 + .vim/autoload/airline/extensions/unite.vim | 23 + .../airline/extensions/virtualenv.vim | 25 + .../airline/extensions/whitespace.vim | 103 ++ .../airline/extensions/windowswap.vim | 23 + .vim/autoload/airline/highlighter.vim | 159 +++ .vim/autoload/airline/init.vim | 114 ++ .vim/autoload/airline/parts.vim | 79 ++ .vim/autoload/airline/section.vim | 73 + .vim/autoload/airline/themes.vim | 67 + .vim/autoload/airline/themes/badwolf.vim | 52 + .vim/autoload/airline/themes/base16.vim | 107 ++ .vim/autoload/airline/themes/bubblegum.vim | 70 + .vim/autoload/airline/themes/dark.vim | 102 ++ .vim/autoload/airline/themes/durant.vim | 59 + .vim/autoload/airline/themes/hybrid.vim | 58 + .vim/autoload/airline/themes/jellybeans.vim | 52 + .vim/autoload/airline/themes/kalisi.vim | 70 + .vim/autoload/airline/themes/kolor.vim | 59 + .vim/autoload/airline/themes/laederon.vim | 62 + .vim/autoload/airline/themes/light.vim | 45 + .vim/autoload/airline/themes/lucius.vim | 56 + .vim/autoload/airline/themes/luna.vim | 92 ++ .vim/autoload/airline/themes/molokai.vim | 65 + .vim/autoload/airline/themes/monochrome.vim | 15 + .vim/autoload/airline/themes/murmur.vim | 82 ++ .vim/autoload/airline/themes/powerlineish.vim | 46 + .vim/autoload/airline/themes/raven.vim | 85 ++ .vim/autoload/airline/themes/serene.vim | 41 + .vim/autoload/airline/themes/silver.vim | 85 ++ .vim/autoload/airline/themes/simple.vim | 46 + .vim/autoload/airline/themes/sol.vim | 90 ++ .vim/autoload/airline/themes/solarized.vim | 176 +++ .vim/autoload/airline/themes/tomorrow.vim | 44 + .vim/autoload/airline/themes/ubaryd.vim | 64 + .vim/autoload/airline/themes/understated.vim | 43 + .vim/autoload/airline/themes/wombat.vim | 90 ++ .vim/autoload/airline/themes/zenburn.vim | 44 + .vim/autoload/airline/util.vim | 64 + .vim/autoload/xolox/easytags.vim | 910 +++++++++++++ .vim/autoload/xolox/easytags/filetypes.vim | 139 ++ .vim/autoload/xolox/easytags/update.vim | 288 ++++ .vim/autoload/xolox/easytags/utils.vim | 20 + .vim/autoload/xolox/misc.vim | 7 + .vim/autoload/xolox/misc/async.vim | 261 ++++ .vim/autoload/xolox/misc/buffer.vim | 80 ++ .vim/autoload/xolox/misc/complete.vim | 26 + .vim/autoload/xolox/misc/cursorhold.vim | 71 + .vim/autoload/xolox/misc/echo.exe | Bin 0 -> 7680 bytes .vim/autoload/xolox/misc/escape.vim | 56 + .vim/autoload/xolox/misc/format.vim | 46 + .vim/autoload/xolox/misc/list.vim | 42 + .vim/autoload/xolox/misc/msg.vim | 129 ++ .vim/autoload/xolox/misc/open.vim | 100 ++ .vim/autoload/xolox/misc/option.vim | 115 ++ .vim/autoload/xolox/misc/os.vim | 271 ++++ .vim/autoload/xolox/misc/path.vim | 278 ++++ .vim/autoload/xolox/misc/perm.vim | 100 ++ .vim/autoload/xolox/misc/persist.vim | 50 + .vim/autoload/xolox/misc/str.vim | 74 + .vim/autoload/xolox/misc/test.vim | 125 ++ .vim/autoload/xolox/misc/tests.vim | 301 ++++ .vim/autoload/xolox/misc/timer.vim | 130 ++ .vim/autoload/xolox/misc/version.vim | 34 + .vim/colors/candycode.vim | 174 +++ .vim/colors/distinguished.vim | 181 +++ .vim/colors/euler.vim | 64 + .vim/colors/genericdc-light.vim | 98 ++ .vim/doc/airline.txt | 793 +++++++++++ .vim/doc/easytags.txt | 754 ++++++++++ .vim/doc/misc.txt | 1212 +++++++++++++++++ .vim/ftdetect/c-detect.vim | 3 + .vim/ftdetect/c0-detect.vim | 3 + .vim/ftdetect/jade-detect.vim | 1 + .vim/ftdetect/javascript.vim | 10 + .vim/ftdetect/setty-detect.vim | 2 + .vim/ftplugin/c.vim | 1 + .vim/ftplugin/html.vim | 2 + .vim/ftplugin/jade.vim | 2 + .vim/ftplugin/setty.vim | 26 + .vim/ftplugin/tex.vim | 2 + .vim/ftplugin/text.vim | 2 + .vim/indent/c.vim | 4 + .vim/indent/c0.vim | 4 + .vim/indent/h.vim | 4 + .vim/indent/html.vim | 4 + .vim/indent/jade.vim | 72 + .vim/indent/javascript.vim | 4 + .vim/indent/python.vim | 199 +++ .vim/indent/setty.vim | 203 +++ .vim/indent/tex.vim | 4 + .vim/misc/easytags/highlight.py | 55 + .vim/misc/easytags/normalize-tags.py | 80 ++ .vim/misc/easytags/why-so-slow.py | 39 + .vim/plugin/airline.vim | 109 ++ .vim/plugin/easytags.vim | 144 ++ .vim/plugin/xolox/misc.vim | 19 + .vim/syntax/c.vim | 3 + .vim/syntax/c0.vim | 217 +++ .vim/syntax/jade.vim | 89 ++ .vim/syntax/javascript.vim | 312 +++++ .vim/syntax/python.vim | 3 + .vim/syntax/sal.vim | 112 ++ .vim/syntax/setty.vim | 148 ++ .vim/t/airline.vim | 87 ++ .vim/t/builder.vim | 106 ++ .vim/t/commands.vim | 33 + .vim/t/extensions_default.vim | 33 + .vim/t/highlighter.vim | 21 + .vim/t/init.vim | 77 ++ .vim/t/parts.vim | 39 + .vim/t/section.vim | 76 ++ .vim/t/themes.vim | 68 + .vim/t/util.vim | 54 + 146 files changed, 14482 insertions(+) create mode 100644 .bashrc create mode 100644 .bashrc_gpi create mode 100644 .config/i3status/config create mode 100644 .i3/config create mode 100644 .vim/.gitignore create mode 100644 .vim/.netrwhist create mode 100644 .vim/autoload/airline.vim create mode 100644 .vim/autoload/airline/builder.vim create mode 100644 .vim/autoload/airline/debug.vim create mode 100644 .vim/autoload/airline/deprecation.vim create mode 100644 .vim/autoload/airline/extensions.vim create mode 100644 .vim/autoload/airline/extensions/branch.vim create mode 100644 .vim/autoload/airline/extensions/bufferline.vim create mode 100644 .vim/autoload/airline/extensions/capslock.vim create mode 100644 .vim/autoload/airline/extensions/commandt.vim create mode 100644 .vim/autoload/airline/extensions/csv.vim create mode 100644 .vim/autoload/airline/extensions/ctrlp.vim create mode 100644 .vim/autoload/airline/extensions/default.vim create mode 100644 .vim/autoload/airline/extensions/eclim.vim create mode 100644 .vim/autoload/airline/extensions/example.vim create mode 100644 .vim/autoload/airline/extensions/hunks.vim create mode 100644 .vim/autoload/airline/extensions/netrw.vim create mode 100644 .vim/autoload/airline/extensions/nrrwrgn.vim create mode 100644 .vim/autoload/airline/extensions/promptline.vim create mode 100644 .vim/autoload/airline/extensions/quickfix.vim create mode 100644 .vim/autoload/airline/extensions/syntastic.vim create mode 100644 .vim/autoload/airline/extensions/tabline.vim create mode 100644 .vim/autoload/airline/extensions/tabline/default.vim create mode 100644 .vim/autoload/airline/extensions/tabline/unique_tail.vim create mode 100644 .vim/autoload/airline/extensions/tabline/unique_tail_improved.vim create mode 100644 .vim/autoload/airline/extensions/tagbar.vim create mode 100644 .vim/autoload/airline/extensions/tmuxline.vim create mode 100644 .vim/autoload/airline/extensions/undotree.vim create mode 100644 .vim/autoload/airline/extensions/unite.vim create mode 100644 .vim/autoload/airline/extensions/virtualenv.vim create mode 100644 .vim/autoload/airline/extensions/whitespace.vim create mode 100644 .vim/autoload/airline/extensions/windowswap.vim create mode 100644 .vim/autoload/airline/highlighter.vim create mode 100644 .vim/autoload/airline/init.vim create mode 100644 .vim/autoload/airline/parts.vim create mode 100644 .vim/autoload/airline/section.vim create mode 100644 .vim/autoload/airline/themes.vim create mode 100644 .vim/autoload/airline/themes/badwolf.vim create mode 100644 .vim/autoload/airline/themes/base16.vim create mode 100644 .vim/autoload/airline/themes/bubblegum.vim create mode 100644 .vim/autoload/airline/themes/dark.vim create mode 100644 .vim/autoload/airline/themes/durant.vim create mode 100644 .vim/autoload/airline/themes/hybrid.vim create mode 100644 .vim/autoload/airline/themes/jellybeans.vim create mode 100644 .vim/autoload/airline/themes/kalisi.vim create mode 100644 .vim/autoload/airline/themes/kolor.vim create mode 100644 .vim/autoload/airline/themes/laederon.vim create mode 100644 .vim/autoload/airline/themes/light.vim create mode 100644 .vim/autoload/airline/themes/lucius.vim create mode 100644 .vim/autoload/airline/themes/luna.vim create mode 100644 .vim/autoload/airline/themes/molokai.vim create mode 100644 .vim/autoload/airline/themes/monochrome.vim create mode 100644 .vim/autoload/airline/themes/murmur.vim create mode 100644 .vim/autoload/airline/themes/powerlineish.vim create mode 100644 .vim/autoload/airline/themes/raven.vim create mode 100644 .vim/autoload/airline/themes/serene.vim create mode 100644 .vim/autoload/airline/themes/silver.vim create mode 100644 .vim/autoload/airline/themes/simple.vim create mode 100644 .vim/autoload/airline/themes/sol.vim create mode 100644 .vim/autoload/airline/themes/solarized.vim create mode 100644 .vim/autoload/airline/themes/tomorrow.vim create mode 100644 .vim/autoload/airline/themes/ubaryd.vim create mode 100644 .vim/autoload/airline/themes/understated.vim create mode 100644 .vim/autoload/airline/themes/wombat.vim create mode 100644 .vim/autoload/airline/themes/zenburn.vim create mode 100644 .vim/autoload/airline/util.vim create mode 100644 .vim/autoload/xolox/easytags.vim create mode 100644 .vim/autoload/xolox/easytags/filetypes.vim create mode 100644 .vim/autoload/xolox/easytags/update.vim create mode 100644 .vim/autoload/xolox/easytags/utils.vim create mode 100644 .vim/autoload/xolox/misc.vim create mode 100644 .vim/autoload/xolox/misc/async.vim create mode 100644 .vim/autoload/xolox/misc/buffer.vim create mode 100644 .vim/autoload/xolox/misc/complete.vim create mode 100644 .vim/autoload/xolox/misc/cursorhold.vim create mode 100644 .vim/autoload/xolox/misc/echo.exe create mode 100644 .vim/autoload/xolox/misc/escape.vim create mode 100644 .vim/autoload/xolox/misc/format.vim create mode 100644 .vim/autoload/xolox/misc/list.vim create mode 100644 .vim/autoload/xolox/misc/msg.vim create mode 100644 .vim/autoload/xolox/misc/open.vim create mode 100644 .vim/autoload/xolox/misc/option.vim create mode 100644 .vim/autoload/xolox/misc/os.vim create mode 100644 .vim/autoload/xolox/misc/path.vim create mode 100644 .vim/autoload/xolox/misc/perm.vim create mode 100644 .vim/autoload/xolox/misc/persist.vim create mode 100644 .vim/autoload/xolox/misc/str.vim create mode 100644 .vim/autoload/xolox/misc/test.vim create mode 100644 .vim/autoload/xolox/misc/tests.vim create mode 100644 .vim/autoload/xolox/misc/timer.vim create mode 100644 .vim/autoload/xolox/misc/version.vim create mode 100644 .vim/colors/candycode.vim create mode 100644 .vim/colors/distinguished.vim create mode 100644 .vim/colors/euler.vim create mode 100644 .vim/colors/genericdc-light.vim create mode 100644 .vim/doc/airline.txt create mode 100644 .vim/doc/easytags.txt create mode 100644 .vim/doc/misc.txt create mode 100644 .vim/ftdetect/c-detect.vim create mode 100644 .vim/ftdetect/c0-detect.vim create mode 100644 .vim/ftdetect/jade-detect.vim create mode 100644 .vim/ftdetect/javascript.vim create mode 100644 .vim/ftdetect/setty-detect.vim create mode 100644 .vim/ftplugin/c.vim create mode 100644 .vim/ftplugin/html.vim create mode 100644 .vim/ftplugin/jade.vim create mode 100644 .vim/ftplugin/setty.vim create mode 100644 .vim/ftplugin/tex.vim create mode 100644 .vim/ftplugin/text.vim create mode 100644 .vim/indent/c.vim create mode 100644 .vim/indent/c0.vim create mode 100644 .vim/indent/h.vim create mode 100644 .vim/indent/html.vim create mode 100644 .vim/indent/jade.vim create mode 100644 .vim/indent/javascript.vim create mode 100644 .vim/indent/python.vim create mode 100644 .vim/indent/setty.vim create mode 100644 .vim/indent/tex.vim create mode 100644 .vim/misc/easytags/highlight.py create mode 100755 .vim/misc/easytags/normalize-tags.py create mode 100755 .vim/misc/easytags/why-so-slow.py create mode 100644 .vim/plugin/airline.vim create mode 100644 .vim/plugin/easytags.vim create mode 100644 .vim/plugin/xolox/misc.vim create mode 100644 .vim/syntax/c.vim create mode 100644 .vim/syntax/c0.vim create mode 100644 .vim/syntax/jade.vim create mode 100644 .vim/syntax/javascript.vim create mode 100644 .vim/syntax/python.vim create mode 100644 .vim/syntax/sal.vim create mode 100644 .vim/syntax/setty.vim create mode 100644 .vim/t/airline.vim create mode 100644 .vim/t/builder.vim create mode 100644 .vim/t/commands.vim create mode 100644 .vim/t/extensions_default.vim create mode 100644 .vim/t/highlighter.vim create mode 100644 .vim/t/init.vim create mode 100644 .vim/t/parts.vim create mode 100644 .vim/t/section.vim create mode 100644 .vim/t/themes.vim create mode 100644 .vim/t/util.vim diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..dd6abc9 --- /dev/null +++ b/.bashrc @@ -0,0 +1,25 @@ +# This includes the bashrc distributed by 98-172 +# Great Practical Ideas for Computer Scientists +source ~/.bashrc_gpi + +# Add your own changes below... +export PATH=/nyquist:$PATH:/cc0/bin:~/bin +export EDITOR=vim +export CLICOLOR=1 +export LSCOLORS=DxGxcxdxCxegedabagacad +export TERM=xterm-256color #256 color support +PS1="\n\[\033[32m\][\w]\[\033[0m\]\n\[\033[1;36m\]\u\[\033[1;33m\]\$ \[\033[0m\]" + +export XLISPPATH=/nyquist/lib:/nyquist/runtime + +alias coin='rlwrap coin' # by-setup-c0 +#alias kinit='kinit.sh' +alias ed='ed -p:' +alias sml='rlwrap sml' +alias g='google-chrome-unstable' + +alias ocaml='rlwrap ocaml' + + +# OPAM configuration +. /home/amgutier/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true diff --git a/.bashrc_gpi b/.bashrc_gpi new file mode 100644 index 0000000..dead768 --- /dev/null +++ b/.bashrc_gpi @@ -0,0 +1,221 @@ +# Great Practical Ideas for Computer Scientists .bashrc_gpi (F13) +# DO NOT MODIFY THIS FILE; place your modifications in ~/.bashrc + +### v5: Fixes minor bugs and adds the afsperms command +### v6: Removes annoying screen issue +### v7: Changes GPI_PATH to be full, checks if file exists before using it +### v8: Adds gpi_makemake (a way to automatically generate Makefiles) +### v9: Updates semester +### v10: Update semester to f12 +### v11: Adds afsperms to gpi helptext +### v12: Adds alias for coin that allows you to use arrow keys +### v13: Updates semester, moves "current" file to CS directory +### v14: Adds unicode support; 15-151 bin +### v15: Adds a command to get CS AFS access. +### v16: Adds better support for lern2unix problems, store more command history. +### v17: Fixes a bug with ls on Mac OS X + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# Define Color Variables for later usage +c_red=$(tput setaf 1) +c_green=$(tput setaf 2) +c_yellow=$(tput setaf 3) +c_blue=$(tput setaf 4) +c_purple=$(tput setaf 5) +c_cyan=$(tput setaf 6) +c_white=$(tput setaf 7) +c_reset=$(tput sgr0) + +# Make .bash_history store more and not store duplicates +export HISTCONTROL=ignoreboth +export HISTSIZE=250000 +export HISTFILESIZE=250000 + +# Append to the history file, don't overwrite it +shopt -s histappend + +# Check the window size after each command and, if necessary, +# Update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# Make cd correct minor spelling mistakes +# This is now not a default as of v5, because we decided it has questionable behavior +# shopt -s cdspell + +# Make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe.sh ] && export LESSOPEN="|/usr/bin/lesspipe.sh %s" + +# Set the Prompt to be more reasonable +#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' + + +# Alias definitions. +alias killz='killall -9 ' +alias hidden='ls -a | grep "^\..*"' +alias rm='rm -i' +alias shell='ps -p $$ -o comm=' +alias math='rlwrap MathKernel' +alias coin='rlwrap coin' + +# C Aliases +alias cc='gcc -Wall -W -ansi -pedantic -O2 ' +alias valgrind-leak='valgrind --leak-check=full --show-reachable=yes' + +# Enable color support of ls and also add handy aliases +# Mac OS doesn't support --color flag for ls, needs -G instead. +if [[ `uname` = "Darwin" ]] +then + alias ls='ls -G' +else + alias ls='ls --color=auto' +fi + +alias grep='grep --color=auto' + +# Enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi + +bind "set completion-ignore-case on" + +# Useful Functions +afsperms(){ find $1 -type d -exec fs sa {} $2 $3 \; ; } +qdict(){ grep $1 /usr/share/dict/words; } +ldap(){ ldapsearch -b ou=person,dc=cmu,dc=edu cn=$1; } +get_cs_afs_access() { + # Script to give a user with an andrew.cmu.edu account access to cs.cmu.edu + # See https://www.cs.cmu.edu/~help/afs/cross_realm.html for information. + + # Get tokens. This might create the user, but I'm not sure that that's + # reliable, so we'll also try to do pts createuser. + aklog cs.cmu.edu + + CUR_USER=`whoami` + + pts createuser $CUR_USER@ANDREW.CMU.EDU -cell cs.cmu.edu 2>&1 | grep -v "Entry for name already exists" + + aklog cs.cmu.edu + + echo "(aklog cs.cmu.edu &)" >> ~/.bashrc +} + +# Turn off the ability for other people to message your terminal using wall +mesg n + +gpi(){ + echo "${c_red}Great Practical Ideas for Computer Scientists .bashrc_gpi${c_reset} (${GPI_VERSION})" + echo "We provide a few (useful) aliases and scripts for you to get started:" + echo " ${c_green}qdict${c_reset} -- Queries the unix dictionary" + echo " ${c_green}afsperms${c_reset} -- Recursively runs fs sa on a directory" + echo " ${c_green}cc${c_reset} -- Invokes gcc with the flags you will usually use" + echo " ${c_green}valgrind-leak${c_reset} -- Invokes valgrind in the mode to show all leaks" + echo " ${c_green}hidden${c_reset} -- Displays ONLY the hidden files" + echo " ${c_green}killz${c_reset} -- Kills all programs with the given program name" + echo " ${c_green}shell${c_reset} -- Displays the name of the shell being used" + echo " ${c_green}gpi_install${c_reset} -- Installs a configuration package provided by GPI" + echo " ${c_green}gpi_makemake${c_reset} -- Creates a Makefile for C, C0, or LaTeX projects in the current directory" + echo " ${c_green}get_cs_afs_access${c_reset} -- Sets up cross-realm authentication with CS.CMU.EDU so you can access files stored there." + echo "More features may be added later, as thought of or requested." +} + +gpi_install() { + echo "Choose a package to install:" + ls $GPI_PATH/packages + echo -n "Package: " + read package + + if [ ! -e "$GPI_PATH/packages/$package" ] + then + echo "Bad package name: $package" + return + fi + + echo "Installing $package..." + for f in `ls -A $GPI_PATH/packages/$package` + do + f=$GPI_PATH/packages/$package/$f + cmd="cp --recursive --interactive $f $HOME/" + echo "$cmd" + $cmd + done + + echo "Installed!" +} + +gpi_makemake() { + supported_extensions='tex java c c0' + found=0 + for ext in $supported_extensions; do + files=$(ls *.$ext 2> /dev/null | wc -l) + if [ "$files" != "0" ]; then + found=1 + break + fi + done + if [ "$found" == "0" ]; then + echo -e "You don't have any of the supported file types in this directory" + return + fi + + + if [ "$ext" == "tex" ]; then + echo -e "gpi_makemake is making you a LaTeX Makefile!" + if [ "$files" == "1" ]; then + file=$(echo *.${ext}) + else + echo -e "There is more than one LaTeX file in your directory..." + echo -e "Choose one from the list to be the main source file." + select file in *.$ext; do break; done + fi + + if [ "$file" == "" ]; then + echo -e "Aborting..." + else + cat ${GPI_PATH}/makefiles/latex.mk | + sed -e "s/GPIMAKEMAKE/${file%.tex}/" > Makefile + echo "gpi_makemake has installed a LaTeX Makefile for $file" + echo "${c_green}make${c_reset} -- Compiles the LaTeX document into a PDF" + echo "${c_green}make clean${c_reset} -- Removes aux and log files" + echo "${c_green}make veryclean${c_reset} -- Removes pdf, aux, and log files" + echo "${c_green}make view${c_reset} -- Display the generated PDF file" + echo "${c_green}make print${c_reset} -- Sends the PDF to print" + fi + elif [ "$ext" == "java" ]; then + echo "gpi_makemake doesn't support java yet. We will add it soon!" + elif [ "$ext" == "c" ]; then + echo -e "gpi_makemake is making you a C Makefile!" + echo -n "What should the name of the target executable be? " + read target + + cat ${GPI_PATH}/makefiles/c.mk | + sed -e "s/GPIMAKEMAKE_TARGET/${target}/" > Makefile + echo "gpi_makemake has installed a C Makefile!" + echo "${c_green}make${c_reset} -- Compiles the C Program (no debug information)" + echo "${c_green}make debug${c_reset} -- Compiles the C Program (with debugging information!)" + echo "${c_green}make run${c_reset} -- Re-compiles (if necessary) and run the program" + echo "${c_green}make clean${c_reset} -- Deletes the created object files" + echo "${c_green}make veryclean${c_reset} -- Deletes the created object files and dependencies" + elif [ "$ext" == "c0" ]; then + echo -e "gpi_makemake is making you a C0 Makefile!" + echo -n "List the C0 source files separated by spaces: " + read sources + echo -n "What should the name of the target executable be? " + read target + cat ${GPI_PATH}/makefiles/c0.mk | + sed -e "s/GPIMAKEMAKE_TARGET/${target}/" | + sed -e "s/GPIMAKEMAKE_SOURCE/${sources}/" > Makefile + echo "gpi_makemake has installed a C0 Makefile" + echo "${c_green}make${c_reset} -- Compiles the C0 Program (no debug information)" + echo "${c_green}make debug${c_reset} -- Compiles the C0 Program (with debugging information!)" + echo "${c_green}make run${c_reset} -- Re-compiles (if necessary) and run the program" + echo "${c_green}make clean${c_reset} -- Deletes the created object files" + echo "${c_green}make veryclean${c_reset} -- Deletes the created object files and dependencies" + + fi +} + diff --git a/.config/i3status/config b/.config/i3status/config new file mode 100644 index 0000000..3bbec7f --- /dev/null +++ b/.config/i3status/config @@ -0,0 +1,52 @@ +general { + colors = true + interval = 5 +} + +order += "disk /" +order += "disk /home" +order += "wireless wlan0" +order += "ethernet eth0" +order += "battery 0" +order += "load" +order += "time" + +wireless wlan0 { + format_up = "W: (%quality at %essid) %ip" + format_down = "W: down" +} + +ethernet eth0 { + # if you use %speed, i3status requires root privileges + format_up = "E: %ip (%speed)" + format_down = "E: down" +} + +battery 0 { + last_full_capacity = false + format = "%status %percentage %remaining" +} + +run_watch DHCP { + pidfile = "/var/run/dhclient*.pid" +} + +run_watch VPN { + pidfile = "/var/run/vpnc/pid" +} + +time { + format = "%m/%d/%Y %H:%M:%S" +} + +load { + format = "%1min" +} + +disk "/" { + format = "/: %free/%total" +} + +disk "/home" { + format = "/home: %free/%total" +} diff --git a/.i3/config b/.i3/config new file mode 100644 index 0000000..d49a291 --- /dev/null +++ b/.i3/config @@ -0,0 +1,167 @@ +# This file has been auto-generated by i3-config-wizard(1). +# It will not be overwritten, so edit it as you like. +# +# Should you change your keyboard layout somewhen, delete +# this file and re-run i3-config-wizard(1). +# + +# i3 config file (v4) +# +# Please see http://i3wm.org/docs/userguide.html for a complete reference! + +set $mod Mod4 + +# font for window titles. ISO 10646 = Unicode +font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 +font pango:DejaVu Sans Mono 10 + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# start a terminal +bindsym $mod+Return exec i3-sensible-terminal + +# toggle audio output +bindsym $mod+Shift+A exec audiochngout + +# kill focused window +bindsym $mod+Shift+Q kill + +# start dmenu (a program launcher) +bindsym $mod+d exec dmenu_run + +# change focus +bindsym $mod+h focus left +bindsym $mod+j focus down +bindsym $mod+k focus up +bindsym $mod+l focus right + +# alternatively, you can use the cursor keys: +bindsym $mod+Left focus left +bindsym $mod+Down focus down +bindsym $mod+Up focus up +bindsym $mod+Right focus right + +# move focused window +bindsym $mod+Shift+H move left +bindsym $mod+Shift+J move down +bindsym $mod+Shift+K move up +bindsym $mod+Shift+L move right + +# alternatively, you can use the cursor keys: +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+Up move up +bindsym $mod+Shift+Right move right + +# split in horizontal orientation +bindsym $mod+b split h + +# split in vertical orientation +bindsym $mod+v split v + +# enter fullscreen mode for the focused container +bindsym $mod+f fullscreen + +# change container layout (stacked, tabbed, default) +bindsym $mod+s layout stacking +bindsym $mod+w layout tabbed +bindsym $mod+e layout default + +# toggle tiling / floating +bindsym $mod+Shift+space floating toggle + +# change focus between tiling / floating windows +bindsym $mod+space focus mode_toggle + +# focus the parent container +bindsym $mod+a focus parent + +# focus the child container +#bindcode $mod+d focus child + +# switch to workspace +bindsym $mod+1 workspace 1 +bindsym $mod+2 workspace 2 +bindsym $mod+3 workspace 3 +bindsym $mod+4 workspace 4 +bindsym $mod+5 workspace 5 +bindsym $mod+6 workspace 6 +bindsym $mod+7 workspace 7 +bindsym $mod+8 workspace 8 +bindsym $mod+9 workspace 9 +bindsym $mod+0 workspace 10 + +# move focused container to workspace +bindsym $mod+Shift+exclam move container to workspace 1 +bindsym $mod+Shift+at move container to workspace 2 +bindsym $mod+Shift+numbersign move container to workspace 3 +bindsym $mod+Shift+dollar move container to workspace 4 +bindsym $mod+Shift+percent move container to workspace 5 +bindsym $mod+Shift+asciicircum move container to workspace 6 +bindsym $mod+Shift+ampersand move container to workspace 7 +bindsym $mod+Shift+asterisk move container to workspace 8 +bindsym $mod+Shift+parenleft move container to workspace 9 +bindsym $mod+Shift+parenright move container to workspace 10 + +# reload the configuration file +bindsym $mod+Shift+C reload +# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +bindsym $mod+Shift+R restart +# exit i3 (logs you out of your X session) +bindsym $mod+Shift+E exit + +# resize window (you can also use the mouse for that) +mode "resize" { + # These bindings trigger as soon as you enter the resize mode + + # Pressing left will shrink the window’s width. + # Pressing right will grow the window’s width. + # Pressing up will shrink the window’s height. + # Pressing down will grow the window’s height. + bindsym h resize shrink width 10 px or 10 ppt + bindsym j resize grow height 10 px or 10 ppt + bindsym k resize shrink height 10 px or 10 ppt + bindsym l resize grow width 10 px or 10 ppt + + # same bindings, but for the arrow keys + bindsym 113 resize shrink width 10 px or 10 ppt + bindsym 116 resize grow height 10 px or 10 ppt + bindsym 111 resize shrink height 10 px or 10 ppt + bindsym 114 resize grow width 10 px or 10 ppt + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} + +bindsym $mod+r mode "resize" + +# Start i3bar to display a workspace bar (plus the system information i3status +# finds out, if available) +bar { + status_command py3status + colors { + background #0c6fc4 + statusline #eeeeee + active_workspace #4389c4 #4389c4 #eeeeee + focused_workspace #75a0c4 #75a0c4 #eeeeee + inactive_workspace #0c6fc4 #0c6fc4 #eeeeee + urgent_workspace #c40c0c #c40c0c #eeeeee + separator #eeeeee + } + font pango:DejaVu Sans Mono 10 +} + +#style stuffj +new_window normal +hide_edge_borders both + +#rename workspace +bindsim $mod+w exec i3-input -F 'rename workspace to "%s"' -P 'New name: ' + +#colors +client.focused #0c6fc4 #0c6fc4 #eeeeee #2e93f4 +client.focused_inactive #75a0c4 #75a0c4 #a3b9cc #2e93f4 +client.unfocused #75a0c4 #75a0c4 #a3b9cc #2e93f4 +client.urgent #c40c0c #c40c0c #eeeeee #2e93f4 diff --git a/.vim/.gitignore b/.vim/.gitignore new file mode 100644 index 0000000..926ccaa --- /dev/null +++ b/.vim/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/.vim/.netrwhist b/.vim/.netrwhist new file mode 100644 index 0000000..3fcc75b --- /dev/null +++ b/.vim/.netrwhist @@ -0,0 +1,8 @@ +let g:netrw_dirhistmax =10 +let g:netrw_dirhist_cnt =6 +let g:netrw_dirhist_1='/home/amgutier/.wifi' +let g:netrw_dirhist_2='/home/amgutier/afs' +let g:netrw_dirhist_3='/home/amgutier/www/fincom/templates/form' +let g:netrw_dirhist_4='/' +let g:netrw_dirhist_5='/home/amgutier/.ssh' +let g:netrw_dirhist_6='/home/amgutier/Dropbox/s15/15415/hw3' diff --git a/.vim/autoload/airline.vim b/.vim/autoload/airline.vim new file mode 100644 index 0000000..81cf3b5 --- /dev/null +++ b/.vim/autoload/airline.vim @@ -0,0 +1,172 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let g:airline_statusline_funcrefs = get(g:, 'airline_statusline_funcrefs', []) + +let s:sections = ['a','b','c','gutter','x','y','z','warning'] +let s:inactive_funcrefs = [] + +function! airline#add_statusline_func(name) + call airline#add_statusline_funcref(function(a:name)) +endfunction + +function! airline#add_statusline_funcref(function) + if index(g:airline_statusline_funcrefs, a:function) >= 0 + echohl WarningMsg + echo 'The airline statusline funcref '.string(a:function).' has already been added.' + echohl NONE + return + endif + call add(g:airline_statusline_funcrefs, a:function) +endfunction + +function! airline#remove_statusline_func(name) + let i = index(g:airline_statusline_funcrefs, function(a:name)) + if i > -1 + call remove(g:airline_statusline_funcrefs, i) + endif +endfunction + +function! airline#add_inactive_statusline_func(name) + call add(s:inactive_funcrefs, function(a:name)) +endfunction + +function! airline#load_theme() + if exists('*airline#themes#{g:airline_theme}#refresh') + call airline#themes#{g:airline_theme}#refresh() + endif + + let palette = g:airline#themes#{g:airline_theme}#palette + call airline#themes#patch(palette) + + if exists('g:airline_theme_patch_func') + let Fn = function(g:airline_theme_patch_func) + call Fn(palette) + endif + + call airline#highlighter#load_theme() + call airline#extensions#load_theme() +endfunction + +function! airline#switch_theme(name) + try + let palette = g:airline#themes#{a:name}#palette "also lazy loads the theme + let g:airline_theme = a:name + catch + echohl WarningMsg | echo 'The specified theme cannot be found.' | echohl NONE + if exists('g:airline_theme') + return + else + let g:airline_theme = 'dark' + endif + endtry + + let w:airline_lastmode = '' + call airline#update_statusline() + call airline#load_theme() + + " this is required to prevent clobbering the startup info message, i don't know why... + call airline#check_mode(winnr()) +endfunction + +function! airline#switch_matching_theme() + if exists('g:colors_name') + try + let palette = g:airline#themes#{g:colors_name}#palette + call airline#switch_theme(g:colors_name) + return 1 + catch + for map in items(g:airline_theme_map) + if match(g:colors_name, map[0]) > -1 + call airline#switch_theme(map[1]) + return 1 + endif + endfor + endtry + endif + return 0 +endfunction + +function! airline#update_statusline() + for nr in filter(range(1, winnr('$')), 'v:val != winnr()') + call setwinvar(nr, 'airline_active', 0) + let context = { 'winnr': nr, 'active': 0, 'bufnr': winbufnr(nr) } + call s:invoke_funcrefs(context, s:inactive_funcrefs) + endfor + + unlet! w:airline_render_left + unlet! w:airline_render_right + for section in s:sections + unlet! w:airline_section_{section} + endfor + + let w:airline_active = 1 + let context = { 'winnr': winnr(), 'active': 1, 'bufnr': winbufnr(winnr()) } + call s:invoke_funcrefs(context, g:airline_statusline_funcrefs) +endfunction + +let s:contexts = {} +let s:core_funcrefs = [ + \ function('airline#extensions#apply'), + \ function('airline#extensions#default#apply') ] +function! s:invoke_funcrefs(context, funcrefs) + let builder = airline#builder#new(a:context) + let err = airline#util#exec_funcrefs(a:funcrefs + s:core_funcrefs, builder, a:context) + if err == 1 + let a:context.line = builder.build() + let s:contexts[a:context.winnr] = a:context + call setwinvar(a:context.winnr, '&statusline', '%!airline#statusline('.a:context.winnr.')') + endif +endfunction + +function! airline#statusline(winnr) + if has_key(s:contexts, a:winnr) + return '%{airline#check_mode('.a:winnr.')}'.s:contexts[a:winnr].line + endif + + " in rare circumstances this happens...see #276 + return '' +endfunction + +function! airline#check_mode(winnr) + let context = s:contexts[a:winnr] + + if get(w:, 'airline_active', 1) + let l:m = mode() + if l:m ==# "i" + let l:mode = ['insert'] + elseif l:m ==# "R" + let l:mode = ['replace'] + elseif l:m =~# '\v(v|V||s|S|)' + let l:mode = ['visual'] + else + let l:mode = ['normal'] + endif + let w:airline_current_mode = get(g:airline_mode_map, l:m, l:m) + else + let l:mode = ['inactive'] + let w:airline_current_mode = get(g:airline_mode_map, '__') + endif + + if g:airline_detect_modified && &modified + call add(l:mode, 'modified') + endif + + if g:airline_detect_paste && &paste + call add(l:mode, 'paste') + endif + + if &readonly || ! &modifiable + call add(l:mode, 'readonly') + endif + + let mode_string = join(l:mode) + if get(w:, 'airline_lastmode', '') != mode_string + call airline#highlighter#highlight_modified_inactive(context.bufnr) + call airline#highlighter#highlight(l:mode) + let w:airline_lastmode = mode_string + endif + + return '' +endfunction + diff --git a/.vim/autoload/airline/builder.vim b/.vim/autoload/airline/builder.vim new file mode 100644 index 0000000..5f4e080 --- /dev/null +++ b/.vim/autoload/airline/builder.vim @@ -0,0 +1,134 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let s:prototype = {} + +function! s:prototype.split(...) + call add(self._sections, ['|', a:0 ? a:1 : '%=']) +endfunction + +function! s:prototype.add_section_spaced(group, contents) + call self.add_section(a:group, (g:airline_symbols.space).a:contents.(g:airline_symbols.space)) +endfunction + +function! s:prototype.add_section(group, contents) + call add(self._sections, [a:group, a:contents]) +endfunction + +function! s:prototype.add_raw(text) + call add(self._sections, ['', a:text]) +endfunction + +function! s:get_prev_group(sections, i) + let x = a:i - 1 + while x >= 0 + let group = a:sections[x][0] + if group != '' && group != '|' + return group + endif + let x = x - 1 + endwhile + return '' +endfunction + +function! s:prototype.build() + let side = 1 + let line = '' + let i = 0 + let length = len(self._sections) + let split = 0 + + while i < length + let section = self._sections[i] + let group = section[0] + let contents = section[1] + let prev_group = s:get_prev_group(self._sections, i) + + if group == '' + let line .= contents + elseif group == '|' + let side = 0 + let line .= contents + let split = 1 + else + if prev_group == '' + let line .= '%#'.group.'#' + elseif split + let line .= s:get_transitioned_seperator(self, prev_group, group, side) + let split = 0 + else + let line .= s:get_seperator(self, prev_group, group, side) + endif + let line .= s:get_accented_line(self, group, contents) + endif + + let i = i + 1 + endwhile + + if !self._context.active + let line = substitute(line, '%#.\{-}\ze#', '\0_inactive', 'g') + endif + return line +endfunction + +function! s:should_change_group(group1, group2) + if a:group1 == a:group2 + return 0 + endif + let color1 = airline#highlighter#get_highlight(a:group1) + let color2 = airline#highlighter#get_highlight(a:group2) + if has('gui_running') + return color1[1] != color2[1] || color1[0] != color2[0] + else + return color1[3] != color2[3] || color1[2] != color2[2] + endif +endfunction + +function! s:get_transitioned_seperator(self, prev_group, group, side) + let line = '' + call airline#highlighter#add_separator(a:prev_group, a:group, a:side) + let line .= '%#'.a:prev_group.'_to_'.a:group.'#' + let line .= a:side ? a:self._context.left_sep : a:self._context.right_sep + let line .= '%#'.a:group.'#' + return line +endfunction + +function! s:get_seperator(self, prev_group, group, side) + if s:should_change_group(a:prev_group, a:group) + return s:get_transitioned_seperator(a:self, a:prev_group, a:group, a:side) + else + return a:side ? a:self._context.left_alt_sep : a:self._context.right_alt_sep + endif +endfunction + +function! s:get_accented_line(self, group, contents) + if a:self._context.active + let contents = [] + let content_parts = split(a:contents, '__accent') + for cpart in content_parts + let accent = matchstr(cpart, '_\zs[^#]*\ze') + call add(contents, cpart) + endfor + let line = join(contents, a:group) + let line = substitute(line, '__restore__', a:group, 'g') + else + let line = substitute(a:contents, '%#__accent[^#]*#', '', 'g') + let line = substitute(line, '%#__restore__#', '', 'g') + endif + return line +endfunction + +function! airline#builder#new(context) + let builder = copy(s:prototype) + let builder._context = a:context + let builder._sections = [] + + call extend(builder._context, { + \ 'left_sep': g:airline_left_sep, + \ 'left_alt_sep': g:airline_left_alt_sep, + \ 'right_sep': g:airline_right_sep, + \ 'right_alt_sep': g:airline_right_alt_sep, + \ }, 'keep') + return builder +endfunction + diff --git a/.vim/autoload/airline/debug.vim b/.vim/autoload/airline/debug.vim new file mode 100644 index 0000000..28424a6 --- /dev/null +++ b/.vim/autoload/airline/debug.vim @@ -0,0 +1,50 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +function! airline#debug#profile1() + profile start airline-profile-switch.log + profile func * + profile file * + split + for i in range(1, 1000) + wincmd w + redrawstatus + endfor + profile pause + noautocmd qall! +endfunction + +function! airline#debug#profile2() + profile start airline-profile-cursor.log + profile func * + profile file * + edit blank + call setline(1, 'all your base are belong to us') + call setline(2, 'all your base are belong to us') + let positions = [[1,2], [2,2], [1,2], [1,1]] + for i in range(1, 1000) + for pos in positions + call cursor(pos[0], pos[1]) + redrawstatus + endfor + endfor + profile pause + noautocmd qall! +endfunction + +function! airline#debug#profile3() + profile start airline-profile-mode.log + profile func * + profile file * + + for i in range(1000) + startinsert + redrawstatus + stopinsert + redrawstatus + endfor + + profile pause + noautocmd qall! +endfunction + diff --git a/.vim/autoload/airline/deprecation.vim b/.vim/autoload/airline/deprecation.vim new file mode 100644 index 0000000..cf7e787 --- /dev/null +++ b/.vim/autoload/airline/deprecation.vim @@ -0,0 +1,32 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +function! airline#deprecation#check() + if exists('g:airline_enable_fugitive') || exists('g:airline_fugitive_prefix') + echom 'The g:airline_enable_fugitive and g:airline_fugitive_prefix variables are obsolete. Please read the documentation about the branch extension.' + endif + + let tests = [ + \ [ 'g:airline_paste_symbol', 'g:airline_symbols.paste' ], + \ [ 'g:airline_readonly_symbol', 'g:airline_symbols.readonly' ], + \ [ 'g:airline_linecolumn_prefix', 'g:airline_symbols.linenr' ], + \ [ 'g:airline_branch_prefix', 'g:airline_symbols.branch' ], + \ [ 'g:airline_branch_empty_message', 'g:airline#extensions#branch#empty_message' ], + \ [ 'g:airline_detect_whitespace', 'g:airline#extensions#whitespace#enabled|show_message' ], + \ [ 'g:airline_enable_hunks', 'g:airline#extensions#hunks#enabled' ], + \ [ 'g:airline_enable_tagbar', 'g:airline#extensions#tagbar#enabled' ], + \ [ 'g:airline_enable_csv', 'g:airline#extensions#csv#enabled' ], + \ [ 'g:airline_enable_branch', 'g:airline#extensions#branch#enabled' ], + \ [ 'g:airline_enable_bufferline', 'g:airline#extensions#bufferline#enabled' ], + \ [ 'g:airline_enable_syntastic', 'g:airline#extensions#syntastic#enabled' ], + \ [ 'g:airline_enable_eclim', 'g:airline#extensions#eclim#enabled' ], + \ ] + for test in tests + if exists(test[0]) + let max = winwidth(0) - 16 + let msg = printf('The variable %s is deprecated and may not work in the future. It has been replaced with %s. Please read the documentation.', test[0], test[1]) + echom msg[:max].'...' + endif + endfor +endfunction + diff --git a/.vim/autoload/airline/extensions.vim b/.vim/autoload/airline/extensions.vim new file mode 100644 index 0000000..22a91cf --- /dev/null +++ b/.vim/autoload/airline/extensions.vim @@ -0,0 +1,242 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let s:ext = {} +let s:ext._theme_funcrefs = [] + +function! s:ext.add_statusline_func(name) dict + call airline#add_statusline_func(a:name) +endfunction +function! s:ext.add_statusline_funcref(function) dict + call airline#add_statusline_funcref(a:function) +endfunction +function! s:ext.add_inactive_statusline_func(name) dict + call airline#add_inactive_statusline_func(a:name) +endfunction +function! s:ext.add_theme_func(name) dict + call add(self._theme_funcrefs, function(a:name)) +endfunction + +let s:script_path = tolower(resolve(expand(':p:h'))) + +let s:filetype_overrides = { + \ 'nerdtree': [ 'NERD', '' ], + \ 'gundo': [ 'Gundo', '' ], + \ 'vimfiler': [ 'vimfiler', '%{vimfiler#get_status_string()}' ], + \ 'minibufexpl': [ 'MiniBufExplorer', '' ], + \ 'startify': [ 'startify', '' ], + \ 'vim-plug': [ 'Plugins', '' ], + \ } + +let s:filetype_regex_overrides = {} + +function! s:check_defined_section(name) + if !exists('w:airline_section_{a:name}') + let w:airline_section_{a:name} = g:airline_section_{a:name} + endif +endfunction + +function! airline#extensions#append_to_section(name, value) + call check_defined_section(a:name) + let w:airline_section_{a:name} .= a:value +endfunction + +function! airline#extensions#prepend_to_section(name, value) + call check_defined_section(a:name) + let w:airline_section_{a:name} = a:value . w:airline_section_{a:name} +endfunction + +function! airline#extensions#apply_left_override(section1, section2) + let w:airline_section_a = a:section1 + let w:airline_section_b = a:section2 + let w:airline_section_c = airline#section#create(['readonly']) + let w:airline_render_left = 1 + let w:airline_render_right = 0 +endfunction + +let s:active_winnr = -1 +function! airline#extensions#apply(...) + let s:active_winnr = winnr() + + if s:is_excluded_window() + return -1 + endif + + if &buftype == 'help' + call airline#extensions#apply_left_override('Help', '%f') + let w:airline_section_x = '' + let w:airline_section_y = '' + let w:airline_render_right = 1 + endif + + if &previewwindow + let w:airline_section_a = 'Preview' + let w:airline_section_b = '' + let w:airline_section_c = bufname(winbufnr(winnr())) + endif + + if has_key(s:filetype_overrides, &ft) + let args = s:filetype_overrides[&ft] + call airline#extensions#apply_left_override(args[0], args[1]) + endif + + for item in items(s:filetype_regex_overrides) + if match(&ft, item[0]) >= 0 + call airline#extensions#apply_left_override(item[1][0], item[1][1]) + endif + endfor +endfunction + +function! s:is_excluded_window() + for matchft in g:airline_exclude_filetypes + if matchft ==# &ft + return 1 + endif + endfor + + for matchw in g:airline_exclude_filenames + if matchstr(expand('%'), matchw) ==# matchw + return 1 + endif + endfor + + if g:airline_exclude_preview && &previewwindow + return 1 + endif + + return 0 +endfunction + +function! airline#extensions#load_theme() + call airline#util#exec_funcrefs(s:ext._theme_funcrefs, g:airline#themes#{g:airline_theme}#palette) +endfunction + +function! s:sync_active_winnr() + if exists('#airline') && winnr() != s:active_winnr + call airline#update_statusline() + endif +endfunction + +function! airline#extensions#load() + " non-trivial number of external plugins use eventignore=all, so we need to account for that + autocmd CursorMoved * call sync_active_winnr() + + call airline#extensions#quickfix#init(s:ext) + + if get(g:, 'loaded_unite', 0) + call airline#extensions#unite#init(s:ext) + endif + + if exists(':NetrwSettings') + call airline#extensions#netrw#init(s:ext) + endif + + if get(g:, 'loaded_vimfiler', 0) + let g:vimfiler_force_overwrite_statusline = 0 + endif + + if get(g:, 'loaded_ctrlp', 0) + call airline#extensions#ctrlp#init(s:ext) + endif + + if get(g:, 'command_t_loaded', 0) + call airline#extensions#commandt#init(s:ext) + endif + + if exists(':UndotreeToggle') + call airline#extensions#undotree#init(s:ext) + endif + + if (get(g:, 'airline#extensions#hunks#enabled', 1) && get(g:, 'airline_enable_hunks', 1)) + \ && (exists('g:loaded_signify') || exists('g:loaded_gitgutter') || exists('g:loaded_changes')) + call airline#extensions#hunks#init(s:ext) + endif + + if (get(g:, 'airline#extensions#tagbar#enabled', 1) && get(g:, 'airline_enable_tagbar', 1)) + \ && exists(':TagbarToggle') + call airline#extensions#tagbar#init(s:ext) + endif + + if (get(g:, 'airline#extensions#csv#enabled', 1) && get(g:, 'airline_enable_csv', 1)) + \ && (get(g:, 'loaded_csv', 0) || exists(':Table')) + call airline#extensions#csv#init(s:ext) + endif + + if exists(':VimShell') + let s:filetype_overrides['vimshell'] = ['vimshell','%{vimshell#get_status_string()}'] + let s:filetype_regex_overrides['^int-'] = ['vimshell','%{substitute(&ft, "int-", "", "")}'] + endif + + if (get(g:, 'airline#extensions#branch#enabled', 1) && get(g:, 'airline_enable_branch', 1)) + \ && (exists('*fugitive#head') || exists('*lawrencium#statusline') || + \ (get(g:, 'airline#extensions#branch#use_vcscommand', 0) && exists('*VCSCommandGetStatusLine'))) + call airline#extensions#branch#init(s:ext) + endif + + if (get(g:, 'airline#extensions#bufferline#enabled', 1) && get(g:, 'airline_enable_bufferline', 1)) + \ && exists('*bufferline#get_status_string') + call airline#extensions#bufferline#init(s:ext) + endif + + if isdirectory($VIRTUAL_ENV) && get(g:, 'airline#extensions#virtualenv#enabled', 1) + call airline#extensions#virtualenv#init(s:ext) + endif + + if (get(g:, 'airline#extensions#eclim#enabled', 1) && exists(':ProjectCreate')) + call airline#extensions#eclim#init(s:ext) + endif + + if (get(g:, 'airline#extensions#syntastic#enabled', 1) && get(g:, 'airline_enable_syntastic', 1)) + \ && exists(':SyntasticCheck') + call airline#extensions#syntastic#init(s:ext) + endif + + if (get(g:, 'airline#extensions#whitespace#enabled', 1) && get(g:, 'airline_detect_whitespace', 1)) + call airline#extensions#whitespace#init(s:ext) + endif + + if get(g:, 'airline#extensions#tabline#enabled', 0) + call airline#extensions#tabline#init(s:ext) + endif + + if get(g:, 'airline#extensions#tmuxline#enabled', 1) && exists(':Tmuxline') + call airline#extensions#tmuxline#init(s:ext) + endif + + if get(g:, 'airline#extensions#promptline#enabled', 1) && exists(':PromptlineSnapshot') && len(get(g:, 'airline#extensions#promptline#snapshot_file', '')) + call airline#extensions#promptline#init(s:ext) + endif + + if get(g:, 'airline#extensions#nrrwrgn#enabled', 1) && exists(':NR') == 2 + call airline#extensions#nrrwrgn#init(s:ext) + endif + + if (get(g:, 'airline#extensions#capslock#enabled', 1) && exists('*CapsLockStatusline')) + call airline#extensions#capslock#init(s:ext) + endif + + if (get(g:, 'airline#extensions#windowswap#enabled', 1) && get(g:, 'loaded_windowswap', 0)) + call airline#extensions#windowswap#init(s:ext) + endif + + if !get(g:, 'airline#extensions#disable_rtp_load', 0) + " load all other extensions, which are not part of the default distribution. + " (autoload/airline/extensions/*.vim outside of our s:script_path). + for file in split(globpath(&rtp, "autoload/airline/extensions/*.vim"), "\n") + " we have to check both resolved and unresolved paths, since it's possible + " that they might not get resolved properly (see #187) + if stridx(tolower(resolve(fnamemodify(file, ':p'))), s:script_path) < 0 + \ && stridx(tolower(fnamemodify(file, ':p')), s:script_path) < 0 + let name = fnamemodify(file, ':t:r') + if !get(g:, 'airline#extensions#'.name.'#enabled', 1) + continue + endif + try + call airline#extensions#{name}#init(s:ext) + catch + endtry + endif + endfor + endif +endfunction + diff --git a/.vim/autoload/airline/extensions/branch.vim b/.vim/autoload/airline/extensions/branch.vim new file mode 100644 index 0000000..e97cae8 --- /dev/null +++ b/.vim/autoload/airline/extensions/branch.vim @@ -0,0 +1,122 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let s:has_fugitive = exists('*fugitive#head') +let s:has_lawrencium = exists('*lawrencium#statusline') +let s:has_vcscommand = get(g:, 'airline#extensions#branch#use_vcscommand', 0) && exists('*VCSCommandGetStatusLine') + +if !s:has_fugitive && !s:has_lawrencium && !s:has_vcscommand + finish +endif + +let s:git_dirs = {} +function! s:get_git_branch(path) + if has_key(s:git_dirs, a:path) + return s:git_dirs[a:path] + endif + + let dir = fugitive#extract_git_dir(a:path) + if empty(dir) + let name = '' + else + try + let line = join(readfile(dir . '/HEAD')) + if strpart(line, 0, 16) == 'ref: refs/heads/' + let name = strpart(line, 16) + else + " raw commit hash + let name = strpart(line, 0, 7) + endif + catch + let name = '' + endtry + endif + + let s:git_dirs[a:path] = name + return name +endfunction + +function! airline#extensions#branch#head() + if exists('b:airline_head') && !empty(b:airline_head) + return b:airline_head + endif + + let b:airline_head = '' + let found_fugitive_head = 0 + + if s:has_fugitive && !exists('b:mercurial_dir') + let b:airline_head = fugitive#head(7) + let found_fugitive_head = 1 + + if empty(b:airline_head) && !exists('b:git_dir') + let b:airline_head = s:get_git_branch(expand("%:p:h")) + endif + endif + + if empty(b:airline_head) + if s:has_lawrencium + let b:airline_head = lawrencium#statusline() + endif + endif + + if empty(b:airline_head) + if s:has_vcscommand + call VCSCommandEnableBufferSetup() + if exists('b:VCSCommandBufferInfo') + let b:airline_head = get(b:VCSCommandBufferInfo, 0, '') + endif + endif + endif + + if empty(b:airline_head) || !found_fugitive_head && !s:check_in_path() + let b:airline_head = '' + endif + + if exists("g:airline#extensions#branch#displayed_head_limit") + let w:displayed_head_limit = g:airline#extensions#branch#displayed_head_limit + if len(b:airline_head) > w:displayed_head_limit - 1 + let b:airline_head = b:airline_head[0:w:displayed_head_limit - 1].'…' + endif + endif + + return b:airline_head +endfunction + +function! airline#extensions#branch#get_head() + let head = airline#extensions#branch#head() + let empty_message = get(g:, 'airline#extensions#branch#empty_message', + \ get(g:, 'airline_branch_empty_message', '')) + let symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch) + return empty(head) + \ ? empty_message + \ : printf('%s%s', empty(symbol) ? '' : symbol.(g:airline_symbols.space), head) +endfunction + +function! s:check_in_path() + if !exists('b:airline_branch_path') + let root = get(b:, 'git_dir', get(b:, 'mercurial_dir', '')) + let bufferpath = resolve(fnamemodify(expand('%'), ':p')) + + if !filereadable(root) "not a file + " if .git is a directory, it's the old submodule format + if match(root, '\.git$') >= 0 + let root = expand(fnamemodify(root, ':h')) + else + " else it's the newer format, and we need to guesstimate + let pattern = '\.git\(\\\|\/\)modules\(\\\|\/\)' + if match(root, pattern) >= 0 + let root = substitute(root, pattern, '', '') + endif + endif + + let b:airline_file_in_root = stridx(bufferpath, root) > -1 + endif + return b:airline_file_in_root +endfunction + +function! airline#extensions#branch#init(ext) + call airline#parts#define_function('branch', 'airline#extensions#branch#get_head') + + autocmd BufReadPost * unlet! b:airline_file_in_root + autocmd CursorHold,ShellCmdPost,CmdwinLeave * unlet! b:airline_head +endfunction diff --git a/.vim/autoload/airline/extensions/bufferline.vim b/.vim/autoload/airline/extensions/bufferline.vim new file mode 100644 index 0000000..6dc97fe --- /dev/null +++ b/.vim/autoload/airline/extensions/bufferline.vim @@ -0,0 +1,23 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !exists('*bufferline#get_status_string') + finish +endif + +let s:overwrite = get(g:, 'airline#extensions#bufferline#overwrite_variables', 1) + +function! airline#extensions#bufferline#init(ext) + if s:overwrite + highlight bufferline_selected gui=bold cterm=bold term=bold + highlight link bufferline_selected_inactive airline_c_inactive + let g:bufferline_inactive_highlight = 'airline_c' + let g:bufferline_active_highlight = 'bufferline_selected' + let g:bufferline_active_buffer_left = '' + let g:bufferline_active_buffer_right = '' + let g:bufferline_separator = g:airline_symbols.space + endif + + call airline#parts#define_raw('file', '%{bufferline#refresh_status()}'.bufferline#get_status_string()) +endfunction + diff --git a/.vim/autoload/airline/extensions/capslock.vim b/.vim/autoload/airline/extensions/capslock.vim new file mode 100644 index 0000000..689b561 --- /dev/null +++ b/.vim/autoload/airline/extensions/capslock.vim @@ -0,0 +1,14 @@ +" MIT License. Copyright (c) 2014 Mathias Andersson. +" vim: et ts=2 sts=2 sw=2 +if !exists('*CapsLockStatusline') + finish +endif + +function! airline#extensions#capslock#status() + return CapsLockStatusline() == '[caps]' ? 'CAPS' : '' +endfunction + +function! airline#extensions#capslock#init(ext) + call airline#parts#define_function('capslock', 'airline#extensions#capslock#status') +endfunction + diff --git a/.vim/autoload/airline/extensions/commandt.vim b/.vim/autoload/airline/extensions/commandt.vim new file mode 100644 index 0000000..e549f27 --- /dev/null +++ b/.vim/autoload/airline/extensions/commandt.vim @@ -0,0 +1,16 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !get(g:, 'command_t_loaded', 0) + finish +endif + +function! airline#extensions#commandt#apply(...) + if bufname('%') ==# 'GoToFile' + call airline#extensions#apply_left_override('CommandT', '') + endif +endfunction + +function! airline#extensions#commandt#init(ext) + call a:ext.add_statusline_func('airline#extensions#commandt#apply') +endfunction diff --git a/.vim/autoload/airline/extensions/csv.vim b/.vim/autoload/airline/extensions/csv.vim new file mode 100644 index 0000000..2c296ab --- /dev/null +++ b/.vim/autoload/airline/extensions/csv.vim @@ -0,0 +1,31 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !get(g:, 'loaded_csv', 0) && !exists(':Table') + finish +endif + +let s:column_display = get(g:, 'airline#extensions#csv#column_display', 'Number') + +function! airline#extensions#csv#get_column() + if exists('*CSV_WCol') + if s:column_display ==# 'Name' + return '['.CSV_WCol('Name').CSV_WCol().']' + else + return '['.CSV_WCol().']' + endif + endif + return '' +endfunction + +function! airline#extensions#csv#apply(...) + if &ft ==# "csv" + call airline#extensions#prepend_to_section('gutter', + \ g:airline_left_alt_sep.' %{airline#extensions#csv#get_column()}') + endif +endfunction + +function! airline#extensions#csv#init(ext) + call a:ext.add_statusline_func('airline#extensions#csv#apply') +endfunction + diff --git a/.vim/autoload/airline/extensions/ctrlp.vim b/.vim/autoload/airline/extensions/ctrlp.vim new file mode 100644 index 0000000..ef7da68 --- /dev/null +++ b/.vim/autoload/airline/extensions/ctrlp.vim @@ -0,0 +1,80 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !get(g:, 'loaded_ctrlp', 0) + finish +endif + +let s:color_template = get(g:, 'airline#extensions#ctrlp#color_template', 'insert') + +function! airline#extensions#ctrlp#generate_color_map(dark, light, white) + return { + \ 'CtrlPdark' : a:dark, + \ 'CtrlPlight' : a:light, + \ 'CtrlPwhite' : a:white, + \ 'CtrlParrow1' : [ a:light[1] , a:white[1] , a:light[3] , a:white[3] , '' ] , + \ 'CtrlParrow2' : [ a:white[1] , a:light[1] , a:white[3] , a:light[3] , '' ] , + \ 'CtrlParrow3' : [ a:light[1] , a:dark[1] , a:light[3] , a:dark[3] , '' ] , + \ } +endfunction + +function! airline#extensions#ctrlp#load_theme(palette) + if exists('a:palette.ctrlp') + let theme = a:palette.ctrlp + else + let s:color_template = has_key(a:palette, s:color_template) ? s:color_template : 'insert' + let theme = airline#extensions#ctrlp#generate_color_map( + \ a:palette[s:color_template]['airline_c'], + \ a:palette[s:color_template]['airline_b'], + \ a:palette[s:color_template]['airline_a']) + endif + for key in keys(theme) + call airline#highlighter#exec(key, theme[key]) + endfor +endfunction + +" Arguments: focus, byfname, regexp, prv, item, nxt, marked +function! airline#extensions#ctrlp#ctrlp_airline(...) + let b = airline#builder#new({'active': 1}) + if a:2 == 'file' + call b.add_section_spaced('CtrlPlight', 'by fname') + endif + if a:3 + call b.add_section_spaced('CtrlPlight', 'regex') + endif + if get(g:, 'airline#extensions#ctrlp#show_adjacent_modes', 1) + call b.add_section_spaced('CtrlPlight', a:4) + call b.add_section_spaced('CtrlPwhite', a:5) + call b.add_section_spaced('CtrlPlight', a:6) + else + call b.add_section_spaced('CtrlPwhite', a:5) + endif + call b.add_section_spaced('CtrlPdark', a:7) + call b.split() + call b.add_section_spaced('CtrlPdark', a:1) + call b.add_section_spaced('CtrlPdark', a:2) + call b.add_section_spaced('CtrlPlight', '%{getcwd()}') + return b.build() +endfunction + +" Argument: len +function! airline#extensions#ctrlp#ctrlp_airline_status(...) + let len = '%#CtrlPdark# '.a:1 + let dir = '%=%<%#CtrlParrow3#'.g:airline_right_sep.'%#CtrlPlight# '.getcwd().' %*' + return len.dir +endfunction + +function! airline#extensions#ctrlp#apply(...) + " disable statusline overwrite if ctrlp already did it + return match(&statusline, 'CtrlPwhite') >= 0 ? -1 : 0 +endfunction + +function! airline#extensions#ctrlp#init(ext) + let g:ctrlp_status_func = { + \ 'main': 'airline#extensions#ctrlp#ctrlp_airline', + \ 'prog': 'airline#extensions#ctrlp#ctrlp_airline_status', + \ } + call a:ext.add_statusline_func('airline#extensions#ctrlp#apply') + call a:ext.add_theme_func('airline#extensions#ctrlp#load_theme') +endfunction + diff --git a/.vim/autoload/airline/extensions/default.vim b/.vim/autoload/airline/extensions/default.vim new file mode 100644 index 0000000..faa1fb6 --- /dev/null +++ b/.vim/autoload/airline/extensions/default.vim @@ -0,0 +1,81 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let s:section_truncate_width = get(g:, 'airline#extensions#default#section_truncate_width', { + \ 'b': 79, + \ 'x': 60, + \ 'y': 88, + \ 'z': 45, + \ }) +let s:layout = get(g:, 'airline#extensions#default#layout', [ + \ [ 'a', 'b', 'c' ], + \ [ 'x', 'y', 'z', 'warning' ] + \ ]) + +function! s:get_section(winnr, key, ...) + if has_key(s:section_truncate_width, a:key) + if winwidth(a:winnr) < s:section_truncate_width[a:key] + return '' + endif + endif + let spc = g:airline_symbols.space + let text = airline#util#getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) + let [prefix, suffix] = [get(a:000, 0, '%('.spc), get(a:000, 1, spc.'%)')] + return empty(text) ? '' : prefix.text.suffix +endfunction + +function! s:build_sections(builder, context, keys) + for key in a:keys + if key == 'warning' && !a:context.active + continue + endif + call s:add_section(a:builder, a:context, key) + endfor +endfunction + +if v:version >= 704 || (v:version >= 703 && has('patch81')) + function s:add_section(builder, context, key) + " i have no idea why the warning section needs special treatment, but it's + " needed to prevent separators from showing up + if a:key == 'warning' + call a:builder.add_raw('%(') + endif + call a:builder.add_section('airline_'.a:key, s:get_section(a:context.winnr, a:key)) + if a:key == 'warning' + call a:builder.add_raw('%)') + endif + endfunction +else + " older version don't like the use of %(%) + function s:add_section(builder, context, key) + if a:key == 'warning' + call a:builder.add_raw('%#airline_warning#'.s:get_section(a:context.winnr, a:key)) + else + call a:builder.add_section('airline_'.a:key, s:get_section(a:context.winnr, a:key)) + endif + endfunction +endif + +function! airline#extensions#default#apply(builder, context) + let winnr = a:context.winnr + let active = a:context.active + + if airline#util#getwinvar(winnr, 'airline_render_left', active || (!active && !g:airline_inactive_collapse)) + call s:build_sections(a:builder, a:context, s:layout[0]) + else + let text = s:get_section(winnr, 'c') + if empty(text) + let text = ' %f%m ' + endif + call a:builder.add_section('airline_c'.(a:context.bufnr), text) + endif + + call a:builder.split(s:get_section(winnr, 'gutter', '', '')) + + if airline#util#getwinvar(winnr, 'airline_render_right', 1) + call s:build_sections(a:builder, a:context, s:layout[1]) + endif + + return 1 +endfunction + diff --git a/.vim/autoload/airline/extensions/eclim.vim b/.vim/autoload/airline/extensions/eclim.vim new file mode 100644 index 0000000..e2f6531 --- /dev/null +++ b/.vim/autoload/airline/extensions/eclim.vim @@ -0,0 +1,53 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !exists(':ProjectCreate') + finish +endif + +function! airline#extensions#eclim#creat_line(...) + if &filetype == "tree" + let builder = a:1 + call builder.add_section('airline_a', ' Project ') + call builder.add_section('airline_b', ' %f ') + call builder.add_section('airline_c', '') + return 1 + endif +endfunction + +function! airline#extensions#eclim#get_warnings() + let eclimList = eclim#display#signs#GetExisting() + + if !empty(eclimList) + " Remove any non-eclim signs (see eclim#display#signs#Update) + " First check for just errors since they are more important. + " If there are no errors, then check for warnings. + let errorList = filter(copy(eclimList), 'v:val.name =~ "^\\(qf_\\)\\?\\(error\\)$"') + + if (empty(errorList)) + " use the warnings + call filter(eclimList, 'v:val.name =~ "^\\(qf_\\)\\?\\(warning\\)$"') + let type = 'W' + else + " Use the errors + let eclimList = errorList + let type = 'E' + endif + + if !empty(eclimList) + let errorsLine = eclimList[0]['line'] + let errorsNumber = len(eclimList) + let errors = "[Eclim:" . type . " line:".string(errorsLine)." (".string(errorsNumber).")]" + if !exists(':SyntasticCheck') || SyntasticStatuslineFlag() == '' + return errors.(g:airline_symbols.space) + endif + endif + endif + return '' +endfunction + +function! airline#extensions#eclim#init(ext) + call airline#parts#define_function('eclim', 'airline#extensions#eclim#get_warnings') + call a:ext.add_statusline_func('airline#extensions#eclim#creat_line') +endfunction + diff --git a/.vim/autoload/airline/extensions/example.vim b/.vim/autoload/airline/extensions/example.vim new file mode 100644 index 0000000..4a1932d --- /dev/null +++ b/.vim/autoload/airline/extensions/example.vim @@ -0,0 +1,54 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +" we don't actually want this loaded :P +finish + +" Due to some potential rendering issues, the use of the `space` variable is +" recommended. +let s:spc = g:airline_symbols.space + +" Extension specific variables can be defined the usual fashion. +if !exists('g:airline#extensions#example#number_of_cats') + let g:airline#extensions#example#number_of_cats = 42 +endif + +" First we define an init function that will be invoked from extensions.vim +function! airline#extensions#example#init(ext) + + " Here we define a new part for the plugin. This allows users to place this + " extension in arbitrary locations. + call airline#parts#define_raw('cats', '%{airline#extensions#example#get_cats()}') + + " Next up we add a funcref so that we can run some code prior to the + " statusline getting modifed. + call a:ext.add_statusline_func('airline#extensions#example#apply') + + " You can also add a funcref for inactive statuslines. + " call a:ext.add_inactive_statusline_func('airline#extensions#example#unapply') +endfunction + +" This function will be invoked just prior to the statusline getting modified. +function! airline#extensions#example#apply(...) + " First we check for the filetype. + if &filetype == "nyancat" + + " Let's say we want to append to section_c, first we check if there's + " already a window-local override, and if not, create it off of the global + " section_c. + let w:airline_section_c = get(w:, 'airline_section_c', g:airline_section_c) + + " Then we just append this extenion to it, optionally using separators. + let w:airline_section_c .= s:spc.g:airline_left_alt_sep.s:spc.'%{airline#extensions#example#get_cats()}' + endif +endfunction + +" Finally, this function will be invoked from the statusline. +function! airline#extensions#example#get_cats() + let cats = '' + for i in range(1, g:airline#extensions#example#number_of_cats) + let cats .= ' (,,,)=(^.^)=(,,,) ' + endfor + return cats +endfunction + diff --git a/.vim/autoload/airline/extensions/hunks.vim b/.vim/autoload/airline/extensions/hunks.vim new file mode 100644 index 0000000..968fd66 --- /dev/null +++ b/.vim/autoload/airline/extensions/hunks.vim @@ -0,0 +1,82 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !get(g:, 'loaded_signify', 0) && !get(g:, 'loaded_gitgutter', 0) && !get(g:, 'loaded_changes', 0) + finish +endif + +let s:non_zero_only = get(g:, 'airline#extensions#hunks#non_zero_only', 0) +let s:hunk_symbols = get(g:, 'airline#extensions#hunks#hunk_symbols', ['+', '~', '-']) + +function! s:get_hunks_signify() + let hunks = sy#repo#get_stats() + if hunks[0] >= 0 + return hunks + endif + return [] +endfunction + +function! s:is_branch_empty() + return exists('*airline#extensions#branch#head') && empty(airline#extensions#branch#head()) +endfunction + +function! s:get_hunks_gitgutter() + if !get(g:, 'gitgutter_enabled', 0) || s:is_branch_empty() + return '' + endif + return GitGutterGetHunkSummary() +endfunction + +function! s:get_hunks_changes() + if !get(b:, 'changes_view_enabled', 0) || s:is_branch_empty() + return [] + endif + let hunks = changes#GetStats() + for i in hunks + if i > 0 + return hunks + endif + endfor + return [] +endfunction + +function! s:get_hunks_empty() + return '' +endfunction + +let s:source_func = '' +function! s:get_hunks() + if empty(s:source_func) + if get(g:, 'loaded_signify', 0) + let s:source_func = 's:get_hunks_signify' + elseif exists('*GitGutterGetHunkSummary') + let s:source_func = 's:get_hunks_gitgutter' + elseif exists('*changes#GetStats') + let s:source_func = 's:get_hunks_changes' + else + let s:source_func = 's:get_hunks_empty' + endif + endif + return {s:source_func}() +endfunction + +function! airline#extensions#hunks#get_hunks() + if !get(w:, 'airline_active', 0) + return '' + endif + let hunks = s:get_hunks() + let string = '' + if !empty(hunks) + for i in [0, 1, 2] + if s:non_zero_only == 0 || hunks[i] > 0 + let string .= printf('%s%s ', s:hunk_symbols[i], hunks[i]) + endif + endfor + endif + return string +endfunction + +function! airline#extensions#hunks#init(ext) + call airline#parts#define_function('hunks', 'airline#extensions#hunks#get_hunks') +endfunction + diff --git a/.vim/autoload/airline/extensions/netrw.vim b/.vim/autoload/airline/extensions/netrw.vim new file mode 100644 index 0000000..debb088 --- /dev/null +++ b/.vim/autoload/airline/extensions/netrw.vim @@ -0,0 +1,32 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !exists(':NetrwSettings') + finish +endif + +function! airline#extensions#netrw#apply(...) + if &ft == 'netrw' + let spc = g:airline_symbols.space + + call a:1.add_section('airline_a', spc.'netrw'.spc) + if exists('*airline#extensions#branch#get_head') + call a:1.add_section('airline_b', spc.'%{airline#extensions#branch#get_head()}'.spc) + endif + call a:1.add_section('airline_c', spc.'%f'.spc) + call a:1.split() + call a:1.add_section('airline_y', spc.'%{airline#extensions#netrw#sortstring()}'.spc) + return 1 + endif +endfunction + +function! airline#extensions#netrw#init(ext) + let g:netrw_force_overwrite_statusline = 0 + call a:ext.add_statusline_func('airline#extensions#netrw#apply') +endfunction + + +function! airline#extensions#netrw#sortstring() + let order = (g:netrw_sort_direction =~ 'n') ? '+' : '-' + return g:netrw_sort_by . (g:airline_symbols.space) . '[' . order . ']' +endfunction diff --git a/.vim/autoload/airline/extensions/nrrwrgn.vim b/.vim/autoload/airline/extensions/nrrwrgn.vim new file mode 100644 index 0000000..338f6e0 --- /dev/null +++ b/.vim/autoload/airline/extensions/nrrwrgn.vim @@ -0,0 +1,54 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !get(g:, 'loaded_nrrw_rgn', 0) + finish +endif + +function! airline#extensions#nrrwrgn#apply(...) + if exists(":WidenRegion") == 2 + let spc = g:airline_symbols.space + if !exists("*nrrwrgn#NrrwRgnStatus()") || empty(nrrwrgn#NrrwRgnStatus()) + call a:1.add_section('airline_a', printf('%s[Narrowed%s#%d]', spc, spc, b:nrrw_instn)) + let bufname=(get(b:, 'orig_buf', 0) ? bufname(b:orig_buf) : substitute(bufname('%'), '^Nrrwrgn_\zs.*\ze_\d\+$', submatch(0), '')) + call a:1.add_section('airline_c', spc.bufname.spc) + call a:1.split() + else + let dict=nrrwrgn#NrrwRgnStatus() + let vmode = { 'v': 'Char ', 'V': 'Line ', '': 'Block '} + let mode = dict.visual ? vmode[dict.visual] : vmode['V'] + let winwidth = winwidth(0) + if winwidth < 80 + let mode = mode[0] + endif + let title = (winwidth < 80 ? "Nrrw" : "Narrowed ") + let multi = (winwidth < 80 ? 'M' : 'Multi') + call a:1.add_section('airline_a', printf('[%s%s%s#%d]%s', (dict.multi ? multi : ""), + \ title, mode, b:nrrw_instn, spc)) + let name = dict.fullname + if name !=# '[No Name]' + if winwidth > 100 + " need some space + let name = fnamemodify(dict.fullname, ':~') + if strlen(name) > 8 + " shorten name + let name = substitute(name, '\(.\)[^/\\]*\([/\\]\)', '\1\2', 'g') + endif + else + let name = fnamemodify(dict.fullname, ':t') + endif + endif + let range=(dict.multi ? '' : printf("[%d-%d]", dict.start[1], dict.end[1])) + call a:1.add_section('airline_c', printf("%s %s %s", name, range, dict.enabled ? "\u2713" : '!')) + call a:1.split() + call a:1.add_section('airline_x', get(g:, 'airline_section_x').spc) + call a:1.add_section('airline_y', spc.get(g:, 'airline_section_y').spc) + call a:1.add_section('airline_z', spc.get(g:, 'airline_section_z')) + endif + return 1 + endif +endfunction + +function! airline#extensions#nrrwrgn#init(ext) + call a:ext.add_statusline_func('airline#extensions#nrrwrgn#apply') +endfunction diff --git a/.vim/autoload/airline/extensions/promptline.vim b/.vim/autoload/airline/extensions/promptline.vim new file mode 100644 index 0000000..50b9708 --- /dev/null +++ b/.vim/autoload/airline/extensions/promptline.vim @@ -0,0 +1,33 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !exists(':PromptlineSnapshot') + finish +endif + +if !exists('airline#extensions#promptline#snapshot_file') || !len('airline#extensions#promptline#snapshot_file') + finish +endif + +let s:prompt_snapshot_file = get(g:, 'airline#extensions#promptline#snapshot_file', '') +let s:color_template = get(g:, 'airline#extensions#promptline#color_template', 'normal') + +function! airline#extensions#promptline#init(ext) + call a:ext.add_theme_func('airline#extensions#promptline#set_prompt_colors') +endfunction + +function! airline#extensions#promptline#set_prompt_colors(palette) + let color_template = has_key(a:palette, s:color_template) ? s:color_template : 'normal' + let mode_palette = a:palette[color_template] + + if !has_key(g:, 'promptline_symbols') + let g:promptline_symbols = { + \ 'left' : g:airline_left_sep, + \ 'right' : g:airline_right_sep, + \ 'left_alt' : g:airline_left_alt_sep, + \ 'right_alt' : g:airline_right_alt_sep} + endif + + let promptline_theme = promptline#api#create_theme_from_airline(mode_palette) + call promptline#api#create_snapshot_with_theme(s:prompt_snapshot_file, promptline_theme) +endfunction diff --git a/.vim/autoload/airline/extensions/quickfix.vim b/.vim/autoload/airline/extensions/quickfix.vim new file mode 100644 index 0000000..2be4077 --- /dev/null +++ b/.vim/autoload/airline/extensions/quickfix.vim @@ -0,0 +1,37 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let g:airline#extensions#quickfix#quickfix_text = 'Quickfix' +let g:airline#extensions#quickfix#location_text = 'Location' + +function! airline#extensions#quickfix#apply(...) + if &buftype == 'quickfix' + let w:airline_section_a = s:get_text() + let w:airline_section_b = '%{get(w:, "quickfix_title", "")}' + let w:airline_section_c = '' + let w:airline_section_x = '' + endif +endfunction + +function! airline#extensions#quickfix#init(ext) + call a:ext.add_statusline_func('airline#extensions#quickfix#apply') +endfunction + +function! s:get_text() + redir => buffers + silent ls + redir END + + let nr = bufnr('%') + for buf in split(buffers, '\n') + if match(buf, '\v^\s*'.nr) > -1 + if match(buf, '\cQuickfix') > -1 + return g:airline#extensions#quickfix#quickfix_text + else + return g:airline#extensions#quickfix#location_text + endif + endif + endfor + return '' +endfunction + diff --git a/.vim/autoload/airline/extensions/syntastic.vim b/.vim/autoload/airline/extensions/syntastic.vim new file mode 100644 index 0000000..f7179af --- /dev/null +++ b/.vim/autoload/airline/extensions/syntastic.vim @@ -0,0 +1,19 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !exists(':SyntasticCheck') + finish +endif + +function! airline#extensions#syntastic#get_warnings() + let errors = SyntasticStatuslineFlag() + if strlen(errors) > 0 + return errors.(g:airline_symbols.space) + endif + return '' +endfunction + +function! airline#extensions#syntastic#init(ext) + call airline#parts#define_function('syntastic', 'airline#extensions#syntastic#get_warnings') +endfunction + diff --git a/.vim/autoload/airline/extensions/tabline.vim b/.vim/autoload/airline/extensions/tabline.vim new file mode 100644 index 0000000..bbab057 --- /dev/null +++ b/.vim/autoload/airline/extensions/tabline.vim @@ -0,0 +1,363 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let s:formatter = get(g:, 'airline#extensions#tabline#formatter', 'default') +let s:excludes = get(g:, 'airline#extensions#tabline#excludes', []) +let s:tab_nr_type = get(g:, 'airline#extensions#tabline#tab_nr_type', 0) +let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1) +let s:show_tab_nr = get(g:, 'airline#extensions#tabline#show_tab_nr', 1) +let s:show_tab_type = get(g:, 'airline#extensions#tabline#show_tab_type', 1) +let s:show_close_button = get(g:, 'airline#extensions#tabline#show_close_button', 1) +let s:close_symbol = get(g:, 'airline#extensions#tabline#close_symbol', 'X') +let s:buffer_idx_mode = get(g:, 'airline#extensions#tabline#buffer_idx_mode', 0) +let s:buf_min_count = get(g:, 'airline#extensions#tabline#buffer_min_count', 0) +let s:tab_min_count = get(g:, 'airline#extensions#tabline#tab_min_count', 0) +let s:spc = g:airline_symbols.space + +let s:number_map = &encoding == 'utf-8' + \ ? { + \ '0': '⁰', + \ '1': '¹', + \ '2': '²', + \ '3': '³', + \ '4': '⁴', + \ '5': '⁵', + \ '6': '⁶', + \ '7': '⁷', + \ '8': '⁸', + \ '9': '⁹' + \ } + \ : {} + +function! airline#extensions#tabline#init(ext) + if has('gui_running') + set guioptions-=e + endif + + autocmd User AirlineToggledOn call s:toggle_on() + autocmd User AirlineToggledOff call s:toggle_off() + autocmd BufDelete * let s:current_bufnr = -1 + + call s:toggle_on() + call a:ext.add_theme_func('airline#extensions#tabline#load_theme') + if s:buffer_idx_mode + call s:define_buffer_idx_mode_mappings() + endif +endfunction + +function! s:toggle_off() + if exists('s:original_tabline') + let &tabline = s:original_tabline + let &showtabline = s:original_showtabline + endif +endfunction + +function! s:toggle_on() + let [ s:original_tabline, s:original_showtabline ] = [ &tabline, &showtabline ] + + set tabline=%!airline#extensions#tabline#get() + if s:buf_min_count <= 0 && s:tab_min_count <= 1 + set showtabline=2 + else + augroup airline_tabline + autocmd! + if s:show_buffers == 1 + autocmd BufEnter * call show_tabline(s:buf_min_count, len(s:get_buffer_list())) + autocmd BufUnload * call show_tabline(s:buf_min_count, len(s:get_buffer_list()) - 1) + else + autocmd TabEnter * call show_tabline(s:tab_min_count, tabpagenr('$')) + endif + augroup END + endif +endfunction + +function! airline#extensions#tabline#load_theme(palette) + let colors = get(a:palette, 'tabline', {}) + let l:tab = get(colors, 'airline_tab', a:palette.normal.airline_b) + let l:tabsel = get(colors, 'airline_tabsel', a:palette.normal.airline_a) + let l:tabtype = get(colors, 'airline_tabtype', a:palette.visual.airline_a) + let l:tabfill = get(colors, 'airline_tabfill', a:palette.normal.airline_c) + let l:tabmod = get(colors, 'airline_tabmod', a:palette.insert.airline_a) + if has_key(a:palette, 'normal_modified') && has_key(a:palette.normal_modified, 'airline_c') + let l:tabmodu = get(colors, 'airline_tabmod_unsel', a:palette.normal_modified.airline_c) + else + "Fall back to normal airline_c if modified airline_c isn't present + let l:tabmodu = get(colors, 'airline_tabmod_unsel', a:palette.normal.airline_c) + endif + + let l:tabhid = get(colors, 'airline_tabhid', a:palette.normal.airline_c) + call airline#highlighter#exec('airline_tab', l:tab) + call airline#highlighter#exec('airline_tabsel', l:tabsel) + call airline#highlighter#exec('airline_tabtype', l:tabtype) + call airline#highlighter#exec('airline_tabfill', l:tabfill) + call airline#highlighter#exec('airline_tabmod', l:tabmod) + call airline#highlighter#exec('airline_tabmod_unsel', l:tabmodu) + call airline#highlighter#exec('airline_tabhid', l:tabhid) +endfunction + +function! s:show_tabline(min_count, total_count) + if a:total_count >= a:min_count + if &showtabline != 2 + set showtabline=2 + endif + else + if &showtabline != 0 + set showtabline=0 + endif + endif +endfunction + +function! airline#extensions#tabline#get() + let curtabcnt = tabpagenr('$') + if curtabcnt != s:current_tabcnt + let s:current_tabcnt = curtabcnt + let s:current_bufnr = -1 " force a refresh... + endif + if s:show_buffers && curtabcnt == 1 + return s:get_buffers() + else + return s:get_tabs() + endif +endfunction + +function! airline#extensions#tabline#title(n) + let buflist = tabpagebuflist(a:n) + let winnr = tabpagewinnr(a:n) + return airline#extensions#tabline#get_buffer_name(buflist[winnr - 1]) +endfunction + +function! airline#extensions#tabline#get_buffer_name(nr) + return airline#extensions#tabline#{s:formatter}#format(a:nr, get(s:, 'current_buffer_list', s:get_buffer_list())) +endfunction + +function! s:get_buffer_list() + let buffers = [] + let cur = bufnr('%') + for nr in range(1, bufnr('$')) + if buflisted(nr) && bufexists(nr) + for ex in s:excludes + if match(bufname(nr), ex) + continue + endif + endfor + if getbufvar(nr, 'current_syntax') == 'qf' + continue + endif + call add(buffers, nr) + endif + endfor + + let s:current_buffer_list = buffers + return buffers +endfunction + +function! s:get_visible_buffers() + let buffers = s:get_buffer_list() + let cur = bufnr('%') + + let total_width = 0 + let max_width = 0 + + for nr in buffers + let width = len(airline#extensions#tabline#get_buffer_name(nr)) + 4 + let total_width += width + let max_width = max([max_width, width]) + endfor + + " only show current and surrounding buffers if there are too many buffers + let position = index(buffers, cur) + let vimwidth = &columns + if total_width > vimwidth && position > -1 + let buf_count = len(buffers) + + " determine how many buffers to show based on the longest buffer width, + " use one on the right side and put the rest on the left + let buf_max = vimwidth / max_width + let buf_right = 1 + let buf_left = max([0, buf_max - buf_right]) + + let start = max([0, position - buf_left]) + let end = min([buf_count, position + buf_right]) + + " fill up available space on the right + if position < buf_left + let end += (buf_left - position) + endif + + " fill up available space on the left + if end > buf_count - 1 - buf_right + let start -= max([0, buf_right - (buf_count - 1 - position)]) + endif + + let buffers = eval('buffers[' . start . ':' . end . ']') + + if start > 0 + call insert(buffers, -1, 0) + endif + + if end < buf_count - 1 + call add(buffers, -1) + endif + endif + + let g:current_visible_buffers = buffers + return buffers +endfunction + +let s:current_bufnr = -1 +let s:current_tabnr = -1 +let s:current_tabcnt = -1 +let s:current_tabline = '' +let s:current_modified = 0 +function! s:get_buffers() + let cur = bufnr('%') + if cur == s:current_bufnr + if !g:airline_detect_modified || getbufvar(cur, '&modified') == s:current_modified + return s:current_tabline + endif + endif + + let l:index = 1 + let b = s:new_builder() + let tab_bufs = tabpagebuflist(tabpagenr()) + for nr in s:get_visible_buffers() + if nr < 0 + call b.add_raw('%#airline_tabhid#...') + continue + endif + + if cur == nr + if g:airline_detect_modified && getbufvar(nr, '&modified') + let group = 'airline_tabmod' + else + let group = 'airline_tabsel' + endif + let s:current_modified = (group == 'airline_tabmod') ? 1 : 0 + else + if g:airline_detect_modified && getbufvar(nr, '&modified') + let group = 'airline_tabmod_unsel' + elseif index(tab_bufs, nr) > -1 + let group = 'airline_tab' + else + let group = 'airline_tabhid' + endif + endif + + if s:buffer_idx_mode + if len(s:number_map) > 0 + call b.add_section(group, s:spc . get(s:number_map, l:index, '') . '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)' . s:spc) + else + call b.add_section(group, '['.l:index.s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.']') + endif + let l:index = l:index + 1 + else + call b.add_section(group, s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.s:spc) + endif + endfor + + call b.add_section('airline_tabfill', '') + call b.split() + call b.add_section('airline_tabfill', '') + call b.add_section('airline_tabtype', ' buffers ') + + let s:current_bufnr = cur + let s:current_tabline = b.build() + return s:current_tabline +endfunction + +function! s:select_tab(buf_index) + " no-op when called in the NERDTree buffer + if exists('t:NERDTreeBufName') && bufname('%') == t:NERDTreeBufName + return + endif + + let idx = a:buf_index + if g:current_visible_buffers[0] == -1 + let idx = idx + 1 + endif + + let buf = get(g:current_visible_buffers, idx, 0) + if buf != 0 + exec 'b!' . buf + endif +endfunction + +function! s:define_buffer_idx_mode_mappings() + noremap AirlineSelectTab1 :call select_tab(0) + noremap AirlineSelectTab2 :call select_tab(1) + noremap AirlineSelectTab3 :call select_tab(2) + noremap AirlineSelectTab4 :call select_tab(3) + noremap AirlineSelectTab5 :call select_tab(4) + noremap AirlineSelectTab6 :call select_tab(5) + noremap AirlineSelectTab7 :call select_tab(6) + noremap AirlineSelectTab8 :call select_tab(7) + noremap AirlineSelectTab9 :call select_tab(8) +endfunction + +function! s:new_builder() + let builder_context = { + \ 'active' : 1, + \ 'right_sep' : get(g:, 'airline#extensions#tabline#right_sep' , g:airline_right_sep), + \ 'right_alt_sep' : get(g:, 'airline#extensions#tabline#right_alt_sep', g:airline_right_alt_sep), + \ } + if get(g:, 'airline_powerline_fonts', 0) + let builder_context.left_sep = get(g:, 'airline#extensions#tabline#left_sep' , g:airline_left_sep) + let builder_context.left_alt_sep = get(g:, 'airline#extensions#tabline#left_alt_sep' , g:airline_left_alt_sep) + else + let builder_context.left_sep = get(g:, 'airline#extensions#tabline#left_sep' , ' ') + let builder_context.left_alt_sep = get(g:, 'airline#extensions#tabline#left_alt_sep' , '|') + endif + + return airline#builder#new(builder_context) +endfunction + +function! s:get_tabs() + let curbuf = bufnr('%') + let curtab = tabpagenr() + if curbuf == s:current_bufnr && curtab == s:current_tabnr + if !g:airline_detect_modified || getbufvar(curbuf, '&modified') == s:current_modified + return s:current_tabline + endif + endif + + let b = s:new_builder() + for i in range(1, tabpagenr('$')) + if i == curtab + let group = 'airline_tabsel' + if g:airline_detect_modified + for bi in tabpagebuflist(i) + if getbufvar(bi, '&modified') + let group = 'airline_tabmod' + endif + endfor + endif + let s:current_modified = (group == 'airline_tabmod') ? 1 : 0 + else + let group = 'airline_tab' + endif + let val = '%(' + if s:show_tab_nr + if s:tab_nr_type == 0 + let val .= ' %{len(tabpagebuflist('.i.'))}' + else + let val .= (g:airline_symbols.space).i + endif + endif + call b.add_section(group, val.'%'.i.'T %{airline#extensions#tabline#title('.i.')} %)') + endfor + + call b.add_raw('%T') + call b.add_section('airline_tabfill', '') + call b.split() + if s:show_close_button + call b.add_section('airline_tab', ' %999X'.s:close_symbol.' ') + endif + if s:show_tab_type + call b.add_section('airline_tabtype', ' tabs ') + endif + + let s:current_bufnr = curbuf + let s:current_tabnr = curtab + let s:current_tabline = b.build() + return s:current_tabline +endfunction diff --git a/.vim/autoload/airline/extensions/tabline/default.vim b/.vim/autoload/airline/extensions/tabline/default.vim new file mode 100644 index 0000000..4f1ed40 --- /dev/null +++ b/.vim/autoload/airline/extensions/tabline/default.vim @@ -0,0 +1,35 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let s:fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.') +let s:fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1) +let s:buf_nr_format = get(g:, 'airline#extensions#tabline#buffer_nr_format', '%s: ') +let s:buf_nr_show = get(g:, 'airline#extensions#tabline#buffer_nr_show', 0) +let s:buf_modified_symbol = g:airline_symbols.modified + +function! airline#extensions#tabline#default#format(bufnr, buffers) + let _ = '' + + let name = bufname(a:bufnr) + if empty(name) + let _ .= '[No Name]' + else + if s:fnamecollapse + let _ .= substitute(fnamemodify(name, s:fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g') + else + let _ .= fnamemodify(name, s:fmod) + endif + endif + + return airline#extensions#tabline#default#wrap_name(a:bufnr, _) +endfunction + +function! airline#extensions#tabline#default#wrap_name(bufnr, buffer_name) + let _ = s:buf_nr_show ? printf(s:buf_nr_format, a:bufnr) : '' + let _ .= substitute(a:buffer_name, '\\', '/', 'g') + + if getbufvar(a:bufnr, '&modified') == 1 + let _ .= s:buf_modified_symbol + endif + return _ +endfunction diff --git a/.vim/autoload/airline/extensions/tabline/unique_tail.vim b/.vim/autoload/airline/extensions/tabline/unique_tail.vim new file mode 100644 index 0000000..e4a790d --- /dev/null +++ b/.vim/autoload/airline/extensions/tabline/unique_tail.vim @@ -0,0 +1,27 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +function! airline#extensions#tabline#unique_tail#format(bufnr, buffers) + let duplicates = {} + let tails = {} + let map = {} + for nr in a:buffers + let name = bufname(nr) + if empty(name) + let map[nr] = '[No Name]' + else + let tail = fnamemodify(name, ':t') + if has_key(tails, tail) + let duplicates[nr] = nr + endif + let tails[tail] = 1 + let map[nr] = airline#extensions#tabline#default#wrap_name(nr, tail) + endif + endfor + + for nr in values(duplicates) + let map[nr] = airline#extensions#tabline#default#wrap_name(nr, fnamemodify(bufname(nr), ':p:.')) + endfor + + return map[a:bufnr] +endfunction diff --git a/.vim/autoload/airline/extensions/tabline/unique_tail_improved.vim b/.vim/autoload/airline/extensions/tabline/unique_tail_improved.vim new file mode 100644 index 0000000..3590fbb --- /dev/null +++ b/.vim/autoload/airline/extensions/tabline/unique_tail_improved.vim @@ -0,0 +1,89 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let s:skip_symbol = '…' + +function! airline#extensions#tabline#unique_tail_improved#format(bufnr, buffers) + if len(a:buffers) <= 1 " don't need to compare bufnames if has less than one buffer opened + return airline#extensions#tabline#default#format(a:bufnr, a:buffers) + endif + + let curbuf_tail = fnamemodify(bufname(a:bufnr), ':t') + let do_deduplicate = 0 + let path_tokens = {} + + for nr in a:buffers + let name = bufname(nr) + if !empty(name) && nr != a:bufnr && fnamemodify(name, ':t') == curbuf_tail " only perform actions if curbuf_tail isn't unique + let do_deduplicate = 1 + let tokens = reverse(split(substitute(fnamemodify(name, ':p:h'), '\\', '/', 'g'), '/')) + let token_index = 0 + for token in tokens + if token == '' | continue | endif + if token == '.' | break | endif + if !has_key(path_tokens, token_index) + let path_tokens[token_index] = {} + endif + let path_tokens[token_index][token] = 1 + let token_index += 1 + endfor + endif + endfor + + if do_deduplicate == 1 + let path = [] + let token_index = 0 + for token in reverse(split(substitute(fnamemodify(bufname(a:bufnr), ':p:h'), '\\', '/', 'g'), '/')) + if token == '.' | break | endif + let duplicated = 0 + let uniq = 1 + let single = 1 + if has_key(path_tokens, token_index) + let duplicated = 1 + if len(keys(path_tokens[token_index])) > 1 | let single = 0 | endif + if has_key(path_tokens[token_index], token) | let uniq = 0 | endif + endif + call insert(path, {'token': token, 'duplicated': duplicated, 'uniq': uniq, 'single': single}) + let token_index += 1 + endfor + + let buf_name = [curbuf_tail] + let has_uniq = 0 + let has_skipped = 0 + for token1 in reverse(path) + if !token1['duplicated'] && len(buf_name) > 1 + call insert(buf_name, s:skip_symbol) + let has_skipped = 0 + break + endif + + if has_uniq == 1 + call insert(buf_name, s:skip_symbol) + let has_skipped = 0 + break + endif + + if token1['uniq'] == 0 && token1['single'] == 1 + let has_skipped = 1 + else + if has_skipped == 1 + call insert(buf_name, s:skip_symbol) + let has_skipped = 0 + endif + call insert(buf_name, token1['token']) + endif + + if token1['uniq'] == 1 + let has_uniq = 1 + endif + endfor + + if has_skipped == 1 + call insert(buf_name, s:skip_symbol) + endif + + return airline#extensions#tabline#default#wrap_name(a:bufnr, join(buf_name, '/')) + else + return airline#extensions#tabline#default#format(a:bufnr, a:buffers) + endif +endfunction diff --git a/.vim/autoload/airline/extensions/tagbar.vim b/.vim/autoload/airline/extensions/tagbar.vim new file mode 100644 index 0000000..56919a8 --- /dev/null +++ b/.vim/autoload/airline/extensions/tagbar.vim @@ -0,0 +1,45 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !exists(':TagbarToggle') + finish +endif + +let s:flags = get(g:, 'airline#extensions#tagbar#flags', '') +let s:spc = g:airline_symbols.space + +" Arguments: current, sort, fname +function! airline#extensions#tagbar#get_status(...) + let builder = airline#builder#new({ 'active': a:1 }) + call builder.add_section('airline_a', s:spc.'Tagbar'.s:spc) + call builder.add_section('airline_b', s:spc.a:2.s:spc) + call builder.add_section('airline_c', s:spc.a:3.s:spc) + return builder.build() +endfunction + +function! airline#extensions#tagbar#inactive_apply(...) + if getwinvar(a:2.winnr, '&filetype') == 'tagbar' + return -1 + endif +endfunction + +let s:airline_tagbar_last_lookup_time = 0 +let s:airline_tagbar_last_lookup_val = '' +function! airline#extensions#tagbar#currenttag() + if get(w:, 'airline_active', 0) + if s:airline_tagbar_last_lookup_time != localtime() + let s:airline_tagbar_last_lookup_val = tagbar#currenttag('%s', '', s:flags) + let s:airline_tagbar_last_lookup_time = localtime() + endif + return s:airline_tagbar_last_lookup_val + endif + return '' +endfunction + +function! airline#extensions#tagbar#init(ext) + call a:ext.add_inactive_statusline_func('airline#extensions#tagbar#inactive_apply') + let g:tagbar_status_func = 'airline#extensions#tagbar#get_status' + + call airline#parts#define_function('tagbar', 'airline#extensions#tagbar#currenttag') +endfunction + diff --git a/.vim/autoload/airline/extensions/tmuxline.vim b/.vim/autoload/airline/extensions/tmuxline.vim new file mode 100644 index 0000000..363709b --- /dev/null +++ b/.vim/autoload/airline/extensions/tmuxline.vim @@ -0,0 +1,26 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !exists(':Tmuxline') + finish +endif + +let s:tmuxline_snapshot_file = get(g:, 'airline#extensions#tmuxline#snapshot_file', '') +let s:color_template = get(g:, 'airline#extensions#tmuxline#color_template', 'normal') + +function! airline#extensions#tmuxline#init(ext) + call a:ext.add_theme_func('airline#extensions#tmuxline#set_tmux_colors') +endfunction + +function! airline#extensions#tmuxline#set_tmux_colors(palette) + let color_template = has_key(a:palette, s:color_template) ? s:color_template : 'normal' + let mode_palette = a:palette[color_template] + + let tmuxline_theme = tmuxline#api#create_theme_from_airline(mode_palette) + call tmuxline#api#set_theme(tmuxline_theme) + + if strlen(s:tmuxline_snapshot_file) + call tmuxline#api#snapshot(s:tmuxline_snapshot_file) + endif +endfunction + diff --git a/.vim/autoload/airline/extensions/undotree.vim b/.vim/autoload/airline/extensions/undotree.vim new file mode 100644 index 0000000..f577ffd --- /dev/null +++ b/.vim/autoload/airline/extensions/undotree.vim @@ -0,0 +1,27 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !exists(':UndotreeToggle') + finish +endif + +function! airline#extensions#undotree#apply(...) + if exists('t:undotree') + if &ft == 'undotree' + if exists('*t:undotree.GetStatusLine') + call airline#extensions#apply_left_override('undo', '%{t:undotree.GetStatusLine()}') + else + call airline#extensions#apply_left_override('undotree', '%f') + endif + endif + + if &ft == 'diff' && exists('*t:diffpanel.GetStatusLine') + call airline#extensions#apply_left_override('diff', '%{t:diffpanel.GetStatusLine()}') + endif + endif +endfunction + +function! airline#extensions#undotree#init(ext) + call a:ext.add_statusline_func('airline#extensions#undotree#apply') +endfunction + diff --git a/.vim/autoload/airline/extensions/unite.vim b/.vim/autoload/airline/extensions/unite.vim new file mode 100644 index 0000000..d230b6f --- /dev/null +++ b/.vim/autoload/airline/extensions/unite.vim @@ -0,0 +1,23 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !get(g:, 'loaded_unite', 0) + finish +endif + +function! airline#extensions#unite#apply(...) + if &ft == 'unite' + call a:1.add_section('airline_a', ' Unite ') + call a:1.add_section('airline_b', ' %{get(unite#get_context(), "buffer_name", "")} ') + call a:1.add_section('airline_c', ' %{unite#get_status_string()} ') + call a:1.split() + call a:1.add_section('airline_y', ' %{get(unite#get_context(), "real_buffer_name", "")} ') + return 1 + endif +endfunction + +function! airline#extensions#unite#init(ext) + let g:unite_force_overwrite_statusline = 0 + call a:ext.add_statusline_func('airline#extensions#unite#apply') +endfunction + diff --git a/.vim/autoload/airline/extensions/virtualenv.vim b/.vim/autoload/airline/extensions/virtualenv.vim new file mode 100644 index 0000000..27f847e --- /dev/null +++ b/.vim/autoload/airline/extensions/virtualenv.vim @@ -0,0 +1,25 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !isdirectory($VIRTUAL_ENV) + finish +endif + +let s:spc = g:airline_symbols.space + +function! airline#extensions#virtualenv#init(ext) + call a:ext.add_statusline_func('airline#extensions#virtualenv#apply') +endfunction + +function! airline#extensions#virtualenv#apply(...) + if &filetype =~ "python" + if get(g:, 'virtualenv_loaded', 0) + let statusline = virtualenv#statusline() + else + let statusline = fnamemodify($VIRTUAL_ENV, ':t') + endif + call airline#extensions#append_to_section('x', + \ s:spc.g:airline_right_alt_sep.s:spc.statusline) + endif +endfunction + diff --git a/.vim/autoload/airline/extensions/whitespace.vim b/.vim/autoload/airline/extensions/whitespace.vim new file mode 100644 index 0000000..8657412 --- /dev/null +++ b/.vim/autoload/airline/extensions/whitespace.vim @@ -0,0 +1,103 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +" http://got-ravings.blogspot.com/2008/10/vim-pr0n-statusline-whitespace-flags.html + +" for backwards compatibility +if exists('g:airline_detect_whitespace') + let s:show_message = g:airline_detect_whitespace == 1 +else + let s:show_message = get(g:, 'airline#extensions#whitespace#show_message', 1) +endif + +let s:symbol = get(g:, 'airline#extensions#whitespace#symbol', g:airline_symbols.whitespace) +let s:default_checks = ['indent', 'trailing'] + +let s:trailing_format = get(g:, 'airline#extensions#whitespace#trailing_format', 'trailing[%s]') +let s:mixed_indent_format = get(g:, 'airline#extensions#whitespace#mixed_indent_format', 'mixed-indent[%s]') +let s:indent_algo = get(g:, 'airline#extensions#whitespace#mixed_indent_algo', 0) + +let s:max_lines = get(g:, 'airline#extensions#whitespace#max_lines', 20000) + +let s:enabled = get(g:, 'airline#extensions#whitespace#enabled', 1) + +function! s:check_mixed_indent() + if s:indent_algo == 1 + " [] + " spaces before or between tabs are not allowed + let t_s_t = '(^\t* +\t\s*\S)' + " ( x count) + " count of spaces at the end of tabs should be less then tabstop value + let t_l_s = '(^\t+ {' . &ts . ',}' . '\S)' + return search('\v' . t_s_t . '|' . t_l_s, 'nw') + else + return search('\v(^\t+ +)|(^ +\t+)', 'nw') + endif +endfunction + +function! airline#extensions#whitespace#check() + if &readonly || !&modifiable || !s:enabled || line('$') > s:max_lines + return '' + endif + + if !exists('b:airline_whitespace_check') + let b:airline_whitespace_check = '' + let checks = get(g:, 'airline#extensions#whitespace#checks', s:default_checks) + + let trailing = 0 + if index(checks, 'trailing') > -1 + let trailing = search('\s$', 'nw') + endif + + let mixed = 0 + if index(checks, 'indent') > -1 + let mixed = s:check_mixed_indent() + endif + + if trailing != 0 || mixed != 0 + let b:airline_whitespace_check = s:symbol + if s:show_message + if trailing != 0 + let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:trailing_format, trailing) + endif + if mixed != 0 + let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:mixed_indent_format, mixed) + endif + endif + endif + endif + return b:airline_whitespace_check +endfunction! + +function! airline#extensions#whitespace#toggle() + if s:enabled + augroup airline_whitespace + autocmd! + augroup END + augroup! airline_whitespace + let s:enabled = 0 + else + call airline#extensions#whitespace#init() + let s:enabled = 1 + endif + + if exists("g:airline#extensions#whitespace#enabled") + let g:airline#extensions#whitespace#enabled = s:enabled + if s:enabled && match(g:airline_section_warning, '#whitespace#check') < 0 + let g:airline_section_warning .= airline#section#create(['whitespace']) + call airline#update_statusline() + endif + endif + echo 'Whitespace checking: '.(s:enabled ? 'Enabled' : 'Disabled') +endfunction + +function! airline#extensions#whitespace#init(...) + call airline#parts#define_function('whitespace', 'airline#extensions#whitespace#check') + + unlet! b:airline_whitespace_check + augroup airline_whitespace + autocmd! + autocmd CursorHold,BufWritePost * unlet! b:airline_whitespace_check + augroup END +endfunction + diff --git a/.vim/autoload/airline/extensions/windowswap.vim b/.vim/autoload/airline/extensions/windowswap.vim new file mode 100644 index 0000000..2beb91c --- /dev/null +++ b/.vim/autoload/airline/extensions/windowswap.vim @@ -0,0 +1,23 @@ +" vim: et ts=2 sts=2 sw=2 + +if !exists('g:loaded_windowswap') + finish +endif + +let s:spc = g:airline_symbols.space + +if !exists('g:airline#extensions#windowswap#indicator_text') + let g:airline#extensions#windowswap#indicator_text = 'WS' +endif + +function! airline#extensions#windowswap#init(ext) + call airline#parts#define_function('windowswap', 'airline#extensions#windowswap#get_status') +endfunction + +function! airline#extensions#windowswap#get_status() + if WindowSwap#HasMarkedWindow() && WindowSwap#GetMarkedWindowNum() == winnr() + return g:airline#extensions#windowswap#indicator_text.s:spc + endif + return '' +endfunction + diff --git a/.vim/autoload/airline/highlighter.vim b/.vim/autoload/airline/highlighter.vim new file mode 100644 index 0000000..17a6cf5 --- /dev/null +++ b/.vim/autoload/airline/highlighter.vim @@ -0,0 +1,159 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running') +let s:separators = {} +let s:accents = {} + +function! s:gui2cui(rgb, fallback) + if a:rgb == '' + return a:fallback + endif + let rgb = map(matchlist(a:rgb, '#\(..\)\(..\)\(..\)')[1:3], '0 + ("0x".v:val)') + let rgb = [rgb[0] > 127 ? 4 : 0, rgb[1] > 127 ? 2 : 0, rgb[2] > 127 ? 1 : 0] + return rgb[0]+rgb[1]+rgb[2] +endfunction + +function! s:get_syn(group, what) + " need to pass in mode, known to break on 7.3.547 + let mode = has('gui_running') ? 'gui' : 'cterm' + let color = synIDattr(synIDtrans(hlID(a:group)), a:what, mode) + if empty(color) || color == -1 + let color = synIDattr(synIDtrans(hlID('Normal')), a:what, mode) + endif + if empty(color) || color == -1 + if has('gui_running') + let color = a:what ==# 'fg' ? '#000000' : '#FFFFFF' + else + let color = a:what ==# 'fg' ? 0 : 1 + endif + endif + return color +endfunction + +function! s:get_array(fg, bg, opts) + let fg = a:fg + let bg = a:bg + return has('gui_running') + \ ? [ fg, bg, '', '', join(a:opts, ',') ] + \ : [ '', '', fg, bg, join(a:opts, ',') ] +endfunction + +function! airline#highlighter#get_highlight(group, ...) + let fg = s:get_syn(a:group, 'fg') + let bg = s:get_syn(a:group, 'bg') + let reverse = has('gui_running') + \ ? synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'gui') + \ : synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'cterm') + \|| synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'term') + return reverse ? s:get_array(bg, fg, a:000) : s:get_array(fg, bg, a:000) +endfunction + +function! airline#highlighter#get_highlight2(fg, bg, ...) + let fg = s:get_syn(a:fg[0], a:fg[1]) + let bg = s:get_syn(a:bg[0], a:bg[1]) + return s:get_array(fg, bg, a:000) +endfunction + +function! airline#highlighter#exec(group, colors) + let colors = a:colors + if s:is_win32term + let colors[2] = s:gui2cui(get(colors, 0, ''), get(colors, 2, '')) + let colors[3] = s:gui2cui(get(colors, 1, ''), get(colors, 3, '')) + endif + exec printf('hi %s %s %s %s %s %s %s %s', + \ a:group, + \ get(colors, 0, '') != '' ? 'guifg='.colors[0] : '', + \ get(colors, 1, '') != '' ? 'guibg='.colors[1] : '', + \ get(colors, 2, '') != '' ? 'ctermfg='.colors[2] : '', + \ get(colors, 3, '') != '' ? 'ctermbg='.colors[3] : '', + \ get(colors, 4, '') != '' ? 'gui='.colors[4] : '', + \ get(colors, 4, '') != '' ? 'cterm='.colors[4] : '', + \ get(colors, 4, '') != '' ? 'term='.colors[4] : '') +endfunction + +function! s:exec_separator(dict, from, to, inverse, suffix) + let l:from = airline#themes#get_highlight(a:from.a:suffix) + let l:to = airline#themes#get_highlight(a:to.a:suffix) + let group = a:from.'_to_'.a:to.a:suffix + if a:inverse + let colors = [ l:from[1], l:to[1], l:from[3], l:to[3] ] + else + let colors = [ l:to[1], l:from[1], l:to[3], l:from[3] ] + endif + let a:dict[group] = colors + call airline#highlighter#exec(group, colors) +endfunction + +function! airline#highlighter#load_theme() + for winnr in filter(range(1, winnr('$')), 'v:val != winnr()') + call airline#highlighter#highlight_modified_inactive(winbufnr(winnr)) + endfor + call airline#highlighter#highlight(['inactive']) + call airline#highlighter#highlight(['normal']) +endfunction + +function! airline#highlighter#add_separator(from, to, inverse) + let s:separators[a:from.a:to] = [a:from, a:to, a:inverse] + call exec_separator({}, a:from, a:to, a:inverse, '') +endfunction + +function! airline#highlighter#add_accent(accent) + let s:accents[a:accent] = 1 +endfunction + +function! airline#highlighter#highlight_modified_inactive(bufnr) + if getbufvar(a:bufnr, '&modified') + let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c') + \ ? g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c : [] + else + let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive.airline_c') + \ ? g:airline#themes#{g:airline_theme}#palette.inactive.airline_c : [] + endif + + if !empty(colors) + call airline#highlighter#exec('airline_c'.(a:bufnr).'_inactive', colors) + endif +endfunction + +function! airline#highlighter#highlight(modes) + let p = g:airline#themes#{g:airline_theme}#palette + + " draw the base mode, followed by any overrides + let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val') + let suffix = a:modes[0] == 'inactive' ? '_inactive' : '' + for mode in mapped + if exists('g:airline#themes#{g:airline_theme}#palette[mode]') + let dict = g:airline#themes#{g:airline_theme}#palette[mode] + for kvp in items(dict) + let mode_colors = kvp[1] + call airline#highlighter#exec(kvp[0].suffix, mode_colors) + + for accent in keys(s:accents) + if !has_key(p.accents, accent) + continue + endif + let colors = copy(mode_colors) + if p.accents[accent][0] != '' + let colors[0] = p.accents[accent][0] + endif + if p.accents[accent][2] != '' + let colors[2] = p.accents[accent][2] + endif + if len(colors) >= 5 + let colors[4] = get(p.accents[accent], 4, '') + else + call add(colors, get(p.accents[accent], 4, '')) + endif + call airline#highlighter#exec(kvp[0].suffix.'_'.accent, colors) + endfor + endfor + + " TODO: optimize this + for sep in items(s:separators) + call exec_separator(dict, sep[1][0], sep[1][1], sep[1][2], suffix) + endfor + endif + endfor +endfunction + diff --git a/.vim/autoload/airline/init.vim b/.vim/autoload/airline/init.vim new file mode 100644 index 0000000..021b3b2 --- /dev/null +++ b/.vim/autoload/airline/init.vim @@ -0,0 +1,114 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +function! s:check_defined(variable, default) + if !exists(a:variable) + let {a:variable} = a:default + endif +endfunction + +let s:loaded = 0 +function! airline#init#bootstrap() + if s:loaded + return + endif + let s:loaded = 1 + + let g:airline#init#bootstrapping = 1 + + call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b0":">") + call s:check_defined('g:airline_left_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b1":">") + call s:check_defined('g:airline_right_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b2":"<") + call s:check_defined('g:airline_right_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b3":"<") + call s:check_defined('g:airline_detect_modified', 1) + call s:check_defined('g:airline_detect_paste', 1) + call s:check_defined('g:airline_detect_iminsert', 0) + call s:check_defined('g:airline_inactive_collapse', 1) + call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus']) + call s:check_defined('g:airline_exclude_filetypes', []) + call s:check_defined('g:airline_exclude_preview', 0) + + call s:check_defined('g:airline_mode_map', {}) + call extend(g:airline_mode_map, { + \ '__' : '------', + \ 'n' : 'NORMAL', + \ 'i' : 'INSERT', + \ 'R' : 'REPLACE', + \ 'v' : 'VISUAL', + \ 'V' : 'V-LINE', + \ 'c' : 'COMMAND', + \ '' : 'V-BLOCK', + \ 's' : 'SELECT', + \ 'S' : 'S-LINE', + \ '' : 'S-BLOCK', + \ }, 'keep') + + call s:check_defined('g:airline_theme_map', {}) + call extend(g:airline_theme_map, { + \ 'Tomorrow.*': 'tomorrow', + \ 'base16.*': 'base16', + \ 'mo[l|n]okai': 'molokai', + \ 'wombat.*': 'wombat', + \ '.*zenburn.*': 'zenburn', + \ '.*solarized.*': 'solarized', + \ }, 'keep') + + call s:check_defined('g:airline_symbols', {}) + call extend(g:airline_symbols, { + \ 'paste': get(g:, 'airline_paste_symbol', 'PASTE'), + \ 'readonly': get(g:, 'airline_readonly_symbol', get(g:, 'airline_powerline_fonts', 0) ? "\ue0a2" : 'RO'), + \ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? "\u2739" : '!', + \ 'linenr': get(g:, 'airline_linecolumn_prefix', get(g:, 'airline_powerline_fonts', 0) ? "\ue0a1" : ':' ), + \ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? "\ue0a0" : ''), + \ 'modified': '+', + \ 'space': ' ', + \ }, 'keep') + + call airline#parts#define('mode', { + \ 'function': 'airline#parts#mode', + \ 'accent': 'bold', + \ }) + call airline#parts#define_function('iminsert', 'airline#parts#iminsert') + call airline#parts#define_function('paste', 'airline#parts#paste') + call airline#parts#define_function('filetype', 'airline#parts#filetype') + call airline#parts#define('readonly', { + \ 'function': 'airline#parts#readonly', + \ 'accent': 'red', + \ }) + call airline#parts#define_raw('file', '%f%m') + call airline#parts#define_raw('linenr', '%{g:airline_symbols.linenr}%#__accent_bold#%4l%#__restore__#') + call airline#parts#define_function('ffenc', 'airline#parts#ffenc') + call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'eclim', 'whitespace','windowswap']) + call airline#parts#define_text('capslock', '') + + unlet g:airline#init#bootstrapping +endfunction + +function! airline#init#sections() + let spc = g:airline_symbols.space + if !exists('g:airline_section_a') + let g:airline_section_a = airline#section#create_left(['mode', 'paste', 'capslock', 'iminsert']) + endif + if !exists('g:airline_section_b') + let g:airline_section_b = airline#section#create(['hunks', 'branch']) + endif + if !exists('g:airline_section_c') + let g:airline_section_c = airline#section#create(['%<', 'file', spc, 'readonly']) + endif + if !exists('g:airline_section_gutter') + let g:airline_section_gutter = airline#section#create(['%=']) + endif + if !exists('g:airline_section_x') + let g:airline_section_x = airline#section#create_right(['tagbar', 'filetype']) + endif + if !exists('g:airline_section_y') + let g:airline_section_y = airline#section#create_right(['ffenc']) + endif + if !exists('g:airline_section_z') + let g:airline_section_z = airline#section#create(['windowswap', '%3p%%'.spc, 'linenr', ':%3c ']) + endif + if !exists('g:airline_section_warning') + let g:airline_section_warning = airline#section#create(['syntastic', 'eclim', 'whitespace']) + endif +endfunction + diff --git a/.vim/autoload/airline/parts.vim b/.vim/autoload/airline/parts.vim new file mode 100644 index 0000000..b0356b1 --- /dev/null +++ b/.vim/autoload/airline/parts.vim @@ -0,0 +1,79 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let s:parts = {} + +" PUBLIC API {{{ + +function! airline#parts#define(key, config) + let s:parts[a:key] = get(s:parts, a:key, {}) + if exists('g:airline#init#bootstrapping') + call extend(s:parts[a:key], a:config, 'keep') + else + call extend(s:parts[a:key], a:config, 'force') + endif +endfunction + +function! airline#parts#define_function(key, name) + call airline#parts#define(a:key, { 'function': a:name }) +endfunction + +function! airline#parts#define_text(key, text) + call airline#parts#define(a:key, { 'text': a:text }) +endfunction + +function! airline#parts#define_raw(key, raw) + call airline#parts#define(a:key, { 'raw': a:raw }) +endfunction + +function! airline#parts#define_minwidth(key, width) + call airline#parts#define(a:key, { 'minwidth': a:width }) +endfunction + +function! airline#parts#define_condition(key, predicate) + call airline#parts#define(a:key, { 'condition': a:predicate }) +endfunction + +function! airline#parts#define_accent(key, accent) + call airline#parts#define(a:key, { 'accent': a:accent }) +endfunction + +function! airline#parts#define_empty(keys) + for key in a:keys + call airline#parts#define_raw(key, '') + endfor +endfunction + +function! airline#parts#get(key) + return get(s:parts, a:key, {}) +endfunction + +" }}} + +function! airline#parts#mode() + return get(w:, 'airline_current_mode', '') +endfunction + +function! airline#parts#paste() + return g:airline_detect_paste && &paste ? g:airline_symbols.paste : '' +endfunction + +function! airline#parts#iminsert() + if g:airline_detect_iminsert && &iminsert && exists('b:keymap_name') + return toupper(b:keymap_name) + endif + return '' +endfunction + +function! airline#parts#readonly() + return &readonly ? g:airline_symbols.readonly : '' +endfunction + +function! airline#parts#filetype() + return &filetype +endfunction + +function! airline#parts#ffenc() + return printf('%s%s', &fenc, strlen(&ff) > 0 ? '['.&ff.']' : '') +endfunction + diff --git a/.vim/autoload/airline/section.vim b/.vim/autoload/airline/section.vim new file mode 100644 index 0000000..06d930f --- /dev/null +++ b/.vim/autoload/airline/section.vim @@ -0,0 +1,73 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +call airline#init#bootstrap() +let s:spc = g:airline_symbols.space + +function! s:wrap_accent(part, value) + if exists('a:part.accent') + call airline#highlighter#add_accent(a:part.accent) + return '%#__accent_'.(a:part.accent).'#'.a:value.'%#__restore__#' + endif + return a:value +endfunction + +function! s:create(parts, append) + let _ = '' + for idx in range(len(a:parts)) + let part = airline#parts#get(a:parts[idx]) + let val = '' + + if exists('part.function') + let func = (part.function).'()' + elseif exists('part.text') + let func = '"'.(part.text).'"' + else + if a:append > 0 && idx != 0 + let val .= s:spc.g:airline_left_alt_sep.s:spc + endif + if a:append < 0 && idx != 0 + let val = s:spc.g:airline_right_alt_sep.s:spc.val + endif + if exists('part.raw') + let _ .= s:wrap_accent(part, val.(part.raw)) + continue + else + let _ .= s:wrap_accent(part, val.a:parts[idx]) + continue + endif + endif + + let minwidth = get(part, 'minwidth', 0) + + if a:append > 0 && idx != 0 + let partval = printf('%%{airline#util#append(%s,%s)}', func, minwidth) + elseif a:append < 0 && idx != len(a:parts) - 1 + let partval = printf('%%{airline#util#prepend(%s,%s)}', func, minwidth) + else + let partval = printf('%%{airline#util#wrap(%s,%s)}', func, minwidth) + endif + + if exists('part.condition') + let partval = substitute(partval, '{', '\="{".(part.condition)." ? "', '') + let partval = substitute(partval, '}', ' : ""}', '') + endif + + let val .= s:wrap_accent(part, partval) + let _ .= val + endfor + return _ +endfunction + +function! airline#section#create(parts) + return s:create(a:parts, 0) +endfunction + +function! airline#section#create_left(parts) + return s:create(a:parts, 1) +endfunction + +function! airline#section#create_right(parts) + return s:create(a:parts, -1) +endfunction + diff --git a/.vim/autoload/airline/themes.vim b/.vim/autoload/airline/themes.vim new file mode 100644 index 0000000..07e0324 --- /dev/null +++ b/.vim/autoload/airline/themes.vim @@ -0,0 +1,67 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +" generates a dictionary which defines the colors for each highlight group +function! airline#themes#generate_color_map(sect1, sect2, sect3, ...) + let palette = { + \ 'airline_a': [ a:sect1[0] , a:sect1[1] , a:sect1[2] , a:sect1[3] , get(a:sect1 , 4 , '') ] , + \ 'airline_b': [ a:sect2[0] , a:sect2[1] , a:sect2[2] , a:sect2[3] , get(a:sect2 , 4 , '') ] , + \ 'airline_c': [ a:sect3[0] , a:sect3[1] , a:sect3[2] , a:sect3[3] , get(a:sect3 , 4 , '') ] , + \ } + + if a:0 > 0 + call extend(palette, { + \ 'airline_x': [ a:1[0] , a:1[1] , a:1[2] , a:1[3] , get(a:1 , 4 , '' ) ] , + \ 'airline_y': [ a:2[0] , a:2[1] , a:2[2] , a:2[3] , get(a:2 , 4 , '' ) ] , + \ 'airline_z': [ a:3[0] , a:3[1] , a:3[2] , a:3[3] , get(a:3 , 4 , '' ) ] , + \ }) + else + call extend(palette, { + \ 'airline_x': [ a:sect3[0] , a:sect3[1] , a:sect3[2] , a:sect3[3] , '' ] , + \ 'airline_y': [ a:sect2[0] , a:sect2[1] , a:sect2[2] , a:sect2[3] , '' ] , + \ 'airline_z': [ a:sect1[0] , a:sect1[1] , a:sect1[2] , a:sect1[3] , '' ] , + \ }) + endif + + return palette +endfunction + +function! airline#themes#get_highlight(group, ...) + return call('airline#highlighter#get_highlight', [a:group] + a:000) +endfunction + +function! airline#themes#get_highlight2(fg, bg, ...) + return call('airline#highlighter#get_highlight2', [a:fg, a:bg] + a:000) +endfunction + +function! airline#themes#patch(palette) + for mode in keys(a:palette) + if !has_key(a:palette[mode], 'airline_warning') + let a:palette[mode]['airline_warning'] = [ '#000000', '#df5f00', 232, 166 ] + endif + endfor + + let a:palette.accents = get(a:palette, 'accents', {}) + let a:palette.accents.bold = [ '', '', '', '', 'bold' ] + let a:palette.accents.italic = [ '', '', '', '', 'italic' ] + + if !has_key(a:palette.accents, 'red') + let a:palette.accents.red = [ '#ff0000' , '' , 160 , '' ] + endif + if !has_key(a:palette.accents, 'green') + let a:palette.accents.green = [ '#008700' , '' , 22 , '' ] + endif + if !has_key(a:palette.accents, 'blue') + let a:palette.accents.blue = [ '#005fff' , '' , 27 , '' ] + endif + if !has_key(a:palette.accents, 'yellow') + let a:palette.accents.yellow = [ '#dfff00' , '' , 190 , '' ] + endif + if !has_key(a:palette.accents, 'orange') + let a:palette.accents.orange = [ '#df5f00' , '' , 166 , '' ] + endif + if !has_key(a:palette.accents, 'purple') + let a:palette.accents.purple = [ '#af00df' , '' , 128 , '' ] + endif +endfunction + diff --git a/.vim/autoload/airline/themes/badwolf.vim b/.vim/autoload/airline/themes/badwolf.vim new file mode 100644 index 0000000..41a25d1 --- /dev/null +++ b/.vim/autoload/airline/themes/badwolf.vim @@ -0,0 +1,52 @@ +let s:N1 = [ '#141413' , '#aeee00' , 232 , 154 ] " blackestgravel & lime +let s:N2 = [ '#f4cf86' , '#45413b' , 222 , 238 ] " dirtyblonde & deepgravel +let s:N3 = [ '#8cffba' , '#242321' , 121 , 235 ] " saltwatertaffy & darkgravel +let s:N4 = [ '#666462' , 241 ] " mediumgravel + +let s:I1 = [ '#141413' , '#0a9dff' , 232 , 39 ] " blackestgravel & tardis +let s:I2 = [ '#f4cf86' , '#005fff' , 222 , 27 ] " dirtyblonde & facebook +let s:I3 = [ '#0a9dff' , '#242321' , 39 , 235 ] " tardis & darkgravel + +let s:V1 = [ '#141413' , '#ffa724' , 232 , 214 ] " blackestgravel & orange +let s:V2 = [ '#000000' , '#fade3e' , 16 , 221 ] " coal & dalespale +let s:V3 = [ '#000000' , '#b88853' , 16 , 137 ] " coal & toffee +let s:V4 = [ '#c7915b' , 173 ] " coffee + +let s:PA = [ '#f4cf86' , 222 ] " dirtyblonde +let s:RE = [ '#ff9eb8' , 211 ] " dress + +let s:IA = [ s:N2[1] , s:N3[1] , s:N2[3] , s:N3[3] , '' ] + +let g:airline#themes#badwolf#palette = {} + +let g:airline#themes#badwolf#palette.accents = { + \ 'red': [ '#ff2c4b' , '' , 196 , '' , '' ] + \ } + +let g:airline#themes#badwolf#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#badwolf#palette.normal_modified = { + \ 'airline_b': [ s:N2[0] , s:N4[0] , s:N2[2] , s:N4[1] , '' ] , + \ 'airline_c': [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } + + +let g:airline#themes#badwolf#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#badwolf#palette.insert_modified = { + \ 'airline_c': [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } +let g:airline#themes#badwolf#palette.insert_paste = { + \ 'airline_a': [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] } + + +let g:airline#themes#badwolf#palette.replace = copy(airline#themes#badwolf#palette.insert) +let g:airline#themes#badwolf#palette.replace.airline_a = [ s:I1[0] , s:RE[0] , s:I1[2] , s:RE[1] , '' ] +let g:airline#themes#badwolf#palette.replace_modified = g:airline#themes#badwolf#palette.insert_modified + + +let g:airline#themes#badwolf#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#badwolf#palette.visual_modified = { + \ 'airline_c': [ s:V3[0] , s:V4[0] , s:V3[2] , s:V4[1] , '' ] } + + +let g:airline#themes#badwolf#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) +let g:airline#themes#badwolf#palette.inactive_modified = { + \ 'airline_c': [ s:V1[1] , '' , s:V1[3] , '' , '' ] } + diff --git a/.vim/autoload/airline/themes/base16.vim b/.vim/autoload/airline/themes/base16.vim new file mode 100644 index 0000000..469435e --- /dev/null +++ b/.vim/autoload/airline/themes/base16.vim @@ -0,0 +1,107 @@ +if get(g:, 'airline#themes#base16#constant', 0) + let g:airline#themes#base16#palette = {} + + " Color palette + let s:gui_dark_gray = '#202020' + let s:cterm_dark_gray = 234 + let s:gui_med_gray_hi = '#303030' + let s:cterm_med_gray_hi = 236 + let s:gui_med_gray_lo = '#3a3a3a' + let s:cterm_med_gray_lo = 237 + let s:gui_light_gray = '#505050' + let s:cterm_light_gray = 239 + let s:gui_green = '#99cc99' + let s:cterm_green = 151 + let s:gui_blue = '#6a9fb5' + let s:cterm_blue = 67 + let s:gui_purple = '#aa759f' + let s:cterm_purple = 139 + let s:gui_orange = '#d28445' + let s:cterm_orange = 173 + let s:gui_red = '#ac4142' + let s:cterm_red = 131 + let s:gui_pink = '#d7afd7' + let s:cterm_pink = 182 + + " Normal mode + let s:N1 = [s:gui_dark_gray, s:gui_green, s:cterm_dark_gray, s:cterm_green] + let s:N2 = [s:gui_light_gray, s:gui_med_gray_lo, s:cterm_light_gray, s:cterm_med_gray_lo] + let s:N3 = [s:gui_green, s:gui_med_gray_hi, s:cterm_green, s:cterm_med_gray_hi] + let g:airline#themes#base16#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + let g:airline#themes#base16#palette.normal_modified = { + \ 'airline_c': [s:gui_orange, s:gui_med_gray_hi, s:cterm_orange, s:cterm_med_gray_hi, ''], + \ } + + " Insert mode + let s:I1 = [s:gui_med_gray_hi, s:gui_blue, s:cterm_med_gray_hi, s:cterm_blue] + let s:I3 = [s:gui_blue, s:gui_med_gray_hi, s:cterm_blue, s:cterm_med_gray_hi] + let g:airline#themes#base16#palette.insert = airline#themes#generate_color_map(s:I1, s:N2, s:I3) + let g:airline#themes#base16#palette.insert_modified = copy(g:airline#themes#base16#palette.normal_modified) + let g:airline#themes#base16#palette.insert_paste = { + \ 'airline_a': [s:gui_dark_gray, s:gui_orange, s:cterm_dark_gray, s:cterm_orange, ''], + \ } + + " Replace mode + let g:airline#themes#base16#palette.replace = { + \ 'airline_a': [s:gui_dark_gray, s:gui_red, s:cterm_dark_gray, s:cterm_red, ''], + \ 'airline_c': [s:gui_red, s:gui_med_gray_hi, s:cterm_red, s:cterm_med_gray_hi, ''], + \ } + let g:airline#themes#base16#palette.replace_modified = copy(g:airline#themes#base16#palette.insert_modified) + + " Visual mode + let s:V1 = [s:gui_dark_gray, s:gui_pink, s:cterm_dark_gray, s:cterm_pink] + let s:V3 = [s:gui_pink, s:gui_med_gray_hi, s:cterm_pink, s:cterm_med_gray_hi] + let g:airline#themes#base16#palette.visual = airline#themes#generate_color_map(s:V1, s:N2, s:V3) + let g:airline#themes#base16#palette.visual_modified = copy(g:airline#themes#base16#palette.insert_modified) + + " Inactive window + let s:IA = [s:gui_dark_gray, s:gui_med_gray_hi, s:cterm_dark_gray, s:cterm_med_gray_hi, ''] + let g:airline#themes#base16#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) + let g:airline#themes#base16#palette.inactive_modified = { + \ 'airline_c': [s:gui_orange, '', s:cterm_orange, '', ''], + \ } +else + function! airline#themes#base16#refresh() + let g:airline#themes#base16#palette = {} + + let g:airline#themes#base16#palette.accents = { + \ 'red': airline#themes#get_highlight('Constant'), + \ } + + let s:N1 = airline#themes#get_highlight2(['DiffText', 'bg'], ['DiffText', 'fg'], 'bold') + let s:N2 = airline#themes#get_highlight('Visual') + let s:N3 = airline#themes#get_highlight('CursorLine') + let g:airline#themes#base16#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + + let group = airline#themes#get_highlight('vimCommand') + let g:airline#themes#base16#palette.normal_modified = { + \ 'statusline': [ group[0], '', group[2], '', '' ] + \ } + + let s:I1 = airline#themes#get_highlight2(['DiffAdded', 'bg'], ['DiffAdded', 'fg'], 'bold') + let s:I2 = airline#themes#get_highlight2(['DiffAdded', 'fg'], ['Normal', 'bg']) + let s:I3 = s:N3 + let g:airline#themes#base16#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) + let g:airline#themes#base16#palette.insert_modified = g:airline#themes#base16#palette.normal_modified + + let s:R1 = airline#themes#get_highlight2(['WarningMsg', 'bg'], ['WarningMsg', 'fg'], 'bold') + let s:R2 = s:N2 + let s:R3 = s:N3 + let g:airline#themes#base16#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) + let g:airline#themes#base16#palette.replace_modified = g:airline#themes#base16#palette.normal_modified + + let s:V1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Constant', 'fg'], 'bold') + let s:V2 = airline#themes#get_highlight2(['Constant', 'fg'], ['Normal', 'bg']) + let s:V3 = s:N3 + let g:airline#themes#base16#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) + let g:airline#themes#base16#palette.visual_modified = g:airline#themes#base16#palette.normal_modified + + let s:IA = airline#themes#get_highlight2(['NonText', 'fg'], ['CursorLine', 'bg']) + let g:airline#themes#base16#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) + let g:airline#themes#base16#palette.inactive_modified = { + \ 'airline_c': [ group[0], '', group[2], '', '' ] + \ } + endfunction + call airline#themes#base16#refresh() +endif + diff --git a/.vim/autoload/airline/themes/bubblegum.vim b/.vim/autoload/airline/themes/bubblegum.vim new file mode 100644 index 0000000..f2378ce --- /dev/null +++ b/.vim/autoload/airline/themes/bubblegum.vim @@ -0,0 +1,70 @@ +" Color palette +let s:gui_dark_gray = '#303030' +let s:cterm_dark_gray = 236 +let s:gui_med_gray_hi = '#444444' +let s:cterm_med_gray_hi = 238 +let s:gui_med_gray_lo = '#3a3a3a' +let s:cterm_med_gray_lo = 237 +let s:gui_light_gray = '#b2b2b2' +let s:cterm_light_gray = 249 +let s:gui_green = '#afd787' +let s:cterm_green = 150 +let s:gui_blue = '#87afd7' +let s:cterm_blue = 110 +let s:gui_purple = '#afafd7' +let s:cterm_purple = 146 +let s:gui_orange = '#d7af5f' +let s:cterm_orange = 179 +let s:gui_red = '#d78787' +let s:cterm_red = 174 +let s:gui_pink = '#d7afd7' +let s:cterm_pink = 182 + +let g:airline#themes#bubblegum#palette = {} + +" Normal mode +let s:N1 = [s:gui_dark_gray, s:gui_green, s:cterm_dark_gray, s:cterm_green] +let s:N2 = [s:gui_light_gray, s:gui_med_gray_lo, s:cterm_light_gray, s:cterm_med_gray_lo] +let s:N3 = [s:gui_green, s:gui_med_gray_hi, s:cterm_green, s:cterm_med_gray_hi] +let g:airline#themes#bubblegum#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#bubblegum#palette.normal_modified = { + \ 'airline_c': [s:gui_orange, s:gui_med_gray_hi, s:cterm_orange, s:cterm_med_gray_hi, ''], + \ } + +" Insert mode +let s:I1 = [s:gui_med_gray_hi, s:gui_blue, s:cterm_med_gray_hi, s:cterm_blue] +let s:I3 = [s:gui_blue, s:gui_med_gray_hi, s:cterm_blue, s:cterm_med_gray_hi] +let g:airline#themes#bubblegum#palette.insert = airline#themes#generate_color_map(s:I1, s:N2, s:I3) +let g:airline#themes#bubblegum#palette.insert_modified = copy(g:airline#themes#bubblegum#palette.normal_modified) +let g:airline#themes#bubblegum#palette.insert_paste = { + \ 'airline_a': [s:gui_dark_gray, s:gui_orange, s:cterm_dark_gray, s:cterm_orange, ''], + \ } + +" Replace mode +let g:airline#themes#bubblegum#palette.replace = { + \ 'airline_a': [s:gui_dark_gray, s:gui_red, s:cterm_dark_gray, s:cterm_red, ''], + \ 'airline_c': [s:gui_red, s:gui_med_gray_hi, s:cterm_red, s:cterm_med_gray_hi, ''], + \ } +let g:airline#themes#bubblegum#palette.replace_modified = copy(g:airline#themes#bubblegum#palette.insert_modified) + +" Visual mode +let s:V1 = [s:gui_dark_gray, s:gui_pink, s:cterm_dark_gray, s:cterm_pink] +let s:V3 = [s:gui_pink, s:gui_med_gray_hi, s:cterm_pink, s:cterm_med_gray_hi] +let g:airline#themes#bubblegum#palette.visual = airline#themes#generate_color_map(s:V1, s:N2, s:V3) +let g:airline#themes#bubblegum#palette.visual_modified = copy(g:airline#themes#bubblegum#palette.insert_modified) + +" Inactive window +let s:IA = [s:gui_light_gray, s:gui_med_gray_hi, s:cterm_light_gray, s:cterm_med_gray_hi, ''] +let g:airline#themes#bubblegum#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) +let g:airline#themes#bubblegum#palette.inactive_modified = { + \ 'airline_c': [s:gui_orange, '', s:cterm_orange, '', ''], + \ } + +" CtrlP +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#bubblegum#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ s:gui_orange, s:gui_med_gray_hi, s:cterm_orange, s:cterm_med_gray_hi, '' ] , + \ [ s:gui_orange, s:gui_med_gray_lo, s:cterm_orange, s:cterm_med_gray_lo, '' ] , + \ [ s:gui_dark_gray, s:gui_green, s:cterm_dark_gray, s:cterm_green, 'bold' ] ) diff --git a/.vim/autoload/airline/themes/dark.vim b/.vim/autoload/airline/themes/dark.vim new file mode 100644 index 0000000..217b2f1 --- /dev/null +++ b/.vim/autoload/airline/themes/dark.vim @@ -0,0 +1,102 @@ +" Each theme is contained in its own file and declares variables scoped to the +" file. These variables represent the possible "modes" that airline can +" detect. The mode is the return value of mode(), which gets converted to a +" readable string. The following is a list currently supported modes: normal, +" insert, replace, visual, and inactive. +" +" Each mode can also have overrides. These are small changes to the mode that +" don't require a completely different look. "modified" and "paste" are two +" such supported overrides. These are simply suffixed to the major mode, +" separated by an underscore. For example, "normal_modified" would be normal +" mode where the current buffer is modified. +" +" The theming algorithm is a 2-pass system where the mode will draw over all +" parts of the statusline, and then the override is applied after. This means +" it is possible to specify a subset of the theme in overrides, as it will +" simply overwrite the previous colors. If you want simultaneous overrides, +" then they will need to change different parts of the statusline so they do +" not conflict with each other. +" +" First, let's define an empty dictionary and assign it to the "palette" +" variable. The # is a separator that maps with the directory structure. If +" you get this wrong, Vim will complain loudly. +let g:airline#themes#dark#palette = {} + +" First let's define some arrays. The s: is just a VimL thing for scoping the +" variables to the current script. Without this, these variables would be +" declared globally. Now let's declare some colors for normal mode and add it +" to the dictionary. The array is in the format: +" [ guifg, guibg, ctermfg, ctermbg, opts ]. See "help attr-list" for valid +" values for the "opt" value. +let s:N1 = [ '#00005f' , '#dfff00' , 17 , 190 ] +let s:N2 = [ '#ffffff' , '#444444' , 255 , 238 ] +let s:N3 = [ '#9cffd3' , '#202020' , 85 , 234 ] +let g:airline#themes#dark#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + +" Here we define overrides for when the buffer is modified. This will be +" applied after g:airline#themes#dark#palette.normal, hence why only certain keys are +" declared. +let g:airline#themes#dark#palette.normal_modified = { + \ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , + \ } + + +let s:I1 = [ '#00005f' , '#00dfff' , 17 , 45 ] +let s:I2 = [ '#ffffff' , '#005fff' , 255 , 27 ] +let s:I3 = [ '#ffffff' , '#000080' , 15 , 17 ] +let g:airline#themes#dark#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#dark#palette.insert_modified = { + \ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , + \ } +let g:airline#themes#dark#palette.insert_paste = { + \ 'airline_a': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] , + \ } + + +let g:airline#themes#dark#palette.replace = copy(g:airline#themes#dark#palette.insert) +let g:airline#themes#dark#palette.replace.airline_a = [ s:I2[0] , '#af0000' , s:I2[2] , 124 , '' ] +let g:airline#themes#dark#palette.replace_modified = g:airline#themes#dark#palette.insert_modified + + +let s:V1 = [ '#000000' , '#ffaf00' , 232 , 214 ] +let s:V2 = [ '#000000' , '#ff5f00' , 232 , 202 ] +let s:V3 = [ '#ffffff' , '#5f0000' , 15 , 52 ] +let g:airline#themes#dark#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#dark#palette.visual_modified = { + \ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , + \ } + + +let s:IA1 = [ '#4e4e4e' , '#1c1c1c' , 239 , 234 , '' ] +let s:IA2 = [ '#4e4e4e' , '#262626' , 239 , 235 , '' ] +let s:IA3 = [ '#4e4e4e' , '#303030' , 239 , 236 , '' ] +let g:airline#themes#dark#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3) +let g:airline#themes#dark#palette.inactive_modified = { + \ 'airline_c': [ '#875faf' , '' , 97 , '' , '' ] , + \ } + + +" Accents are used to give parts within a section a slightly different look or +" color. Here we are defining a "red" accent, which is used by the 'readonly' +" part by default. Only the foreground colors are specified, so the background +" colors are automatically extracted from the underlying section colors. What +" this means is that regardless of which section the part is defined in, it +" will be red instead of the section's foreground color. You can also have +" multiple parts with accents within a section. +let g:airline#themes#dark#palette.accents = { + \ 'red': [ '#ff0000' , '' , 160 , '' ] + \ } + + +" Here we define the color map for ctrlp. We check for the g:loaded_ctrlp +" variable so that related functionality is loaded iff the user is using +" ctrlp. Note that this is optional, and if you do not define ctrlp colors +" they will be chosen automatically from the existing palette. +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#dark#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ '#d7d7ff' , '#5f00af' , 189 , 55 , '' ], + \ [ '#ffffff' , '#875fd7' , 231 , 98 , '' ], + \ [ '#5f00af' , '#ffffff' , 55 , 231 , 'bold' ]) + diff --git a/.vim/autoload/airline/themes/durant.vim b/.vim/autoload/airline/themes/durant.vim new file mode 100644 index 0000000..56be7ba --- /dev/null +++ b/.vim/autoload/airline/themes/durant.vim @@ -0,0 +1,59 @@ +let s:N1 = [ '#005f00' , '#afd700' , 22 , 148 ] +let s:N2 = [ '#93a1a1' , '#586e75' , 245 , 240 ] +let s:N3 = [ '#93a1a1' , '#073642' , 240 , 233 ] +let g:airline#themes#durant#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + + +let g:airline#themes#durant#normal_modified = { + \ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , + \ } + + + +let s:I1 = [ '#ffffff' , '#00875f' , 255 , 29 ] +let s:I2 = [ '#9e9e9e' , '#303030' , 247 , 236 ] +let s:I3 = [ '#87d7ff' , '#005f87' , 117 , 24 ] +let g:airline#themes#durant#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#durant#palette.insert_modified = { + \ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , + \ } +let g:airline#themes#durant#palette.insert_paste = { + \ 'airline_a': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] , + \ } + + +let g:airline#themes#durant#palette.replace = copy(g:airline#themes#durant#palette.insert) +let g:airline#themes#durant#palette.replace.airline_a = [ s:I2[0] , '#af0000' , s:I2[2] , 124 , '' ] + +let g:airline#themes#durant#palette.replace_modified = g:airline#themes#durant#palette.insert_modified + +let s:V1 = [ '#1a1a18' , '#ffffff' , 232 , 255 ] +let s:V2 = [ '#ffffff' , '#44403a' , 255, 238 ] +let s:V3 = [ '#90a680' , '#2e2d2a' , 64, 235 ] +let g:airline#themes#durant#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#durant#palette.visual_modified = { + \ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , + \ } + + +let s:IA1 = [ '#4e4e4e' , '#1c1c1c' , 239 , 234 , '' ] +let s:IA2 = [ '#4e4e4e' , '#262626' , 239 , 235 , '' ] +let s:IA3 = [ '#4e4e4e' , '#303030' , 239 , 236 , '' ] +let g:airline#themes#durant#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3) +let g:airline#themes#durant#palette.inactive_modified = { + \ 'airline_c': [ '#875faf' , '' , 97 , '' , '' ] , + \ } + + +let g:airline#themes#durant#palette.accents = { + \ 'red': [ '#ff0000' , '' , 160 , '' ] + \ } + +if !get(g:, 'loaded_ctrlp', 0) + finish +endif + let g:airline#themes#durant#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ '#d7d7ff' , '#5f00af' , 189 , 55 , '' ], + \ [ '#ffffff' , '#875fd7' , 231 , 98 , '' ], + \ [ '#5f00af' , '#ffffff' , 55 , 231 , 'bold' ]) + diff --git a/.vim/autoload/airline/themes/hybrid.vim b/.vim/autoload/airline/themes/hybrid.vim new file mode 100644 index 0000000..b0df844 --- /dev/null +++ b/.vim/autoload/airline/themes/hybrid.vim @@ -0,0 +1,58 @@ +" vim-airline companion theme of Hybrid +" (https://github.com/w0ng/vim-hybrid) + +let g:airline#themes#hybrid#palette = {} + +function! airline#themes#hybrid#refresh() + let s:N1 = airline#themes#get_highlight('DiffAdd') + let s:N2 = airline#themes#get_highlight('CursorLine') + let s:N3 = airline#themes#get_highlight('PMenu') + let g:airline#themes#hybrid#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + + let modified_group = airline#themes#get_highlight2(['Text', 'fg'], ['SpellRare', 'bg'], 'bold') + let g:airline#themes#hybrid#palette.normal_modified = { + \ 'airline_c': airline#themes#get_highlight2(['Text', 'fg'], ['SpellRare', 'bg'], 'bold') + \ } + + let warning_group = airline#themes#get_highlight('SpellRare') + let g:airline#themes#hybrid#palette.normal.airline_warning = warning_group + let g:airline#themes#hybrid#palette.normal_modified.airline_warning = warning_group + + let s:I1 = airline#themes#get_highlight2(['Text', 'fg'], ['DiffText', 'bg'], 'bold') + let s:I2 = airline#themes#get_highlight2(['Text', 'fg'], ['SpellLocal', 'bg'], 'bold') + let s:I3 = airline#themes#get_highlight2(['Text', 'fg'], ['SpellCap', 'bg'], 'bold') + let g:airline#themes#hybrid#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) + let g:airline#themes#hybrid#palette.insert_modified = g:airline#themes#hybrid#palette.normal_modified + let g:airline#themes#hybrid#palette.insert.airline_warning = g:airline#themes#hybrid#palette.normal.airline_warning + let g:airline#themes#hybrid#palette.insert_modified.airline_warning = g:airline#themes#hybrid#palette.normal_modified.airline_warning + + let s:R1 = airline#themes#get_highlight('DiffChange') + let s:R2 = s:N2 + let s:R3 = s:N3 + let g:airline#themes#hybrid#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) + let replace_group = airline#themes#get_highlight('SpellRare') + let g:airline#themes#hybrid#palette.replace_modified = g:airline#themes#hybrid#palette.normal_modified + let g:airline#themes#hybrid#palette.replace.airline_warning = g:airline#themes#hybrid#palette.normal.airline_warning + let g:airline#themes#hybrid#palette.replace_modified.airline_warning = g:airline#themes#hybrid#palette.replace_modified.airline_warning + + let s:V1 = airline#themes#get_highlight2(['Text', 'fg'], ['Folded', 'bg'], 'bold') + let s:V2 = airline#themes#get_highlight2(['Text', 'fg'], ['DiffDelete', 'bg'], 'bold') + let s:V3 = airline#themes#get_highlight2(['Text', 'fg'], ['Error', 'bg'], 'bold') + let g:airline#themes#hybrid#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) + let g:airline#themes#hybrid#palette.visual_modified = g:airline#themes#hybrid#palette.normal_modified + let g:airline#themes#hybrid#palette.visual.airline_warning = g:airline#themes#hybrid#palette.normal.airline_warning + let g:airline#themes#hybrid#palette.visual_modified.airline_warning = g:airline#themes#hybrid#palette.normal_modified.airline_warning + + let s:IA = airline#themes#get_highlight('StatusLineNC') + let g:airline#themes#hybrid#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) + let g:airline#themes#hybrid#palette.inactive_modified = { + \ 'airline_c': [ modified_group[0], '', modified_group[2], '', '' ] + \ } + + let g:airline#themes#hybrid#palette.accents = { + \ 'red': airline#themes#get_highlight('Constant'), + \ } + +endfunction + +call airline#themes#hybrid#refresh() diff --git a/.vim/autoload/airline/themes/jellybeans.vim b/.vim/autoload/airline/themes/jellybeans.vim new file mode 100644 index 0000000..201068c --- /dev/null +++ b/.vim/autoload/airline/themes/jellybeans.vim @@ -0,0 +1,52 @@ +let g:airline#themes#jellybeans#palette = {} + +" The name of the function must be 'refresh'. +function! airline#themes#jellybeans#refresh() + " This theme is an example of how to use helper functions to extract highlight + " values from the corresponding colorscheme. It was written in a hurry, so it + " is very minimalistic. If you are a jellybeans user and want to make updates, + " please send pull requests. + + " Here are examples where the entire highlight group is copied and an airline + " compatible color array is generated. + let s:N1 = airline#themes#get_highlight('DbgCurrent', 'bold') + let s:N2 = airline#themes#get_highlight('Folded') + let s:N3 = airline#themes#get_highlight('NonText') + + let g:airline#themes#jellybeans#palette.accents = { + \ 'red': airline#themes#get_highlight('Constant'), + \ } + + let g:airline#themes#jellybeans#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + let g:airline#themes#jellybeans#palette.normal_modified = { + \ 'airline_c': [ '#ffb964', '', 215, '', '' ] + \ } + + let s:I1 = airline#themes#get_highlight('DiffAdd', 'bold') + let s:I2 = s:N2 + let s:I3 = s:N3 + let g:airline#themes#jellybeans#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) + let g:airline#themes#jellybeans#palette.insert_modified = g:airline#themes#jellybeans#palette.normal_modified + + let s:R1 = airline#themes#get_highlight('WildMenu', 'bold') + let s:R2 = s:N2 + let s:R3 = s:N3 + let g:airline#themes#jellybeans#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) + let g:airline#themes#jellybeans#palette.replace_modified = g:airline#themes#jellybeans#palette.normal_modified + + " Sometimes you want to mix and match colors from different groups, you can do + " that with this method. + let s:V1 = airline#themes#get_highlight2(['TabLineSel', 'bg'], ['DiffDelete', 'bg'], 'bold') + let s:V2 = s:N2 + let s:V3 = s:N3 + let g:airline#themes#jellybeans#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) + let g:airline#themes#jellybeans#palette.visual_modified = g:airline#themes#jellybeans#palette.normal_modified + + " And of course, you can always do it manually as well. + let s:IA = [ '#444444', '#1c1c1c', 237, 234 ] + let g:airline#themes#jellybeans#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) + let g:airline#themes#jellybeans#palette.inactive_modified = g:airline#themes#jellybeans#palette.normal_modified +endfunction + +call airline#themes#jellybeans#refresh() + diff --git a/.vim/autoload/airline/themes/kalisi.vim b/.vim/autoload/airline/themes/kalisi.vim new file mode 100644 index 0000000..78504fa --- /dev/null +++ b/.vim/autoload/airline/themes/kalisi.vim @@ -0,0 +1,70 @@ +" +" Colorscheme: Kalisi for airline. Inspired by powerline. +" Arthur Jaron +" hifreeo@gmail.com +" 24.10.2014 + +" Visual mode +let s:V1 = [ '#0087ff' , '#ffffff','33','231'] +let s:V2 = [ '#005faf' , '#5fafff','25','75'] +let s:V3 = [ '#87d7ff' , '#005faf','117','25'] + +" Replace mode +let s:R1 = [ '#d75fff' , '#ffffff','171','231'] +let s:R2 = [ '#5f005f' , '#d75fff','53','171'] +let s:R3 = [ '#ff87ff' , '#8700af','213','91'] + +let g:airline#themes#kalisi#palette = {} + + +function! airline#themes#kalisi#refresh() + + let s:StatusLine = airline#themes#get_highlight('StatusLine') + let s:StatusLineNC = airline#themes#get_highlight('StatusLineNC') + + " Insert mode + let s:I1 = [ '#ffffff' , '#e80000','231','160'] + let s:I2 = [ '#ff0000' , '#5f0000','196','52'] + let s:I3 = s:StatusLine + + " Normal mode + let s:N1 = [ '#005f00' , '#afd700','22','148'] + let s:N2 = [ '#afd700' , '#005f00','148','22'] + let s:N3 = s:StatusLine + + " Tabline Plugin + let g:airline#themes#kalisi#palette.tabline = { + \ 'airline_tab': ['#bcbcbc', '#005f00','250','22'], + \ 'airline_tabsel': ['#404042', '#A6DB29','238','148'], + \ 'airline_tabtype':['#afd700', '#204d20','148','22'], + \ 'airline_tabfill': s:StatusLine, + \ 'airline_tabhid': ['#c5c5c5', '#404042','251','238'], + \ 'airline_tabmod': ['#d7ff00', '#afd700','190','148'], + \ 'airline_tabmod_unsel': ['#d7ff00', '#005f00','190','22'] + \ } + + let g:airline#themes#kalisi#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + let g:airline#themes#kalisi#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) + let g:airline#themes#kalisi#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) + let g:airline#themes#kalisi#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) + + " Inactive Mode + let s:IA = airline#themes#get_highlight('StatusLineNC') + let g:airline#themes#kalisi#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) + let g:airline#themes#kalisi#palette.inactive_modified = { + \ 'airline_c': ['#d7ff00', s:IA[1],'190',s:IA[3]], + \ } + +endfunction + +call airline#themes#kalisi#refresh() + +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#kalisi#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ s:StatusLine, + \ ['#afd700', '#005f00','148','22'], + \ [ '#005f00' , '#afd700' , '22','148'] + \) + diff --git a/.vim/autoload/airline/themes/kolor.vim b/.vim/autoload/airline/themes/kolor.vim new file mode 100644 index 0000000..e61f56f --- /dev/null +++ b/.vim/autoload/airline/themes/kolor.vim @@ -0,0 +1,59 @@ +let g:airline#themes#kolor#palette = {} + +let s:N1 = [ '#e2e2e2' , '#4f3598' , 254 , 56 ] +let s:N2 = [ '#ff5fd7' , '#242322' , 206 , 234 ] +let s:N3 = [ '#e2e2e2' , '#4a4a4a' , 254 , 238 ] + +let g:airline#themes#kolor#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + +let g:airline#themes#kolor#palette.normal_modified = { + \ 'airline_c': [ '#e2e2e2' , '#4f3598' , 254 , 56 , '' ] , + \ } + + +let s:I1 = [ '#242322' , '#7eaefd' , 234 , 111 ] +let s:I2 = [ '#75d7d8' , '#242322' , 80 , 234 ] +let s:I3 = [ '#e2e2e2' , '#4a4a4a' , 254 , 238 ] +let g:airline#themes#kolor#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#kolor#palette.insert_modified = { + \ 'airline_c': [ '#242322' , '#7eaefd' , 234 , 111 , '' ] , + \ } + + +let g:airline#themes#kolor#palette.replace = copy(g:airline#themes#kolor#palette.insert) +let g:airline#themes#kolor#palette.replace.airline_a = [ s:I2[0] , '#005154' , s:I2[2] , 23 , '' ] +let g:airline#themes#kolor#palette.replace_modified = { + \ 'airline_c': [ '#e2e2e2' , '#005154' , 254 , 23 , '' ] , + \ } + + +let s:V1 = [ '#242322' , '#e6987a' , 234 , 180 ] +let s:V2 = [ '#dbc570' , '#242322' , 186 , 234 ] +let s:V3 = [ '#e2e2e2' , '#4a4a4a' , 254 , 238 ] +let g:airline#themes#kolor#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#kolor#palette.visual_modified = { + \ 'airline_c': [ '#242322' , '#e6987a' , 234 , 180 , '' ] , + \ } + + +let s:IA1 = [ '#b2b2b2' , '#4a4a4a' , 247 , 238 , '' ] +let s:IA2 = [ '#b2b2b2' , '#4a4a4a' , 247 , 238 ] +let s:IA3 = [ '#b2b2b2' , '#4a4a4a' , 247 , 238 , '' ] +let g:airline#themes#kolor#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3) +let g:airline#themes#kolor#palette.inactive_modified = { + \ 'airline_c': [ '#875faf' , '' , 97 , '' , '' ] , + \ } + + +let g:airline#themes#kolor#palette.accents = { + \ 'red': [ '#d96e8a' , '' , 168 , '' ] + \ } + + +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#kolor#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ '#e2e2e2' , '#4a4a4a' , 254 , 238 , '' ], + \ [ '#e2e2e2' , '#242322' , 254 , 234 , '' ], + \ [ '#e2e2e2' , '#4f3598' , 254 , 56 , 'bold' ]) diff --git a/.vim/autoload/airline/themes/laederon.vim b/.vim/autoload/airline/themes/laederon.vim new file mode 100644 index 0000000..115c107 --- /dev/null +++ b/.vim/autoload/airline/themes/laederon.vim @@ -0,0 +1,62 @@ +" vim-airline companion theme of Laederon +" (https://github.com/Donearm/Laederon) + +" Normal mode +let s:N1 = [ '#1a1a18' , '#ffffff' , 232 , 255 ] " blackestgravel & snow +let s:N2 = [ '#ffffff' , '#44403a' , 255, 238 ] " snow & deepgravel +let s:N3 = [ '#90a680' , '#2e2d2a' , 64, 235 ] " dilutedpaint & darkgravel +let s:N4 = [ '#777470' , 240 ] " gravel + +" Insert mode +let s:I1 = [ '#1a1a18' , '#1693a5' , 232 , 62 ] " blackestgravel & crystallake +let s:I2 = [ '#515744' , '#44403a' , 101 , 238 ] " lichen & deepgravel +let s:I3 = [ '#1693a5' , '#2e2d2a' , 39 , 235 ] " crystallake & darkgravel + +" Visual mode +let s:V1 = [ '#1a1a18' , '#ab3e5d' , 232 , 161 ] " blackestgravel & raspberry +let s:V2 = [ '#000000' , '#908571' , 16 , 252 ] " coal & winterterrain +let s:V3 = [ '#ab3e5d' , '#8c7f77' , 161 , 245 ] " raspberry & wetcoldterrain +let s:V4 = [ '#515744' , 101 ] " lichen + +" Replace mode +let s:RE = [ '#233e09' , 22 ] " oakleaf + +" Paste mode +let s:PA = [ '#ab3e5d' , 161 ] " raspberry + +let s:IA = [ s:N2[1] , s:N3[1] , s:N2[3], s:N3[3] , '' ] + + +let g:airline#themes#laederon#palette = {} + +let g:airline#themes#laederon#palette.accents = { + \ 'red': [ '#ef393d' , '' , 196 , '' , '' ] + \ } + +let g:airline#themes#laederon#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#laederon#palette.normal_modified = { + \ 'airline_a' : [ s:N2[0] , s:N4[0] , s:N2[2] , s:N4[1] , '' ] , + \ 'airline_c' : [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } + + +let g:airline#themes#laederon#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#laederon#palette.insert_modified = { + \ 'airline_c' : [ s:V2[1] , s:N2[1] , s:V2[3] , s:N2[3] , '' ] } +let g:airline#themes#laederon#palette.insert_paste = { + \ 'airline_a' : [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] } + + +let g:airline#themes#laederon#palette.replace = copy(airline#themes#laederon#palette.insert) +let g:airline#themes#laederon#palette.replace.airline_a = [ s:I1[0] , s:RE[0] , s:I1[2] , s:RE[1] , '' ] +let g:airline#themes#laederon#palette.replace_modified = g:airline#themes#laederon#palette.insert_modified + + +let g:airline#themes#laederon#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#laederon#palette.visual_modified = { + \ 'airline_c' : [ s:V3[0] , s:V4[0] , s:V3[2] , s:V4[1] , '' ] } + + +let g:airline#themes#laederon#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) +let g:airline#themes#laederon#palette.inactive_modified = { + \ 'airline_c' : [ s:V1[1] , '' , s:V1[3] , '' , '' ] } + diff --git a/.vim/autoload/airline/themes/light.vim b/.vim/autoload/airline/themes/light.vim new file mode 100644 index 0000000..d9fe844 --- /dev/null +++ b/.vim/autoload/airline/themes/light.vim @@ -0,0 +1,45 @@ +let g:airline#themes#light#palette = {} + +let s:N1 = [ '#ffffff' , '#005fff' , 255 , 27 ] +let s:N2 = [ '#000087' , '#00dfff' , 18 , 45 ] +let s:N3 = [ '#005fff' , '#afffff' , 27 , 159 ] +let g:airline#themes#light#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#light#palette.normal_modified = { + \ 'airline_c': [ '#df0000' , '#ffdfdf' , 160 , 224 , '' ] , + \ } + + +let s:I1 = [ '#ffffff' , '#00875f' , 255 , 29 ] +let s:I2 = [ '#005f00' , '#00df87' , 22 , 42 ] +let s:I3 = [ '#005f5f' , '#afff87' , 23 , 156 ] +let g:airline#themes#light#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#light#palette.insert_modified = { + \ 'airline_c': [ '#df0000' , '#ffdfdf' , 160 , 224 , '' ] , + \ } +let g:airline#themes#light#palette.insert_paste = { + \ 'airline_a': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] , + \ } + + +let g:airline#themes#light#palette.replace = copy(g:airline#themes#light#palette.insert) +let g:airline#themes#light#palette.replace.airline_a = [ s:I2[0] , '#ff0000' , s:I1[2] , 196 , '' ] +let g:airline#themes#light#palette.replace_modified = g:airline#themes#light#palette.insert_modified + + +let s:V1 = [ '#ffffff' , '#ff5f00' , 255 , 202 ] +let s:V2 = [ '#5f0000' , '#ffaf00' , 52 , 214 ] +let s:V3 = [ '#df5f00' , '#ffff87' , 166 , 228 ] +let g:airline#themes#light#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#light#palette.visual_modified = { + \ 'airline_c': [ '#df0000' , '#ffdfdf' , 160 , 224 , '' ] , + \ } + + +let s:IA1 = [ '#666666' , '#b2b2b2' , 242 , 249 , '' ] +let s:IA2 = [ '#8a8a8a' , '#d0d0d0' , 245 , 252 , '' ] +let s:IA3 = [ '#a8a8a8' , '#ffffff' , 248 , 255 , '' ] +let g:airline#themes#light#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3) +let g:airline#themes#light#palette.inactive_modified = { + \ 'airline_c': [ '#df0000' , '' , 160 , '' , '' ] , + \ } + diff --git a/.vim/autoload/airline/themes/lucius.vim b/.vim/autoload/airline/themes/lucius.vim new file mode 100644 index 0000000..e386900 --- /dev/null +++ b/.vim/autoload/airline/themes/lucius.vim @@ -0,0 +1,56 @@ +let g:airline#themes#lucius#palette = {} + +function! airline#themes#lucius#refresh() + + let s:N1 = airline#themes#get_highlight('StatusLine') + let s:N2 = airline#themes#get_highlight('Folded') + let s:N3 = airline#themes#get_highlight('CursorLine') + let g:airline#themes#lucius#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + + let modified_group = airline#themes#get_highlight('Statement') + let g:airline#themes#lucius#palette.normal_modified = { + \ 'airline_c': [modified_group[0], '', modified_group[2], '', ''] + \ } + + let warning_group = airline#themes#get_highlight('DiffDelete') + let g:airline#themes#lucius#palette.normal.airline_warning = warning_group + let g:airline#themes#lucius#palette.normal_modified.airline_warning = warning_group + + let s:I1 = airline#themes#get_highlight('DiffAdd') + let s:I2 = s:N2 + let s:I3 = s:N3 + let g:airline#themes#lucius#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) + let g:airline#themes#lucius#palette.insert_modified = g:airline#themes#lucius#palette.normal_modified + let g:airline#themes#lucius#palette.insert.airline_warning = g:airline#themes#lucius#palette.normal.airline_warning + let g:airline#themes#lucius#palette.insert_modified.airline_warning = g:airline#themes#lucius#palette.normal_modified.airline_warning + + let s:R1 = airline#themes#get_highlight('DiffChange') + let s:R2 = s:N2 + let s:R3 = s:N3 + let g:airline#themes#lucius#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) + let g:airline#themes#lucius#palette.replace_modified = g:airline#themes#lucius#palette.normal_modified + let g:airline#themes#lucius#palette.replace.airline_warning = g:airline#themes#lucius#palette.normal.airline_warning + let g:airline#themes#lucius#palette.replace_modified.airline_warning = g:airline#themes#lucius#palette.normal_modified.airline_warning + + let s:V1 = airline#themes#get_highlight('Cursor') + let s:V2 = s:N2 + let s:V3 = s:N3 + let g:airline#themes#lucius#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) + let g:airline#themes#lucius#palette.visual_modified = g:airline#themes#lucius#palette.normal_modified + let g:airline#themes#lucius#palette.visual.airline_warning = g:airline#themes#lucius#palette.normal.airline_warning + let g:airline#themes#lucius#palette.visual_modified.airline_warning = g:airline#themes#lucius#palette.normal_modified.airline_warning + + let s:IA = airline#themes#get_highlight('StatusLineNC') + let g:airline#themes#lucius#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) + let g:airline#themes#lucius#palette.inactive_modified = { + \ 'airline_c': [ modified_group[0], '', modified_group[2], '', '' ] + \ } + + let g:airline#themes#lucius#palette.accents = { + \ 'red': airline#themes#get_highlight('Constant'), + \ } + +endfunction + +call airline#themes#lucius#refresh() + diff --git a/.vim/autoload/airline/themes/luna.vim b/.vim/autoload/airline/themes/luna.vim new file mode 100644 index 0000000..879d862 --- /dev/null +++ b/.vim/autoload/airline/themes/luna.vim @@ -0,0 +1,92 @@ +" vim-airline companion theme of Luna +" (https://github.com/Pychimp/vim-luna) + +let g:airline#themes#luna#palette = {} + +let g:airline#themes#luna#palette.accents = { + \ 'red': [ '#ffffff' , '' , 231 , '' , '' ], + \ } + + +let s:N1 = [ '#ffffff' , '#005252' , 231 , 36 ] +let s:N2 = [ '#ffffff' , '#003f3f' , 231 , 29 ] +let s:N3 = [ '#ffffff' , '#002b2b' , 231 , 23 ] +let g:airline#themes#luna#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#luna#palette.normal_modified = { + \ 'airline_c': [ '#ffffff' , '#450000' , 231 , 52 , '' ] , + \ } + + +let s:I1 = [ '#ffffff' , '#789f00' , 231 , 106 ] +let s:I2 = [ '#ffffff' , '#003f3f' , 231 , 29 ] +let s:I3 = [ '#ffffff' , '#002b2b' , 231 , 23 ] +let g:airline#themes#luna#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#luna#palette.insert_modified = { + \ 'airline_c': [ '#ffffff' , '#005e5e' , 255 , 52 , '' ] , + \ } +let g:airline#themes#luna#palette.insert_paste = { + \ 'airline_a': [ s:I1[0] , '#789f00' , s:I1[2] , 106 , '' ] , + \ } + + +let g:airline#themes#luna#palette.replace = copy(g:airline#themes#luna#palette.insert) +let g:airline#themes#luna#palette.replace.airline_a = [ s:I2[0] , '#920000' , s:I2[2] , 88 , '' ] +let g:airline#themes#luna#palette.replace_modified = g:airline#themes#luna#palette.insert_modified + +let s:V1 = [ '#ffff9a' , '#ff8036' , 222 , 208 ] +let s:V2 = [ '#ffffff' , '#003f3f' , 231 , 29 ] +let s:V3 = [ '#ffffff' , '#002b2b' , 231 , 23 ] +let g:airline#themes#luna#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#luna#palette.visual_modified = { + \ 'airline_c': [ '#ffffff' , '#450000' , 231 , 52 , '' ] , + \ } + +let s:IA = [ '#4e4e4e' , '#002b2b' , 59 , 23 , '' ] +let g:airline#themes#luna#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) +let g:airline#themes#luna#palette.inactive_modified = { + \ 'airline_c': [ '#e20000' , '' , 166 , '' , '' ] , + \ } + +let g:airline#themes#luna#palette.tabline = { + \ 'airline_tab': ['#2aa198', '#003f3f', 231, 29, ''], + \ 'airline_tabsel': ['#ffffff', '#2e8b57', 231, 36, ''], + \ 'airline_tabtype': ['#ffffff', '#005252', 231, 36, ''], + \ 'airline_tabfill': ['#ffffff', '#002b2b', 231, 23, ''], + \ 'airline_tabmod': ['#ffffff', '#780000', 231, 88, ''], + \ } + +let s:WI = [ '#ffffff', '#5f0000', 231, 88 ] +let g:airline#themes#luna#palette.normal.airline_warning = [ + \ s:WI[0], s:WI[1], s:WI[2], s:WI[3] + \ ] + +let g:airline#themes#luna#palette.normal_modified.airline_warning = + \ g:airline#themes#luna#palette.normal.airline_warning + +let g:airline#themes#luna#palette.insert.airline_warning = + \ g:airline#themes#luna#palette.normal.airline_warning + +let g:airline#themes#luna#palette.insert_modified.airline_warning = + \ g:airline#themes#luna#palette.normal.airline_warning + +let g:airline#themes#luna#palette.visual.airline_warning = + \ g:airline#themes#luna#palette.normal.airline_warning + +let g:airline#themes#luna#palette.visual_modified.airline_warning = + \ g:airline#themes#luna#palette.normal.airline_warning + +let g:airline#themes#luna#palette.replace.airline_warning = + \ g:airline#themes#luna#palette.normal.airline_warning + +let g:airline#themes#luna#palette.replace_modified.airline_warning = + \ g:airline#themes#luna#palette.normal.airline_warning + + +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#luna#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ '#ffffff' , '#002b2b' , 231 , 23 , '' ] , + \ [ '#ffffff' , '#005252' , 231 , 36 , '' ] , + \ [ '#ffffff' , '#973d45' , 231 , 95 , '' ] ) + diff --git a/.vim/autoload/airline/themes/molokai.vim b/.vim/autoload/airline/themes/molokai.vim new file mode 100644 index 0000000..1998f00 --- /dev/null +++ b/.vim/autoload/airline/themes/molokai.vim @@ -0,0 +1,65 @@ +let g:airline#themes#molokai#palette = {} + +let g:airline#themes#molokai#palette.accents = { + \ 'red': [ '#66d9ef' , '' , 81 , '' , '' ], + \ } + + +" Normal mode +let s:N1 = [ '#080808' , '#e6db74' , 232 , 144 ] " mode +let s:N2 = [ '#f8f8f0' , '#232526' , 253 , 16 ] " info +let s:N3 = [ '#f8f8f0' , '#465457' , 253 , 67 ] " statusline + +let g:airline#themes#molokai#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#molokai#palette.normal_modified = { + \ 'airline_c': [ '#080808' , '#e6db74' , 232 , 144 , '' ] , + \ } + + +" Insert mode +let s:I1 = [ '#080808' , '#66d9ef' , 232 , 81 ] +let s:I2 = [ '#f8f8f0' , '#232526' , 253 , 16 ] +let s:I3 = [ '#f8f8f0' , '#465457' , 253 , 67 ] + +let g:airline#themes#molokai#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#molokai#palette.insert_modified = { + \ 'airline_c': [ '#080808' , '#66d9ef' , 232 , 81 , '' ] , + \ } + + +" Replace mode +let g:airline#themes#molokai#palette.replace = copy(g:airline#themes#molokai#palette.insert) +let g:airline#themes#molokai#palette.replace.airline_a = [ s:I1[0] , '#ef5939' , s:I1[2] , 166 , '' ] +let g:airline#themes#molokai#palette.replace_modified = { + \ 'airline_c': [ '#080808' , '#ef5939' , 232 , 166 , '' ] , + \ } + + +" Visual mode +let s:V1 = [ '#080808' , '#fd971f' , 232 , 208 ] +let s:V2 = [ '#f8f8f0' , '#232526' , 253 , 16 ] +let s:V3 = [ '#f8f8f0' , '#465457' , 253 , 67 ] + +let g:airline#themes#molokai#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#molokai#palette.visual_modified = { + \ 'airline_c': [ '#080808' , '#fd971f' , 232 , 208 , '' ] , + \ } + + +" Inactive +let s:IA = [ '#1b1d1e' , '#465457' , 233 , 67 , '' ] +let g:airline#themes#molokai#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) +let g:airline#themes#molokai#palette.inactive_modified = { + \ 'airline_c': [ '#f8f8f0' , '' , 253 , '' , '' ] , + \ } + + +" CtrlP +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#molokai#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ '#f8f8f0' , '#465457' , 253 , 67 , '' ] , + \ [ '#f8f8f0' , '#232526' , 253 , 16 , '' ] , + \ [ '#080808' , '#e6db74' , 232 , 144 , 'bold' ] ) + diff --git a/.vim/autoload/airline/themes/monochrome.vim b/.vim/autoload/airline/themes/monochrome.vim new file mode 100644 index 0000000..7dd1a17 --- /dev/null +++ b/.vim/autoload/airline/themes/monochrome.vim @@ -0,0 +1,15 @@ +let g:airline#themes#monochrome#palette = {} + +function! airline#themes#monochrome#refresh() + let s:SL = airline#themes#get_highlight('StatusLine') + let g:airline#themes#monochrome#palette.normal = airline#themes#generate_color_map(s:SL, s:SL, s:SL) + let g:airline#themes#monochrome#palette.insert = g:airline#themes#monochrome#palette.normal + let g:airline#themes#monochrome#palette.replace = g:airline#themes#monochrome#palette.normal + let g:airline#themes#monochrome#palette.visual = g:airline#themes#monochrome#palette.normal + + let s:SLNC = airline#themes#get_highlight('StatusLineNC') + let g:airline#themes#monochrome#palette.inactive = airline#themes#generate_color_map(s:SLNC, s:SLNC, s:SLNC) +endfunction + +call airline#themes#monochrome#refresh() + diff --git a/.vim/autoload/airline/themes/murmur.vim b/.vim/autoload/airline/themes/murmur.vim new file mode 100644 index 0000000..08e4757 --- /dev/null +++ b/.vim/autoload/airline/themes/murmur.vim @@ -0,0 +1,82 @@ +let g:airline#themes#murmur#palette = {} + +" Color palette +let s:cterm_termbg = 237 " Background for branch and file format blocks +let s:gui_termbg = '#5F5F5F' +let s:cterm_termfg = 144 " Foreground for branch and file format blocks +let s:gui_termfg = '#AFAF87' + +let s:cterm_termbg2 = 234 " Background for middle block +let s:gui_termbg2 = '#1C1C1C' +let s:cterm_termfg2 = 39 " Foreground for middle block +let s:gui_termfg2 = '#F5F5F5' + +let s:cterm_normalbg = 27 " Background for normal mode and file position blocks +let s:gui_normalbg = '#5F87FF' +let s:cterm_normalfg = 15 " Foreground for normal mode and file position blocks +let s:gui_normalfg = '#FFFFFF' + +let s:cterm_insertbg = 70 " Background for insert mode and file position blocks +let s:gui_insertbg = '#87AF5F' +let s:cterm_insertfg = 15 " Foreground for insert mode and file position blocks +let s:gui_insertfg = '#FFFFFF' + +let s:cterm_visualbg = 166 " Background for visual mode and file position blocks +let s:gui_visualbg = '#ff8c00' +let s:cterm_visualfg = 15 " Foreground for visual mode and file position blocks +let s:gui_visualfg = '#FFFFFF' + +let s:cterm_replacebg = 88 " Background for replace mode and file position blocks +let s:gui_replacebg = '#870000' +let s:cterm_replacefg = 15 " Foreground for replace mode and file position blocks +let s:gui_replacefg = '#FFFFFF' + +let s:cterm_alert = 88 " Modified file alert color +let s:gui_alert = '#870000' + +let s:cterm_inactivebg = 234 " Background for inactive mode +let s:gui_inactivebg = '#1C1C1C' +let s:cterm_inactivefg = 239 " Foreground for inactive mode +let s:gui_inactivefg = '#4E4E4E' + +" Branch and file format +let s:BB = [s:gui_termfg, s:gui_termbg, s:cterm_termfg, s:cterm_termbg] " Branch and file format blocks + +" Normal mode +let s:N1 = [s:gui_normalfg, s:gui_normalbg, s:cterm_normalfg, s:cterm_normalbg] " Outside blocks in normal mode +let s:N2 = [s:gui_termfg2, s:gui_termbg2, s:cterm_normalbg, s:cterm_termbg2] " Middle block +let g:airline#themes#murmur#palette.normal = airline#themes#generate_color_map(s:N1, s:BB, s:N2) +let g:airline#themes#murmur#palette.normal_modified = {'airline_c': [s:gui_alert, s:gui_termbg2, s:cterm_alert, s:cterm_termbg2, 'bold'] ,} + +" Insert mode +let s:I1 = [s:gui_insertfg, s:gui_insertbg, s:cterm_insertfg, s:cterm_insertbg] " Outside blocks in insert mode +let s:I2 = [s:gui_insertbg, s:gui_termbg2, s:cterm_insertbg, s:cterm_termbg2] " Middle block +let g:airline#themes#murmur#palette.insert = airline#themes#generate_color_map(s:I1, s:BB, s:I2) +let g:airline#themes#murmur#palette.insert_modified = {'airline_c': [s:gui_alert, s:gui_termbg2, s:cterm_alert, s:cterm_termbg2, 'bold'] ,} + +" Replace mode +let s:R1 = [s:gui_replacefg, s:gui_replacebg, s:cterm_replacefg, s:cterm_replacebg] " Outside blocks in replace mode +let s:R2 = [s:gui_termfg, s:gui_termbg2, s:cterm_termfg, s:cterm_termbg2] " Middle block +let g:airline#themes#murmur#palette.replace = airline#themes#generate_color_map(s:R1, s:BB, s:R2) +let g:airline#themes#murmur#palette.replace_modified = {'airline_c': [s:gui_alert, s:gui_termbg2, s:cterm_alert, s:cterm_termbg2, 'bold'] ,} + +" Visual mode +let s:V1 = [s:gui_visualfg, s:gui_visualbg, s:cterm_visualfg, s:cterm_visualbg] " Outside blocks in visual mode +let s:V2 = [s:gui_visualbg, s:gui_termbg2, s:cterm_visualbg, s:cterm_termbg2] " Middle block +let g:airline#themes#murmur#palette.visual = airline#themes#generate_color_map(s:V1, s:BB, s:V2) +let g:airline#themes#murmur#palette.visual_modified = {'airline_c': [s:gui_alert, s:gui_termbg2, s:cterm_alert, s:cterm_termbg2, 'bold'] ,} + +" Inactive mode +let s:IA1 = [s:gui_inactivefg, s:gui_inactivebg, s:cterm_inactivefg, s:cterm_inactivebg, ''] +let s:IA2 = [s:gui_inactivefg, s:gui_inactivebg, s:cterm_inactivefg, s:cterm_inactivebg, ''] +let s:IA3 = [s:gui_inactivefg, s:gui_inactivebg, s:cterm_inactivefg, s:cterm_inactivebg, ''] +let g:airline#themes#murmur#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3) + +" CtrlP plugin colors +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#murmur#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [s:gui_normalfg, s:gui_normalbg, s:cterm_normalfg, s:cterm_normalbg, ''], + \ [s:gui_termfg, s:gui_termbg, s:cterm_termfg, s:cterm_termbg, ''], + \ [s:gui_termfg2, s:gui_termbg2, s:cterm_termfg2, s:cterm_termbg2, 'bold']) diff --git a/.vim/autoload/airline/themes/powerlineish.vim b/.vim/autoload/airline/themes/powerlineish.vim new file mode 100644 index 0000000..d550e11 --- /dev/null +++ b/.vim/autoload/airline/themes/powerlineish.vim @@ -0,0 +1,46 @@ +" Theme to mimic the default colorscheme of powerline +" Not 100% the same so it's powerline... ish. +" +" Differences from default powerline: +" * Paste indicator isn't colored different +" * Far right hand section matches the color of the mode indicator +" +" Differences from other airline themes: +" * No color differences when you're in a modified buffer +" * Visual mode only changes the mode section. Otherwise +" it appears the same as normal mode + +" Normal mode " fg & bg +let s:N1 = [ '#005f00' , '#afd700' , 22 , 148 ] " darkestgreen & brightgreen +let s:N2 = [ '#9e9e9e' , '#303030' , 247 , 236 ] " gray8 & gray2 +let s:N3 = [ '#ffffff' , '#121212' , 231 , 233 ] " white & gray4 + +" Insert mode " fg & bg +let s:I1 = [ '#005f5f' , '#ffffff' , 23 , 231 ] " darkestcyan & white +let s:I2 = [ '#5fafd7' , '#0087af' , 74 , 31 ] " darkcyan & darkblue +let s:I3 = [ '#87d7ff' , '#005f87' , 117 , 24 ] " mediumcyan & darkestblue + +" Visual mode " fg & bg +let s:V1 = [ '#080808' , '#ffaf00' , 232 , 214 ] " gray3 & brightestorange + +" Replace mode " fg & bg +let s:RE = [ '#ffffff' , '#d70000' , 231 , 160 ] " white & brightred + +let g:airline#themes#powerlineish#palette = {} + +let g:airline#themes#powerlineish#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + +let g:airline#themes#powerlineish#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#powerlineish#palette.insert_replace = { + \ 'airline_a': [ s:RE[0] , s:I1[1] , s:RE[1] , s:I1[3] , '' ] } + +let g:airline#themes#powerlineish#palette.visual = { + \ 'airline_a': [ s:V1[0] , s:V1[1] , s:V1[2] , s:V1[3] , '' ] } + +let g:airline#themes#powerlineish#palette.replace = copy(airline#themes#powerlineish#palette.normal) +let g:airline#themes#powerlineish#palette.replace.airline_a = [ s:RE[0] , s:RE[1] , s:RE[2] , s:RE[3] , '' ] + + +let s:IA = [ s:N2[1] , s:N3[1] , s:N2[3] , s:N3[3] , '' ] +let g:airline#themes#powerlineish#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) + diff --git a/.vim/autoload/airline/themes/raven.vim b/.vim/autoload/airline/themes/raven.vim new file mode 100644 index 0000000..02bfd73 --- /dev/null +++ b/.vim/autoload/airline/themes/raven.vim @@ -0,0 +1,85 @@ +let g:airline#themes#raven#palette = {} + +let g:airline#themes#raven#palette.accents = { + \ 'red': [ '#ff2121' , '' , 196 , '' , '' ], + \ } + +let s:N1 = [ '#c8c8c8' , '#2e2e2e' , 188 , 235 ] +let s:N2 = [ '#c8c8c8' , '#2e2e2e' , 188 , 235 ] +let s:N3 = [ '#c8c8c8' , '#2e2e2e' , 188 , 235 ] +let g:airline#themes#raven#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#raven#palette.normal_modified = { + \ 'airline_c': [ '#e25000' , '#2e2e2e' , 166 , 235 , '' ] , + \ } + +let s:I1 = [ '#11c279' , '#2e2e2e' , 36 , 235 ] +let s:I2 = [ '#11c279' , '#2e2e2e' , 36 , 235 ] +let s:I3 = [ '#11c279' , '#2e2e2e' , 36 , 235 ] +let g:airline#themes#raven#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#raven#palette.insert_modified = { + \ 'airline_c': [ '#e25000' , '#2e2e2e' , 166 , 235 , '' ] , + \ } +let g:airline#themes#raven#palette.insert_paste = { + \ 'airline_a': [ s:I1[0] , '#2e2e2e' , s:I1[2] , 235 , '' ] , + \ } + +let g:airline#themes#raven#palette.replace = copy(g:airline#themes#raven#palette.insert) +let g:airline#themes#raven#palette.replace.airline_a = [ '#e60000' , s:I1[1] , 160 , s:I1[3] , '' ] +let g:airline#themes#raven#palette.replace.airline_z = [ '#e60000' , s:I1[1] , 160 , s:I1[3] , '' ] +let g:airline#themes#raven#palette.replace_modified = g:airline#themes#raven#palette.insert_modified + +let s:V1 = [ '#6565ff' , '#2e2e2e' , 63 , 235 ] +let s:V2 = [ '#6565ff' , '#2e2e2e' , 63 , 235 ] +let s:V3 = [ '#6565ff' , '#2e2e2e' , 63 , 235 ] +let g:airline#themes#raven#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#raven#palette.visual_modified = { + \ 'airline_c': [ '#e25000' , '#2e2e2e' , 166 , 235 , '' ] , + \ } + +let s:IA = [ '#5e5e5e' , '#222222' , 59 , 235 , '' ] +let g:airline#themes#raven#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) +let g:airline#themes#raven#palette.inactive_modified = { + \ 'airline_c': [ '#e25000' , '' , 166 , '' , '' ] , + \ } + +let g:airline#themes#raven#palette.tabline = { + \ 'airline_tab': ['#c8c8c8' , '#2e2e2e' , 188 , 235 , '' ], + \ 'airline_tabsel': ['#2e2e2e' , '#a4c639' , 235 , 149 , '' ], + \ 'airline_tabtype': ['#c8c8c8' , '#2e2e2e' , 188 , 235 , '' ], + \ 'airline_tabfill': ['#c8c8c8' , '#2e2e2e' , 188 , 235 , '' ], + \ 'airline_tabmod': ['#2e2e2e' , '#a4c639' , 235 , 149 , '' ], + \ } + +let s:WI = [ '#ff0000', '#2e2e2e', 196, 235 ] +let g:airline#themes#raven#palette.normal.airline_warning = [ + \ s:WI[0], s:WI[1], s:WI[2], s:WI[3] + \ ] + +let g:airline#themes#raven#palette.normal_modified.airline_warning = + \ g:airline#themes#raven#palette.normal.airline_warning + +let g:airline#themes#raven#palette.insert.airline_warning = + \ g:airline#themes#raven#palette.normal.airline_warning + +let g:airline#themes#raven#palette.insert_modified.airline_warning = + \ g:airline#themes#raven#palette.normal.airline_warning + +let g:airline#themes#raven#palette.visual.airline_warning = + \ g:airline#themes#raven#palette.normal.airline_warning + +let g:airline#themes#raven#palette.visual_modified.airline_warning = + \ g:airline#themes#raven#palette.normal.airline_warning + +let g:airline#themes#raven#palette.replace.airline_warning = + \ g:airline#themes#raven#palette.normal.airline_warning + +let g:airline#themes#raven#palette.replace_modified.airline_warning = + \ g:airline#themes#raven#palette.normal.airline_warning + +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#raven#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ '#c8c8c8' , '#2e2e2e' , 188 , 235 , '' ] , + \ [ '#c8c8c8' , '#2e2e2e' , 188 , 235 , '' ] , + \ [ '#2e2e2e' , '#a4c639' , 235 , 149 , '' ] ) diff --git a/.vim/autoload/airline/themes/serene.vim b/.vim/autoload/airline/themes/serene.vim new file mode 100644 index 0000000..9191c07 --- /dev/null +++ b/.vim/autoload/airline/themes/serene.vim @@ -0,0 +1,41 @@ +let g:airline#themes#serene#palette = {} + +let s:guibg = '#080808' +let s:termbg = 232 +let s:termsep = 236 +let s:guisep = '#303030' + +let s:N1 = [ '#00dfff' , s:guibg , 45 , s:termbg ] +let s:N2 = [ '#ff5f00' , s:guibg , 202 , s:termbg ] +let s:N3 = [ '#767676' , s:guibg , 7 , s:termbg ] + +let g:airline#themes#serene#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#serene#palette.normal_modified = { + \ 'airline_c': [ '#df0000' , s:guibg, 160 , s:termbg , '' ] , + \ } + +let s:I1 = [ '#5fff00' , s:guibg , 82 , s:termbg ] +let s:I2 = [ '#ff5f00' , s:guibg , 202 , s:termbg ] +let s:I3 = [ '#767676' , s:guibg , 7 , s:termbg ] +let g:airline#themes#serene#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#serene#palette.insert_modified = copy(g:airline#themes#serene#palette.normal_modified) +let g:airline#themes#serene#palette.insert_paste = { + \ 'airline_a': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] , + \ } + +let g:airline#themes#serene#palette.replace = { + \ 'airline_a': [ s:I1[0] , '#af0000' , s:I1[2] , 124 , '' ] , + \ } +let g:airline#themes#serene#palette.replace_modified = copy(g:airline#themes#serene#palette.normal_modified) + +let s:V1 = [ '#dfdf00' , s:guibg , 184 , s:termbg ] +let s:V2 = [ '#ff5f00' , s:guibg , 202 , s:termbg ] +let s:V3 = [ '#767676' , s:guibg , 7 , s:termbg ] +let g:airline#themes#serene#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#serene#palette.visual_modified = copy(g:airline#themes#serene#palette.normal_modified) + +let s:IA = [ '#4e4e4e' , s:guibg , 239 , s:termbg , '' ] +let s:IA2 = [ '#4e4e4e' , s:guisep , 239 , s:termsep , '' ] +let g:airline#themes#serene#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA2, s:IA2) +let g:airline#themes#serene#palette.inactive_modified = copy(g:airline#themes#serene#palette.normal_modified) + diff --git a/.vim/autoload/airline/themes/silver.vim b/.vim/autoload/airline/themes/silver.vim new file mode 100644 index 0000000..fd85edb --- /dev/null +++ b/.vim/autoload/airline/themes/silver.vim @@ -0,0 +1,85 @@ +let g:airline#themes#silver#palette = {} + +let g:airline#themes#silver#palette.accents = { + \ 'red': [ '#ff2121' , '' , 196 , '' , '' ], + \ } + +let s:N1 = [ '#414141' , '#e1e1e1' , 59 , 188 ] +let s:N2 = [ '#414141' , '#e1e1e1' , 59 , 188 ] +let s:N3 = [ '#414141' , '#e1e1e1' , 59 , 188 ] +let g:airline#themes#silver#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#silver#palette.normal_modified = { + \ 'airline_c': [ '#e25000' , '#e1e1e1' , 166 , 188 , '' ] , + \ } + +let s:I1 = [ '#0d935c' , '#e1e1e1' , 29 , 188 ] +let s:I2 = [ '#0d935c' , '#e1e1e1' , 29 , 188 ] +let s:I3 = [ '#0d935c' , '#e1e1e1' , 29 , 188 ] +let g:airline#themes#silver#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#silver#palette.insert_modified = { + \ 'airline_c': [ '#e25000' , '#e1e1e1' , 166 , 188 , '' ] , + \ } +let g:airline#themes#silver#palette.insert_paste = { + \ 'airline_a': [ s:I1[0] , '#e1e1e1' , s:I1[2] , 188 , '' ] , + \ } + +let g:airline#themes#silver#palette.replace = copy(g:airline#themes#silver#palette.insert) +let g:airline#themes#silver#palette.replace.airline_a = [ '#b30000' , s:I1[1] , 124 , s:I1[3] , '' ] +let g:airline#themes#silver#palette.replace.airline_z = [ '#b30000' , s:I1[1] , 124 , s:I1[3] , '' ] +let g:airline#themes#silver#palette.replace_modified = g:airline#themes#silver#palette.insert_modified + +let s:V1 = [ '#0000b3' , '#e1e1e1' , 19 , 188 ] +let s:V2 = [ '#0000b3' , '#e1e1e1' , 19 , 188 ] +let s:V3 = [ '#0000b3' , '#e1e1e1' , 19 , 188 ] +let g:airline#themes#silver#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#silver#palette.visual_modified = { + \ 'airline_c': [ '#e25000' , '#e1e1e1' , 166 , 188 , '' ] , + \ } + +let s:IA = [ '#a1a1a1' , '#dddddd' , 145 , 188 , '' ] +let g:airline#themes#silver#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) +let g:airline#themes#silver#palette.inactive_modified = { + \ 'airline_c': [ '#e25000' , '' , 166 , '' , '' ] , + \ } + +let g:airline#themes#silver#palette.tabline = { + \ 'airline_tab': ['#414141' , '#e1e1e1' , 59 , 188 , '' ], + \ 'airline_tabsel': ['#e1e1e1' , '#007599' , 188 , 30 , '' ], + \ 'airline_tabtype': ['#414141' , '#e1e1e1' , 59 , 188 , '' ], + \ 'airline_tabfill': ['#414141' , '#e1e1e1' , 59 , 188 , '' ], + \ 'airline_tabmod': ['#e1e1e1' , '#007599' , 188 , 30 , '' ], + \ } + +let s:WI = [ '#ff0000', '#e1e1e1', 196, 188 ] +let g:airline#themes#silver#palette.normal.airline_warning = [ + \ s:WI[0], s:WI[1], s:WI[2], s:WI[3] + \ ] + +let g:airline#themes#silver#palette.normal_modified.airline_warning = + \ g:airline#themes#silver#palette.normal.airline_warning + +let g:airline#themes#silver#palette.insert.airline_warning = + \ g:airline#themes#silver#palette.normal.airline_warning + +let g:airline#themes#silver#palette.insert_modified.airline_warning = + \ g:airline#themes#silver#palette.normal.airline_warning + +let g:airline#themes#silver#palette.visual.airline_warning = + \ g:airline#themes#silver#palette.normal.airline_warning + +let g:airline#themes#silver#palette.visual_modified.airline_warning = + \ g:airline#themes#silver#palette.normal.airline_warning + +let g:airline#themes#silver#palette.replace.airline_warning = + \ g:airline#themes#silver#palette.normal.airline_warning + +let g:airline#themes#silver#palette.replace_modified.airline_warning = + \ g:airline#themes#silver#palette.normal.airline_warning + +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#silver#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ '#414141' , '#e1e1e1' , 59 , 188 , '' ] , + \ [ '#414141' , '#e1e1e1' , 59 , 188 , '' ] , + \ [ '#e1e1e1' , '#007599' , 188 , 30 , '' ] ) diff --git a/.vim/autoload/airline/themes/simple.vim b/.vim/autoload/airline/themes/simple.vim new file mode 100644 index 0000000..a111a1c --- /dev/null +++ b/.vim/autoload/airline/themes/simple.vim @@ -0,0 +1,46 @@ +let g:airline#themes#simple#palette = {} + +let s:guibg = '#080808' +let s:guibg2 = '#1c1c1c' +let s:termbg = 232 +let s:termbg2= 234 + +let s:N1 = [ s:guibg , '#00dfff' , s:termbg , 45 ] +let s:N2 = [ '#ff5f00' , s:guibg2, 202 , s:termbg2 ] +let s:N3 = [ '#767676' , s:guibg, 243 , s:termbg] +let g:airline#themes#simple#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#simple#palette.normal_modified = { + \ 'airline_c': [ '#df0000' , s:guibg, 160 , s:termbg , '' ] , + \ } + + +let s:I1 = [ s:guibg, '#5fff00' , s:termbg , 82 ] +let s:I2 = [ '#ff5f00' , s:guibg2, 202 , s:termbg2 ] +let s:I3 = [ '#767676' , s:guibg, 243 , s:termbg ] +let g:airline#themes#simple#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#simple#palette.insert_modified = copy(g:airline#themes#simple#palette.normal_modified) +let g:airline#themes#simple#palette.insert_paste = { + \ 'airline_a': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] , + \ } + + +let g:airline#themes#simple#palette.replace = { + \ 'airline_a': [ s:I1[0] , '#af0000' , s:I1[2] , 124 , '' ] , + \ } +let g:airline#themes#simple#palette.replace_modified = copy(g:airline#themes#simple#palette.normal_modified) + + +let s:V1 = [ s:guibg, '#dfdf00' , s:termbg , 184 ] +let s:V2 = [ '#ff5f00' , s:guibg2, 202 , s:termbg2 ] +let s:V3 = [ '#767676' , s:guibg, 243 , s:termbg ] +let g:airline#themes#simple#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#simple#palette.visual_modified = copy(g:airline#themes#simple#palette.normal_modified) + + +let s:IA = [ '#4e4e4e' , s:guibg , 239 , s:termbg , '' ] +let s:IA2 = [ '#4e4e4e' , s:guibg2 , 239 , s:termbg2 , '' ] +let g:airline#themes#simple#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA2, s:IA2) +let g:airline#themes#simple#palette.inactive_modified = { + \ 'airline_c': [ '#df0000', '', 160, '', '' ] , + \ } + diff --git a/.vim/autoload/airline/themes/sol.vim b/.vim/autoload/airline/themes/sol.vim new file mode 100644 index 0000000..89ea505 --- /dev/null +++ b/.vim/autoload/airline/themes/sol.vim @@ -0,0 +1,90 @@ +" vim-airline companion theme of Sol +" (https://github.com/Pychimp/vim-sol) + +let g:airline#themes#sol#palette = {} + +let g:airline#themes#sol#palette.accents = { + \ 'red': [ '#ffffff' , '' , 231 , '' , '' ], + \ } + +let s:N1 = [ '#343434' , '#a0a0a0' , 237 , 248 ] +let s:N2 = [ '#343434' , '#b3b3b3' , 237 , 250 ] +let s:N3 = [ '#343434' , '#c7c7c7' , 237 , 252 ] +let g:airline#themes#sol#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#sol#palette.normal_modified = { + \ 'airline_c': [ '#ffffff' , '#ff6868' , 237 , 209 , '' ] , + \ } + + +let s:I1 = [ '#eeeeee' , '#09643f' , 255 , 30 ] +let s:I2 = [ '#343434' , '#a3a3a3' , 237 , 249 ] +let s:I3 = [ '#343434' , '#b0b0b0' , 237 , 250 ] +let g:airline#themes#sol#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#sol#palette.insert_modified = { + \ 'airline_c': [ '#343434' , '#ffdbc7' , 237 , 216 , '' ] , + \ } +let g:airline#themes#sol#palette.insert_paste = { + \ 'airline_a': [ s:I1[0] , '#09643f' , s:I1[2] , 30 , '' ] , + \ } + + +let g:airline#themes#sol#palette.replace = copy(g:airline#themes#sol#palette.insert) +let g:airline#themes#sol#palette.replace.airline_a = [ s:I1[0] , '#ff2121' , s:I1[2] , 196 , '' ] +let g:airline#themes#sol#palette.replace.airline_z = [ s:I1[0] , '#ff2121' , s:I1[2] , 196 , '' ] +let g:airline#themes#sol#palette.replace_modified = g:airline#themes#sol#palette.insert_modified + +let s:V1 = [ '#ffff9a' , '#ff6003' , 222 , 202 ] +let s:V2 = [ '#343434' , '#a3a3a3' , 237 , 249 ] +let s:V3 = [ '#343434' , '#b0b0b0' , 237 , 250 ] +let g:airline#themes#sol#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#sol#palette.visual_modified = { + \ 'airline_c': [ '#343434' , '#ffdbc7' , 237 , 216 , '' ] , + \ } + +let s:IA = [ '#777777' , '#c7c7c7' , 244 , 251 , '' ] +let g:airline#themes#sol#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) +let g:airline#themes#sol#palette.inactive_modified = { + \ 'airline_c': [ '#ff3535' , '' , 203 , '' , '' ] , + \ } + +let g:airline#themes#sol#palette.tabline = { + \ 'airline_tab': ['#343434', '#b3b3b3', 237, 250, ''], + \ 'airline_tabsel': ['#ffffff', '#004b9a', 231, 31 , ''], + \ 'airline_tabtype': ['#343434', '#a0a0a0', 237, 248, ''], + \ 'airline_tabfill': ['#343434', '#c7c7c7', 237, 251, ''], + \ 'airline_tabmod': ['#343434', '#ffdbc7', 237, 216, ''], + \ } + +let s:WI = [ '#eeeeee', '#e33900', 255, 166 ] +let g:airline#themes#sol#palette.normal.airline_warning = [ + \ s:WI[0], s:WI[1], s:WI[2], s:WI[3] + \ ] + +let g:airline#themes#sol#palette.normal_modified.airline_warning = + \ g:airline#themes#sol#palette.normal.airline_warning + +let g:airline#themes#sol#palette.insert.airline_warning = + \ g:airline#themes#sol#palette.normal.airline_warning + +let g:airline#themes#sol#palette.insert_modified.airline_warning = + \ g:airline#themes#sol#palette.normal.airline_warning + +let g:airline#themes#sol#palette.visual.airline_warning = + \ g:airline#themes#sol#palette.normal.airline_warning + +let g:airline#themes#sol#palette.visual_modified.airline_warning = + \ g:airline#themes#sol#palette.normal.airline_warning + +let g:airline#themes#sol#palette.replace.airline_warning = + \ g:airline#themes#sol#palette.normal.airline_warning + +let g:airline#themes#sol#palette.replace_modified.airline_warning = + \ g:airline#themes#sol#palette.normal.airline_warning + +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#sol#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ '#343434' , '#c7c7c7' , 237 , 251 , '' ] , + \ [ '#343434' , '#b3b3b3' , 237 , 250 , '' ] , + \ [ '#eeeeee' , '#007fff' , 255 , 27 , '' ] ) diff --git a/.vim/autoload/airline/themes/solarized.vim b/.vim/autoload/airline/themes/solarized.vim new file mode 100644 index 0000000..30ba47e --- /dev/null +++ b/.vim/autoload/airline/themes/solarized.vim @@ -0,0 +1,176 @@ +let g:airline#themes#solarized#palette = {} + +function! airline#themes#solarized#refresh() + """""""""""""""""""""""""""""""""""""""""""""""" + " Options + """""""""""""""""""""""""""""""""""""""""""""""" + let s:background = get(g:, 'airline_solarized_bg', &background) + let s:ansi_colors = get(g:, 'solarized_termcolors', 16) != 256 && &t_Co >= 16 ? 1 : 0 + let s:tty = &t_Co == 8 + + """""""""""""""""""""""""""""""""""""""""""""""" + " Colors + """""""""""""""""""""""""""""""""""""""""""""""" + " Base colors + let s:base03 = {'t': s:ansi_colors ? 8 : (s:tty ? '0' : 234), 'g': '#002b36'} + let s:base02 = {'t': s:ansi_colors ? '0' : (s:tty ? '0' : 235), 'g': '#073642'} + let s:base01 = {'t': s:ansi_colors ? 10 : (s:tty ? '0' : 240), 'g': '#586e75'} + let s:base00 = {'t': s:ansi_colors ? 11 : (s:tty ? '7' : 241), 'g': '#657b83'} + let s:base0 = {'t': s:ansi_colors ? 12 : (s:tty ? '7' : 244), 'g': '#839496'} + let s:base1 = {'t': s:ansi_colors ? 14 : (s:tty ? '7' : 245), 'g': '#93a1a1'} + let s:base2 = {'t': s:ansi_colors ? 7 : (s:tty ? '7' : 254), 'g': '#eee8d5'} + let s:base3 = {'t': s:ansi_colors ? 15 : (s:tty ? '7' : 230), 'g': '#fdf6e3'} + let s:yellow = {'t': s:ansi_colors ? 3 : (s:tty ? '3' : 136), 'g': '#b58900'} + let s:orange = {'t': s:ansi_colors ? 9 : (s:tty ? '1' : 166), 'g': '#cb4b16'} + let s:red = {'t': s:ansi_colors ? 1 : (s:tty ? '1' : 160), 'g': '#dc322f'} + let s:magenta = {'t': s:ansi_colors ? 5 : (s:tty ? '5' : 125), 'g': '#d33682'} + let s:violet = {'t': s:ansi_colors ? 13 : (s:tty ? '5' : 61 ), 'g': '#6c71c4'} + let s:blue = {'t': s:ansi_colors ? 4 : (s:tty ? '4' : 33 ), 'g': '#268bd2'} + let s:cyan = {'t': s:ansi_colors ? 6 : (s:tty ? '6' : 37 ), 'g': '#2aa198'} + let s:green = {'t': s:ansi_colors ? 2 : (s:tty ? '2' : 64 ), 'g': '#859900'} + + """""""""""""""""""""""""""""""""""""""""""""""" + " Simple mappings + " NOTE: These are easily tweakable mappings. The actual mappings get + " the specific gui and terminal colors from the base color dicts. + """""""""""""""""""""""""""""""""""""""""""""""" + " Normal mode + if s:background == 'dark' + let s:N1 = [s:base3, s:base1, 'bold'] + let s:N2 = [s:base2, (s:tty ? s:base01 : s:base00), ''] + let s:N3 = [s:base01, s:base02, ''] + else + let s:N1 = [s:base2, s:base00, 'bold'] + let s:N2 = [(s:tty ? s:base01 : s:base2), s:base1, ''] + let s:N3 = [s:base1, s:base2, ''] + endif + let s:NF = [s:orange, s:N3[1], ''] + let s:NW = [s:base3, s:orange, ''] + if s:background == 'dark' + let s:NM = [s:base1, s:N3[1], ''] + let s:NMi = [s:base2, s:N3[1], ''] + else + let s:NM = [s:base01, s:N3[1], ''] + let s:NMi = [s:base02, s:N3[1], ''] + endif + + " Insert mode + let s:I1 = [s:N1[0], s:yellow, 'bold'] + let s:I2 = s:N2 + let s:I3 = s:N3 + let s:IF = s:NF + let s:IM = s:NM + + " Visual mode + let s:V1 = [s:N1[0], s:magenta, 'bold'] + let s:V2 = s:N2 + let s:V3 = s:N3 + let s:VF = s:NF + let s:VM = s:NM + + " Replace mode + let s:R1 = [s:N1[0], s:red, ''] + let s:R2 = s:N2 + let s:R3 = s:N3 + let s:RM = s:NM + let s:RF = s:NF + + " Inactive, according to VertSplit in solarized + " (bg dark: base00; bg light: base0) + if s:background == 'dark' + let s:IA = [s:base02, s:base00, ''] + else + let s:IA = [s:base2, s:base0, ''] + endif + + """""""""""""""""""""""""""""""""""""""""""""""" + " Actual mappings + " WARNING: Don't modify this section unless necessary. + """""""""""""""""""""""""""""""""""""""""""""""" + let s:NFa = [s:NF[0].g, s:NF[1].g, s:NF[0].t, s:NF[1].t, s:NF[2]] + let s:IFa = [s:IF[0].g, s:IF[1].g, s:IF[0].t, s:IF[1].t, s:IF[2]] + let s:VFa = [s:VF[0].g, s:VF[1].g, s:VF[0].t, s:VF[1].t, s:VF[2]] + let s:RFa = [s:RF[0].g, s:RF[1].g, s:RF[0].t, s:RF[1].t, s:RF[2]] + + let g:airline#themes#solarized#palette.accents = { + \ 'red': s:NFa, + \ } + + let g:airline#themes#solarized#palette.inactive = airline#themes#generate_color_map( + \ [s:IA[0].g, s:IA[1].g, s:IA[0].t, s:IA[1].t, s:IA[2]], + \ [s:IA[0].g, s:IA[1].g, s:IA[0].t, s:IA[1].t, s:IA[2]], + \ [s:IA[0].g, s:IA[1].g, s:IA[0].t, s:IA[1].t, s:IA[2]]) + let g:airline#themes#solarized#palette.inactive_modified = { + \ 'airline_c': [s:NMi[0].g, '', s:NMi[0].t, '', s:NMi[2]]} + + let g:airline#themes#solarized#palette.normal = airline#themes#generate_color_map( + \ [s:N1[0].g, s:N1[1].g, s:N1[0].t, s:N1[1].t, s:N1[2]], + \ [s:N2[0].g, s:N2[1].g, s:N2[0].t, s:N2[1].t, s:N2[2]], + \ [s:N3[0].g, s:N3[1].g, s:N3[0].t, s:N3[1].t, s:N3[2]]) + + let g:airline#themes#solarized#palette.normal.airline_warning = [ + \ s:NW[0].g, s:NW[1].g, s:NW[0].t, s:NW[1].t, s:NW[2]] + + let g:airline#themes#solarized#palette.normal_modified = { + \ 'airline_c': [s:NM[0].g, s:NM[1].g, + \ s:NM[0].t, s:NM[1].t, s:NM[2]]} + + let g:airline#themes#solarized#palette.normal_modified.airline_warning = + \ g:airline#themes#solarized#palette.normal.airline_warning + + let g:airline#themes#solarized#palette.insert = airline#themes#generate_color_map( + \ [s:I1[0].g, s:I1[1].g, s:I1[0].t, s:I1[1].t, s:I1[2]], + \ [s:I2[0].g, s:I2[1].g, s:I2[0].t, s:I2[1].t, s:I2[2]], + \ [s:I3[0].g, s:I3[1].g, s:I3[0].t, s:I3[1].t, s:I3[2]]) + + let g:airline#themes#solarized#palette.insert.airline_warning = + \ g:airline#themes#solarized#palette.normal.airline_warning + + let g:airline#themes#solarized#palette.insert_modified = { + \ 'airline_c': [s:IM[0].g, s:IM[1].g, + \ s:IM[0].t, s:IM[1].t, s:IM[2]]} + + let g:airline#themes#solarized#palette.insert_modified.airline_warning = + \ g:airline#themes#solarized#palette.normal.airline_warning + + let g:airline#themes#solarized#palette.visual = airline#themes#generate_color_map( + \ [s:V1[0].g, s:V1[1].g, s:V1[0].t, s:V1[1].t, s:V1[2]], + \ [s:V2[0].g, s:V2[1].g, s:V2[0].t, s:V2[1].t, s:V2[2]], + \ [s:V3[0].g, s:V3[1].g, s:V3[0].t, s:V3[1].t, s:V3[2]]) + + let g:airline#themes#solarized#palette.visual.airline_warning = + \ g:airline#themes#solarized#palette.normal.airline_warning + + let g:airline#themes#solarized#palette.visual_modified = { + \ 'airline_c': [s:VM[0].g, s:VM[1].g, + \ s:VM[0].t, s:VM[1].t, s:VM[2]]} + + let g:airline#themes#solarized#palette.visual_modified.airline_warning = + \ g:airline#themes#solarized#palette.normal.airline_warning + + let g:airline#themes#solarized#palette.replace = airline#themes#generate_color_map( + \ [s:R1[0].g, s:R1[1].g, s:R1[0].t, s:R1[1].t, s:R1[2]], + \ [s:R2[0].g, s:R2[1].g, s:R2[0].t, s:R2[1].t, s:R2[2]], + \ [s:R3[0].g, s:R3[1].g, s:R3[0].t, s:R3[1].t, s:R3[2]]) + + let g:airline#themes#solarized#palette.replace.airline_warning = + \ g:airline#themes#solarized#palette.normal.airline_warning + + let g:airline#themes#solarized#palette.replace_modified = { + \ 'airline_c': [s:RM[0].g, s:RM[1].g, + \ s:RM[0].t, s:RM[1].t, s:RM[2]]} + + let g:airline#themes#solarized#palette.replace_modified.airline_warning = + \ g:airline#themes#solarized#palette.normal.airline_warning + + let g:airline#themes#solarized#palette.tabline = {} + + let g:airline#themes#solarized#palette.tabline.airline_tab = [ + \ s:I2[0].g, s:I2[1].g, s:I2[0].t, s:I2[1].t, s:I2[2]] + + let g:airline#themes#solarized#palette.tabline.airline_tabtype = [ + \ s:N2[0].g, s:N2[1].g, s:N2[0].t, s:N2[1].t, s:N2[2]] +endfunction + +call airline#themes#solarized#refresh() + diff --git a/.vim/autoload/airline/themes/tomorrow.vim b/.vim/autoload/airline/themes/tomorrow.vim new file mode 100644 index 0000000..f382fc1 --- /dev/null +++ b/.vim/autoload/airline/themes/tomorrow.vim @@ -0,0 +1,44 @@ +let g:airline#themes#tomorrow#palette = {} + +function! airline#themes#tomorrow#refresh() + let g:airline#themes#tomorrow#palette.accents = { + \ 'red': airline#themes#get_highlight('Constant'), + \ } + + let s:N1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Directory', 'fg'], 'bold') + let s:N2 = airline#themes#get_highlight('Pmenu') + let s:N3 = airline#themes#get_highlight('CursorLine') + let g:airline#themes#tomorrow#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + + let group = airline#themes#get_highlight('vimCommand') + let g:airline#themes#tomorrow#palette.normal_modified = { + \ 'airline_c': [ group[0], '', group[2], '', '' ] + \ } + + let s:I1 = airline#themes#get_highlight2(['Normal', 'bg'], ['MoreMsg', 'fg'], 'bold') + let s:I2 = airline#themes#get_highlight2(['MoreMsg', 'fg'], ['Normal', 'bg']) + let s:I3 = s:N3 + let g:airline#themes#tomorrow#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) + let g:airline#themes#tomorrow#palette.insert_modified = g:airline#themes#tomorrow#palette.normal_modified + + let s:R1 = airline#themes#get_highlight('Error', 'bold') + let s:R2 = s:N2 + let s:R3 = s:N3 + let g:airline#themes#tomorrow#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) + let g:airline#themes#tomorrow#palette.replace_modified = g:airline#themes#tomorrow#palette.normal_modified + + let s:V1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Constant', 'fg'], 'bold') + let s:V2 = airline#themes#get_highlight2(['Constant', 'fg'], ['Normal', 'bg']) + let s:V3 = s:N3 + let g:airline#themes#tomorrow#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) + let g:airline#themes#tomorrow#palette.visual_modified = g:airline#themes#tomorrow#palette.normal_modified + + let s:IA = airline#themes#get_highlight2(['NonText', 'fg'], ['CursorLine', 'bg']) + let g:airline#themes#tomorrow#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) + let g:airline#themes#tomorrow#palette.inactive_modified = { + \ 'airline_c': [ group[0], '', group[2], '', '' ] + \ } +endfunction + +call airline#themes#tomorrow#refresh() + diff --git a/.vim/autoload/airline/themes/ubaryd.vim b/.vim/autoload/airline/themes/ubaryd.vim new file mode 100644 index 0000000..70232ef --- /dev/null +++ b/.vim/autoload/airline/themes/ubaryd.vim @@ -0,0 +1,64 @@ +" vim-airline companion theme of Ubaryd +" (https://github.com/Donearm/Ubaryd) + +" Normal mode +let s:N1 = [ '#141413' , '#c7b386' , 232 , 252 ] " blackestgravel & bleaksand +let s:N2 = [ '#c7b386' , '#45413b' , 252, 238 ] " bleaksand & deepgravel +let s:N3 = [ '#b88853' , '#242321' , 137, 235 ] " toffee & darkgravel +let s:N4 = [ '#857f78' , 243 ] " gravel + +" Insert mode +let s:I1 = [ '#1a1a18' , '#fade3e' , 232 , 221 ] " blackestgravel & warmcorn +let s:I2 = [ '#c7b386' , '#45413b' , 252 , 238 ] " bleaksand & deepgravel +let s:I3 = [ '#f4cf86' , '#242321' , 222 , 235 ] " lighttannedskin & darkgravel + +" Visual mode +let s:V1 = [ '#1c1b1a' , '#9a4820' , 233 , 88 ] " blackgravel & warmadobe +let s:V2 = [ '#000000' , '#88633f' , 16 , 95 ] " coal & cappuccino +let s:V3 = [ '#88633f' , '#c7b386' , 95 , 252 ] " cappuccino & bleaksand +let s:V4 = [ '#c14c3d' , 160 ] " tannedumbrella + +" Replace mode +let s:RE = [ '#c7915b' , 173 ] " nut + +" Paste mode +let s:PA = [ '#f9ef6d' , 154 ] " bleaklemon + +let s:IA = [ s:N2[1], s:N3[1], s:N2[3], s:N3[3], '' ] + +let g:airline#themes#ubaryd#palette = {} + +let g:airline#themes#ubaryd#palette.accents = { + \ 'red': [ '#ff7400' , '' , 196 , '' , '' ], + \ } + +let g:airline#themes#ubaryd#palette.inactive = { + \ 'airline_a' : [ s:N2[1] , s:N3[1] , s:N2[3] , s:N3[3] , '' ] } + + +let g:airline#themes#ubaryd#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#ubaryd#palette.normal_modified = { + \ 'airline_a' : [ s:N2[0] , s:N4[0] , s:N2[2] , s:N4[1] , '' ] , + \ 'airline_c' : [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } + + +let g:airline#themes#ubaryd#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#ubaryd#palette.insert_modified = { + \ 'airline_c' : [ s:V2[1] , s:N2[1] , s:V2[3] , s:N2[3] , '' ] } +let g:airline#themes#ubaryd#palette.insert_paste = { + \ 'airline_a' : [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] } + + +let g:airline#themes#ubaryd#palette.replace = copy(airline#themes#ubaryd#palette.insert) +let g:airline#themes#ubaryd#palette.replace.airline_a = [ s:I1[0] , s:RE[0] , s:I1[2] , s:RE[1] , '' ] +let g:airline#themes#ubaryd#palette.replace_modified = g:airline#themes#ubaryd#palette.insert_modified + + +let g:airline#themes#ubaryd#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#ubaryd#palette.visual_modified = { + \ 'airline_c' : [ s:V3[0] , s:V4[0] , s:V3[2] , s:V4[1] , '' ] } + +let g:airline#themes#ubaryd#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) +let g:airline#themes#ubaryd#palette.inactive_modified = { + \ 'airline_c' : [ s:V1[1] , '' , s:V1[3] , '' , '' ] } + diff --git a/.vim/autoload/airline/themes/understated.vim b/.vim/autoload/airline/themes/understated.vim new file mode 100644 index 0000000..b3e7917 --- /dev/null +++ b/.vim/autoload/airline/themes/understated.vim @@ -0,0 +1,43 @@ +let g:airline#themes#understated#palette = {} + +let s:N1 = ['#FFFFFF', '#5F87FF', 15, 69] " Outside blocks in normal mode (mode and file position) +let s:N2 = ['#AFAF87', '#5F5F5F', 144, 59] " Next blocks inside (branch and file format) +let s:N3 = ['#AFAF87', '#5F5F5F', 144, 59] " The middle block + +let g:airline#themes#understated#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#understated#palette.normal_modified = {'airline_c': ['#ffffff', '#5f005f', 144, 59, 'bold'] ,} + +let s:I1 = ['#FFFFFF', '#87AF5F', 15, 107] " Outside blocks in normal mode (mode and file position) +let s:I2 = ['#AFAF87', '#5F5F5F', 144, 59] " Next blocks inside (branch and file format) +let s:I3 = ['#AFAF87', '#5F5F5F', 144, 59] " The middle block +let g:airline#themes#understated#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#understated#palette.insert_modified = {'airline_c': ['#AFAF87', '#5F5F5F', 144, 59, 'bold'] ,} +let g:airline#themes#understated#palette.insert_paste = {'airline_c': ['#AFAF87', '#5F5F5F', 144, 59, ''] ,} + +let g:airline#themes#understated#palette.replace = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#understated#palette.replace.airline_a = ['#FFFFFF', '#870000', 15, 88, ''] +let g:airline#themes#understated#palette.replace_modified = {'airline_c': ['#AFAF87', '#5F5F5F', 144, 59, 'bold'] ,} + +let s:V1 = ['#FFFFFF', '#AF5F00', 15, 130] +let s:V2 = ['#AFAF87', '#5F5F5F', 144, 59] +let s:V3 = ['#AFAF87', '#5F5F5F', 144, 59] +let g:airline#themes#understated#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#understated#palette.visual_modified = {'airline_c': [ '#AFAF87', '#5f005f', 144, 59, 'bold'] ,} + +let s:V1 = ['#080808', '#FFAF00', 232, 214] +let s:IA1 = ['#4E4E4E', '#1C1C1C', 239, 234, ''] +let s:IA2 = ['#4E4E4E', '#1C1C1C', 239, 234, ''] +let s:IA3 = ['#4E4E4E', '#1C1C1C', 239, 234, ''] +let g:airline#themes#understated#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3) +let g:airline#themes#understated#palette.inactive_modified = {'airline_c': ['#4E4E4E', '', 239, '', 'bold'] ,} + +let g:airline#themes#understated#palette.accents = {'red': ['#FF0000', '', 88, '']} + +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#understated#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ ['#FFFFFF', '#1C1C1C', 15, 234, '' ], + \ ['#FFFFFF', '#262626', 15, 235, '' ], + \ ['#FFFFFF', '#303030', 15, 236, 'bold']) + diff --git a/.vim/autoload/airline/themes/wombat.vim b/.vim/autoload/airline/themes/wombat.vim new file mode 100644 index 0000000..39fdc4c --- /dev/null +++ b/.vim/autoload/airline/themes/wombat.vim @@ -0,0 +1,90 @@ +" vim-airline companion theme of Wombat +" looks great with wombat256 vim colorscheme + +" Normal mode +" [ guifg, guibg, ctermfg, ctermbg, opts ] +let s:N1 = [ '#141413' , '#CAE682' , 232 , 192 ] " mode +let s:N2 = [ '#CAE682' , '#32322F' , 192 , 236 ] " info +let s:N3 = [ '#CAE682' , '#242424' , 192 , 234 ] " statusline +let s:N4 = [ '#86CD74' , 113 ] " mode modified + +" Insert mode +let s:I1 = [ '#141413' , '#FDE76E' , 232 , 227 ] +let s:I2 = [ '#FDE76E' , '#32322F' , 227 , 236 ] +let s:I3 = [ '#FDE76E' , '#242424' , 227 , 234 ] +let s:I4 = [ '#FADE3E' , 221 ] + +" Visual mode +let s:V1 = [ '#141413' , '#B5D3F3' , 232 , 153 ] +let s:V2 = [ '#B5D3F3' , '#32322F' , 153 , 236 ] +let s:V3 = [ '#B5D3F3' , '#242424' , 153 , 234 ] +let s:V4 = [ '#7CB0E6' , 111 ] + +" Replace mode +let s:R1 = [ '#141413' , '#E5786D' , 232 , 173 ] +let s:R2 = [ '#E5786D' , '#32322F' , 173 , 236 ] +let s:R3 = [ '#E5786D' , '#242424' , 173 , 234 ] +let s:R4 = [ '#E55345' , 203 ] + +" Paste mode +let s:PA = [ '#94E42C' , 47 ] + +" Info modified +let s:IM = [ '#40403C' , 238 ] + +" Inactive mode +let s:IA = [ '#767676' , s:N3[1] , 243 , s:N3[3] , '' ] + +let g:airline#themes#wombat#palette = {} + +let g:airline#themes#wombat#palette.accents = { + \ 'red': [ '#E5786D' , '' , 203 , '' , '' ], + \ } + +let g:airline#themes#wombat#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) +let g:airline#themes#wombat#palette.normal_modified = { + \ 'airline_a': [ s:N1[0] , s:N4[0] , s:N1[2] , s:N4[1] , '' ] , + \ 'airline_b': [ s:N4[0] , s:IM[0] , s:N4[1] , s:IM[1] , '' ] , + \ 'airline_c': [ s:N4[0] , s:N3[1] , s:N4[1] , s:N3[3] , '' ] } + + +let g:airline#themes#wombat#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) +let g:airline#themes#wombat#palette.insert_modified = { + \ 'airline_a': [ s:I1[0] , s:I4[0] , s:I1[2] , s:I4[1] , '' ] , + \ 'airline_b': [ s:I4[0] , s:IM[0] , s:I4[1] , s:IM[1] , '' ] , + \ 'airline_c': [ s:I4[0] , s:N3[1] , s:I4[1] , s:N3[3] , '' ] } + + +let g:airline#themes#wombat#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) +let g:airline#themes#wombat#palette.visual_modified = { + \ 'airline_a': [ s:V1[0] , s:V4[0] , s:V1[2] , s:V4[1] , '' ] , + \ 'airline_b': [ s:V4[0] , s:IM[0] , s:V4[1] , s:IM[1] , '' ] , + \ 'airline_c': [ s:V4[0] , s:N3[1] , s:V4[1] , s:N3[3] , '' ] } + + +let g:airline#themes#wombat#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) +let g:airline#themes#wombat#palette.replace_modified = { + \ 'airline_a': [ s:R1[0] , s:R4[0] , s:R1[2] , s:R4[1] , '' ] , + \ 'airline_b': [ s:R4[0] , s:IM[0] , s:R4[1] , s:IM[1] , '' ] , + \ 'airline_c': [ s:R4[0] , s:N3[1] , s:R4[1] , s:N3[3] , '' ] } + + +let g:airline#themes#wombat#palette.insert_paste = { + \ 'airline_a': [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] , + \ 'airline_b': [ s:PA[0] , s:IM[0] , s:PA[1] , s:IM[1] , '' ] , + \ 'airline_c': [ s:PA[0] , s:N3[1] , s:PA[1] , s:N3[3] , '' ] } + + +let g:airline#themes#wombat#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) +let g:airline#themes#wombat#palette.inactive_modified = { + \ 'airline_c': [ s:N4[0] , '' , s:N4[1] , '' , '' ] } + + +if !get(g:, 'loaded_ctrlp', 0) + finish +endif +let g:airline#themes#wombat#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ [ '#DADADA' , '#242424' , 253 , 234 , '' ] , + \ [ '#DADADA' , '#40403C' , 253 , 238 , '' ] , + \ [ '#141413' , '#DADADA' , 232 , 253 , 'bold' ] ) + diff --git a/.vim/autoload/airline/themes/zenburn.vim b/.vim/autoload/airline/themes/zenburn.vim new file mode 100644 index 0000000..9883c21 --- /dev/null +++ b/.vim/autoload/airline/themes/zenburn.vim @@ -0,0 +1,44 @@ +let g:airline#themes#zenburn#palette = {} + +function! airline#themes#zenburn#refresh() + let g:airline#themes#zenburn#palette.accents = { + \ 'red': airline#themes#get_highlight('Constant'), + \ } + + let s:N1 = airline#themes#get_highlight2(['DbgCurrent', 'bg'], ['Folded', 'fg'], 'bold') + let s:N2 = airline#themes#get_highlight('Folded') + let s:N3 = airline#themes#get_highlight('NonText') + + let g:airline#themes#zenburn#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + let s:Nmod = airline#themes#get_highlight('Comment') + let g:airline#themes#zenburn#palette.normal_modified = { + \ 'airline_c': s:Nmod + \ } + + let s:I1 = airline#themes#get_highlight2(['DbgCurrent', 'bg'], ['String', 'fg'], 'bold') + let s:I2 = airline#themes#get_highlight2(['String', 'fg'], ['Folded', 'bg']) + let s:I3 = s:N3 + let g:airline#themes#zenburn#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) + let g:airline#themes#zenburn#palette.insert_modified = g:airline#themes#zenburn#palette.normal_modified + + let s:R1 = airline#themes#get_highlight2(['DbgCurrent', 'bg'], ['Comment', 'fg'], 'bold') + let s:R2 = airline#themes#get_highlight2(['Comment', 'fg'], ['Folded', 'bg']) + let s:R3 = s:N3 + let g:airline#themes#zenburn#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) + let g:airline#themes#zenburn#palette.replace_modified = g:airline#themes#zenburn#palette.normal_modified + + let s:V1 = airline#themes#get_highlight2(['DbgCurrent', 'bg'], ['Identifier', 'fg'], 'bold') + let s:V2 = airline#themes#get_highlight2(['Identifier', 'fg'], ['Folded', 'bg']) + let s:V3 = s:N3 + let g:airline#themes#zenburn#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) + let g:airline#themes#zenburn#palette.visual_modified = g:airline#themes#zenburn#palette.normal_modified + + let s:IA = airline#themes#get_highlight('NonText') + let g:airline#themes#zenburn#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) + let g:airline#themes#zenburn#palette.inactive_modified = { + \ 'airline_c': s:Nmod + \ } +endfunction + +call airline#themes#zenburn#refresh() + diff --git a/.vim/autoload/airline/util.vim b/.vim/autoload/airline/util.vim new file mode 100644 index 0000000..a04bd0b --- /dev/null +++ b/.vim/autoload/airline/util.vim @@ -0,0 +1,64 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +call airline#init#bootstrap() +let s:spc = g:airline_symbols.space + +function! airline#util#wrap(text, minwidth) + if a:minwidth > 0 && winwidth(0) < a:minwidth + return '' + endif + return a:text +endfunction + +function! airline#util#append(text, minwidth) + if a:minwidth > 0 && winwidth(0) < a:minwidth + return '' + endif + let prefix = s:spc == "\ua0" ? s:spc : s:spc.s:spc + return empty(a:text) ? '' : prefix.g:airline_left_alt_sep.s:spc.a:text +endfunction + +function! airline#util#prepend(text, minwidth) + if a:minwidth > 0 && winwidth(0) < a:minwidth + return '' + endif + return empty(a:text) ? '' : a:text.s:spc.g:airline_right_alt_sep.s:spc +endfunction + +if v:version >= 704 + function! airline#util#getwinvar(winnr, key, def) + return getwinvar(a:winnr, a:key, a:def) + endfunction +else + function! airline#util#getwinvar(winnr, key, def) + let winvals = getwinvar(a:winnr, '') + return get(winvals, a:key, a:def) + endfunction +endif + +if v:version >= 704 + function! airline#util#exec_funcrefs(list, ...) + for Fn in a:list + let code = call(Fn, a:000) + if code != 0 + return code + endif + endfor + return 0 + endfunction +else + function! airline#util#exec_funcrefs(list, ...) + " for 7.2; we cannot iterate the list, hence why we use range() + " for 7.3-[97, 328]; we cannot reuse the variable, hence the {} + for i in range(0, len(a:list) - 1) + let Fn{i} = a:list[i] + let code = call(Fn{i}, a:000) + if code != 0 + return code + endif + endfor + return 0 + endfunction +endif + diff --git a/.vim/autoload/xolox/easytags.vim b/.vim/autoload/xolox/easytags.vim new file mode 100644 index 0000000..b328e19 --- /dev/null +++ b/.vim/autoload/xolox/easytags.vim @@ -0,0 +1,910 @@ +" Vim script +" Author: Peter Odding +" Last Change: March 15, 2015 +" URL: http://peterodding.com/code/vim/easytags/ + +let g:xolox#easytags#version = '3.10' +let g:xolox#easytags#default_pattern_prefix = '\C\<' +let g:xolox#easytags#default_pattern_suffix = '\>' + +if !exists('s:timers_initialized') + let g:xolox#easytags#update_timer = xolox#misc#timer#resumable() + let g:xolox#easytags#highlight_timer = xolox#misc#timer#resumable() + let g:xolox#easytags#syntax_match_timer = xolox#misc#timer#resumable() + let g:xolox#easytags#syntax_keyword_timer = xolox#misc#timer#resumable() + let g:xolox#easytags#syntax_filter_stage_1_timer = xolox#misc#timer#resumable() + let g:xolox#easytags#syntax_filter_stage_2_timer = xolox#misc#timer#resumable() + let s:timers_initialized = 1 +endif + +" Plug-in initialization. {{{1 + +function! xolox#easytags#initialize(min_version) " {{{2 + " Check that the location of Exuberant Ctags has been configured or that the + " correct version of the program exists in one of its default locations. + if exists('g:easytags_cmd') && xolox#easytags#check_ctags_compatible(g:easytags_cmd, a:min_version) + return 1 + endif + if xolox#misc#os#is_win() + " FIXME The code below that searches the $PATH is not used on Windows at + " the moment because xolox#misc#path#which() generally produces absolute + " paths and on Windows these absolute paths tend to contain spaces which + " makes xolox#shell#execute_with_dll() fail. I've tried quoting the + " program name with double quotes but it fails just the same (it works + " with system() though). Anyway the problem of having multiple conflicting + " versions of Exuberant Ctags installed is not that relevant to Windows + " since it doesn't have a package management system. I still want to fix + " xolox#shell#execute_with_dll() though. + if xolox#easytags#check_ctags_compatible('ctags', a:min_version) + let g:easytags_cmd = 'ctags' + return 1 + endif + else + " Exuberant Ctags can be installed under several names: + " - On Ubuntu Linux, Exuberant Ctags is installed as `ctags-exuberant' + " (and possibly `ctags' but that one can't be trusted :-) + " - On Debian Linux, Exuberant Ctags is installed as `exuberant-ctags'. + " - On Free-BSD, Exuberant Ctags is installed as `exctags'. + " IIUC on Mac OS X the program /usr/bin/ctags is installed by default but + " unusable and when the user installs Exuberant Ctags in an alternative + " location, it doesn't come before /usr/bin/ctags in the search path. To + " solve this problem in a general way and to save every Mac user out there + " some frustration the plug-in will search the path and consider every + " possible location, meaning that as long as Exuberant Ctags is installed + " in the $PATH the plug-in should find it automatically. + for program in xolox#misc#path#which('exuberant-ctags', 'ctags-exuberant', 'ctags', 'exctags') + if xolox#easytags#check_ctags_compatible(program, a:min_version) + let g:easytags_cmd = program + return 1 + endif + endfor + endif +endfunction + +function! xolox#easytags#check_ctags_compatible(name, min_version) " {{{2 + " Not every executable out there named `ctags' is in fact Exuberant Ctags. + " This function makes sure it is because the easytags plug-in requires the + " --list-languages option (and more). + call xolox#misc#msg#debug("easytags.vim %s: Checking if Exuberant Ctags is installed as '%s'.", g:xolox#easytags#version, a:name) + " Make sure the given program is executable. + if !executable(a:name) + call xolox#misc#msg#debug("easytags.vim %s: Program '%s' is not executable!", g:xolox#easytags#version, a:name) + return 0 + endif + " Make sure the command exits without reporting an error. + let command = a:name . ' --version' + let result = xolox#misc#os#exec({'command': command, 'check': 0}) + if result['exit_code'] != 0 + call xolox#misc#msg#debug("easytags.vim %s: Command '%s' returned nonzero exit code %i!", g:xolox#easytags#version, a:name, result['exit_code']) + else + " Extract the version number from the output. + let pattern = 'Exuberant Ctags \zs\(\d\+\(\.\d\+\)*\|Development\)' + let g:easytags_ctags_version = matchstr(get(result['stdout'], 0, ''), pattern) + " Deal with development builds. + if g:easytags_ctags_version == 'Development' + call xolox#misc#msg#debug("easytags.vim %s: Assuming development build is compatible ..", g:xolox#easytags#version, a:name) + return 1 + endif + " Make sure the version is compatible. + if xolox#misc#version#at_least(a:min_version, g:easytags_ctags_version) + call xolox#misc#msg#debug("easytags.vim %s: Version is compatible! :-)", g:xolox#easytags#version) + return 1 + else + call xolox#misc#msg#debug("easytags.vim %s: Version is not compatible! :-(", g:xolox#easytags#version) + endif + endif + call xolox#misc#msg#debug("easytags.vim %s: Standard output of command: %s", g:xolox#easytags#version, string(result['stdout'])) + call xolox#misc#msg#debug("easytags.vim %s: Standard error of command: %s", g:xolox#easytags#version, string(result['stderr'])) + return 0 +endfunction + +function! xolox#easytags#register(global) " {{{2 + " Parse the &tags option and get a list of all tags files *including + " non-existing files* (this is why we can't just call tagfiles()). + let tagfiles = xolox#misc#option#split_tags(&tags) + let expanded = map(copy(tagfiles), 'resolve(expand(v:val))') + " Add the filename to the &tags option when the user hasn't done so already. + let tagsfile = a:global ? g:easytags_file : xolox#easytags#get_file_type_specific_tagsfile() + if index(expanded, xolox#misc#path#absolute(tagsfile)) == -1 + " This is a real mess because of bugs in Vim?! :let &tags = '...' doesn't + " work on UNIX and Windows, :set tags=... doesn't work on Windows. What I + " mean with "doesn't work" is that tagfiles() == [] after the :let/:set + " command even though the tags file exists! One easy way to confirm that + " this is a bug in Vim is to type :set tags= then press followed by + " . Now you entered the exact same value that the code below also did + " but suddenly Vim sees the tags file and tagfiles() != [] :-S + call add(tagfiles, tagsfile) + let value = xolox#misc#option#join_tags(tagfiles) + let cmd = (a:global ? 'set' : 'setl') . ' tags=' . escape(value, '\ ') + if xolox#misc#os#is_win() && v:version < 703 + " TODO How to clear the expression from Vim's status line? + call feedkeys(":" . cmd . "|let &ro=&ro\", 'n') + else + execute cmd + endif + endif +endfunction + +" Public interface through (automatic) commands. {{{1 + +function! xolox#easytags#autoload(event) " {{{2 + try + let session_loading = xolox#easytags#session_is_loading() && a:event == 'BufReadPost' + let do_update = xolox#misc#option#get('easytags_auto_update', 1) && !session_loading + let do_highlight = xolox#misc#option#get('easytags_auto_highlight', 1) && &eventignore !~? '\' + " Don't execute this function for unsupported file types (doesn't load + " the list of file types if updates and highlighting are both disabled). + if (do_update || do_highlight) && !empty(xolox#easytags#filetypes#canonicalize(&filetype)) + " Update entries for current file in tags file? + if do_update + let buffer_read = (a:event =~? 'BufReadPost') + let buffer_written = (a:event =~? 'BufWritePost') + if buffer_written || (buffer_read && xolox#misc#option#get('easytags_always_enabled', 0)) + call xolox#easytags#update(1, 0, []) + endif + endif + " Apply highlighting of tags to current buffer? + if do_highlight + if !exists('b:easytags_last_highlighted') + call xolox#easytags#highlight() + else + for tagfile in tagfiles() + if getftime(tagfile) > b:easytags_last_highlighted + call xolox#easytags#highlight() + break + endif + endfor + endif + let b:easytags_last_highlighted = localtime() + endif + endif + catch + call xolox#misc#msg#warn("easytags.vim %s: %s (at %s)", g:xolox#easytags#version, v:exception, v:throwpoint) + endtry +endfunction + +function! xolox#easytags#update(silent, filter_tags, filenames) " {{{2 + let async = xolox#misc#option#get('easytags_async', 0) + call g:xolox#easytags#update_timer.start() + try + let have_args = !empty(a:filenames) + let starttime = xolox#misc#timer#start() + let cfile = s:check_cfile(a:silent, a:filter_tags, have_args) + let command_line = s:prep_cmdline(cfile, a:filenames) + if empty(command_line) + return 0 + endif + " Pack all of the information required to update the tags in + " a Vim dictionary which is easy to serialize to a string. + let params = {} + let params['command'] = command_line + let params['ctags_version'] = g:easytags_ctags_version + let params['default_filetype'] = xolox#easytags#filetypes#canonicalize(&filetype) + let params['filter_tags'] = a:filter_tags || async + let params['have_args'] = have_args + let dynamic_tagsfile = xolox#easytags#get_dynamic_tagsfile() + if !empty(dynamic_tagsfile) + let params['tagsfile'] = dynamic_tagsfile + elseif !empty(g:easytags_by_filetype) + let params['directory'] = xolox#misc#path#absolute(g:easytags_by_filetype) + let params['filetypes'] = g:xolox#easytags#filetypes#ctags_to_vim + else + let params['tagsfile'] = xolox#easytags#get_global_tagsfile() + endif + if async + call xolox#misc#async#call({'function': 'xolox#easytags#update#with_vim', 'arguments': [params], 'callback': 'xolox#easytags#async_callback'}) + else + call s:report_results(xolox#easytags#update#with_vim(params), 0) + " When :UpdateTags was executed manually we'll refresh the dynamic + " syntax highlighting so that new tags are immediately visible. + if !a:silent && xolox#misc#option#get('easytags_auto_highlight', 1) + HighlightTags + endif + endif + return 1 + catch + call xolox#misc#msg#warn("easytags.vim %s: %s (at %s)", g:xolox#easytags#version, v:exception, v:throwpoint) + finally + call g:xolox#easytags#update_timer.stop() + endtry +endfunction + +function! s:check_cfile(silent, filter_tags, have_args) " {{{3 + if a:have_args + return '' + endif + let silent = a:silent || a:filter_tags + if xolox#misc#option#get('easytags_autorecurse', 0) + let cdir = xolox#easytags#utils#resolve(expand('%:p:h')) + if !isdirectory(cdir) + if silent | return '' | endif + throw "The directory of the current file doesn't exist yet!" + endif + return cdir + endif + let cfile = xolox#easytags#utils#resolve(expand('%:p')) + if cfile == '' || !filereadable(cfile) + if silent | return '' | endif + throw "You'll need to save your file before using :UpdateTags!" + elseif g:easytags_ignored_filetypes != '' && &ft =~ g:easytags_ignored_filetypes + if silent | return '' | endif + throw "The " . string(&ft) . " file type is explicitly ignored." + elseif empty(xolox#easytags#filetypes#canonicalize(&ft)) + if silent | return '' | endif + throw "Exuberant Ctags doesn't support the " . string(&ft) . " file type!" + endif + return cfile +endfunction + +function! s:prep_cmdline(cfile, arguments) " {{{3 + let vim_file_type = xolox#easytags#filetypes#canonicalize(&filetype) + let custom_languages = xolox#misc#option#get('easytags_languages', {}) + let language = get(custom_languages, vim_file_type, {}) + if empty(language) + let cmdline = [xolox#easytags#ctags_command()] + call add(cmdline, '--fields=+l') + call add(cmdline, '--c-kinds=+p') + call add(cmdline, '--c++-kinds=+p') + call add(cmdline, '--sort=no') + call add(cmdline, '-f-') + if xolox#misc#option#get('easytags_include_members', 0) + call add(cmdline, '--extra=+q') + endif + else + let program = get(language, 'cmd', xolox#easytags#ctags_command()) + if empty(program) + call xolox#misc#msg#warn("easytags.vim %s: No 'cmd' defined for language '%s', and also no global default!", g:xolox#easytags#version, vim_file_type) + return '' + endif + let cmdline = [program] + get(language, 'args', []) + call add(cmdline, xolox#misc#escape#shell(get(language, 'stdout_opt', '-f-'))) + endif + let have_args = 0 + if a:cfile != '' + if xolox#misc#option#get('easytags_autorecurse', 0) + call add(cmdline, empty(language) ? '-R' : xolox#misc#escape#shell(get(language, 'recurse_flag', '-R'))) + call add(cmdline, xolox#misc#escape#shell(a:cfile)) + else + if empty(language) + " TODO Should --language-force distinguish between C and C++? + " TODO --language-force doesn't make sense for JavaScript tags in HTML files? + let filetype = xolox#easytags#filetypes#to_ctags(vim_file_type) + call add(cmdline, xolox#misc#escape#shell('--language-force=' . filetype)) + endif + call add(cmdline, xolox#misc#escape#shell(a:cfile)) + endif + let have_args = 1 + else + for arg in a:arguments + if arg =~ '^-' + call add(cmdline, arg) + let have_args = 1 + else + let matches = split(expand(arg), "\n") + if !empty(matches) + call map(matches, 'xolox#misc#escape#shell(xolox#easytags#utils#canonicalize(v:val))') + call extend(cmdline, matches) + let have_args = 1 + endif + endif + endfor + endif + " No need to run Exuberant Ctags without any filename arguments! + return have_args ? join(cmdline) : '' +endfunction + +function! xolox#easytags#highlight() " {{{2 + " TODO This is a mess; Re-implement Python version in Vim script, benchmark, remove Python version. + try + call g:xolox#easytags#highlight_timer.start() + let filetype = xolox#easytags#filetypes#canonicalize(&filetype) + let tagkinds = get(s:tagkinds, filetype, []) + if exists('g:syntax_on') && !empty(tagkinds) && !exists('b:easytags_nohl') + let starttime = xolox#misc#timer#start() + let used_python = 0 + for tagkind in tagkinds + let hlgroup_tagged = tagkind.hlgroup . 'Tag' + " Define style on first run, clear highlighting on later runs. + if !hlexists(hlgroup_tagged) + execute 'highlight def link' hlgroup_tagged tagkind.hlgroup + else + execute 'syntax clear' hlgroup_tagged + endif + " Try to perform the highlighting using the fast Python script. + " TODO The tags files are read multiple times by the Python script + " within one run of xolox#easytags#highlight() + if s:highlight_with_python(hlgroup_tagged, tagkind) + let used_python = 1 + else + " Fall back to the slow and naive Vim script implementation. + if !exists('taglist') + " Get the list of tags when we need it and remember the results. + let ctags_filetypes = xolox#easytags#filetypes#find_ctags_aliases(filetype) + let filetypes_pattern = printf('^\(%s\)$', join(map(ctags_filetypes, 'xolox#misc#escape#pattern(v:val)'), '\|')) + call g:xolox#easytags#syntax_filter_stage_1_timer.start() + let taglist = filter(taglist('.'), "get(v:val, 'language', '') =~? filetypes_pattern") + call g:xolox#easytags#syntax_filter_stage_1_timer.stop() + endif + " Filter a copy of the list of tags to the relevant kinds. + if has_key(tagkind, 'tagkinds') + let filter = 'v:val.kind =~ tagkind.tagkinds' + else + let filter = tagkind.vim_filter + endif + call g:xolox#easytags#syntax_filter_stage_2_timer.start() + let matches = filter(copy(taglist), filter) + call g:xolox#easytags#syntax_filter_stage_2_timer.stop() + if matches != [] + " Convert matched tags to :syntax commands and execute them. + let use_keywords_when = xolox#misc#option#get('easytags_syntax_keyword', 'auto') + let has_default_pattern_prefix = (tagkind.pattern_prefix == g:xolox#easytags#default_pattern_prefix) + let has_default_pattern_suffix = (tagkind.pattern_suffix == g:xolox#easytags#default_pattern_suffix) + let has_non_default_patterns = !(has_default_pattern_prefix && has_default_pattern_suffix) + if use_keywords_when == 'always' || (use_keywords_when == 'auto' && !has_non_default_patterns) + " Vim's ":syntax keyword" command doesn't use the regular + " expression engine and the resulting syntax highlighting is + " therefor much faster. Because of this we use the syntax + " keyword command when 1) we can do so without sacrificing + " accuracy or 2) the user explicitly chose to sacrifice + " accuracy in order to make the highlighting faster. + call g:xolox#easytags#syntax_keyword_timer.start() + let keywords = {} + for tag in matches + if s:is_keyword_compatible(tag) + let keywords[tag.name] = 1 + endif + endfor + if !empty(keywords) + let template = 'syntax keyword %s %s containedin=ALLBUT,%s' + let command = printf(template, hlgroup_tagged, join(keys(keywords)), xolox#easytags#syntax_groups_to_ignore()) + call xolox#misc#msg#debug("easytags.vim %s: Executing command '%s'.", g:xolox#easytags#version, command) + execute command + " Remove the tags that we just highlighted from the list of + " tags that still need to be highlighted. + call filter(matches, "!s:is_keyword_compatible(v:val)") + endif + call g:xolox#easytags#syntax_keyword_timer.stop() + endif + if !empty(matches) + call g:xolox#easytags#syntax_match_timer.start() + let matches = xolox#misc#list#unique(map(matches, 'xolox#misc#escape#pattern(get(v:val, "name"))')) + let pattern = tagkind.pattern_prefix . '\%(' . join(matches, '\|') . '\)' . tagkind.pattern_suffix + let template = 'syntax match %s /%s/ containedin=ALLBUT,%s' + let command = printf(template, hlgroup_tagged, escape(pattern, '/'), xolox#easytags#syntax_groups_to_ignore()) + call xolox#misc#msg#debug("easytags.vim %s: Executing command '%s'.", g:xolox#easytags#version, command) + try + execute command + catch /^Vim\%((\a\+)\)\=:E339/ + let msg = "easytags.vim %s: Failed to highlight %i %s tags because pattern is too big! (%i KB)" + call xolox#misc#msg#warn(msg, g:xolox#easytags#version, len(matches), tagkind.hlgroup, len(pattern) / 1024) + endtry + call g:xolox#easytags#syntax_match_timer.stop() + endif + endif + endif + endfor + " Avoid flashing each highlighted buffer in front of the user when + " loading a session. + if !xolox#easytags#session_is_loading() + redraw + endif + let bufname = expand('%:p:~') + if bufname == '' + let bufname = 'unnamed buffer #' . bufnr('%') + endif + let msg = "easytags.vim %s: Highlighted tags in %s in %s%s." + call xolox#misc#timer#stop(msg, g:xolox#easytags#version, bufname, starttime, used_python ? " (using Python)" : "") + return 1 + endif + catch + call xolox#misc#msg#warn("easytags.vim %s: %s (at %s)", g:xolox#easytags#version, v:exception, v:throwpoint) + finally + call g:xolox#easytags#highlight_timer.stop() + endtry +endfunction + +function! s:is_keyword_compatible(tag) + let name = get(a:tag, 'name', '') + if !empty(name) + " Make sure the tag contains only `keyword characters' (included in the + " &iskeyword option) and is not longer than 80 characters (these + " limitations are documented under :help :syn-keyword). + if name =~ '^\k\+$' && len(name) <= 80 + " Make sure the tag doesn't conflict with one of the named options + " accepted by the `:syntax keyword' command (using these named options + " improperly, e.g. without a mandatory argument, will raise an error). + return !has_key(s:invalid_keywords, name) + endif + return 0 +endfunction + +" These are documented under :help E395, except for "contains" which is not +" documented as being forbidden but when used definitely triggers an error. +let s:invalid_keywords = { + \ 'cchar': 1, + \ 'conceal': 1, + \ 'contained': 1, + \ 'containedin': 1, + \ 'contains': 1, + \ 'nextgroup': 1, + \ 'skipempty': 1, + \ 'skipnl': 1, + \ 'skipwhite': 1, + \ 'transparent': 1, + \ } + +" Public supporting functions (might be useful to others). {{{1 + +function! xolox#easytags#ctags_command() " {{{2 + let program = xolox#misc#option#get('easytags_cmd') + if !empty(program) + let options = xolox#misc#option#get('easytags_opts') + if !empty(options) + let command_line = [program] + call extend(command_line, map(copy(options), 'xolox#misc#escape#shell(expand(v:val))')) + let program = join(command_line) + endif + return program + endif + return '' +endfunction + +function! xolox#easytags#get_tagsfile() " {{{2 + " Get the absolute pathname of the tags file to use. This function + " automatically selects the best choice from the following options (in + " descending order of preference): + " + " 1. Dynamic tags files (see `xolox#easytags#get_dynamic_tagsfile()`). + " 2. File type specific tags files (see `xolox#easytags#get_file_type_specific_tagsfile()`). + " 3. The global tags file (see `xolox#easytags#get_global_tagsfile()`). + " + " Returns the absolute pathname of the selected tags file. + " + " This function is no longer used by the vim-easytags plug-in itself because + " the vim-easytags plug-in needs to differentiate between the different + " types of tags files in every place where it deals with tags files. Because + " this is an externally callable function it is unclear to me if other code + " depends on it, this is the reason why I haven't removed it yet. + let tagsfile = xolox#easytags#get_dynamic_tagsfile() + if empty(tagsfile) + let tagsfile = xolox#easytags#get_file_type_specific_tagsfile() + endif + if empty(tagsfile) + let tagsfile = xolox#easytags#get_global_tagsfile() + endif + return tagsfile +endfunction + +function! xolox#easytags#get_dynamic_tagsfile() " {{{2 + " Get the pathname of the dynamic tags file to use. If the user configured + " dynamic tags files this function returns the pathname of the applicable + " dynamic tags file (which may not exist yet), otherwise it returns an empty + " string. + let tagsfile = '' + " Look for a suitable project specific tags file? + let dynamic_files = xolox#misc#option#get('easytags_dynamic_files', 0) + if dynamic_files == 1 + let tagsfile = get(tagfiles(), 0, '') + elseif dynamic_files == 2 + let tagsfile = xolox#misc#option#eval_tags(&tags, 1) + let directory = fnamemodify(tagsfile, ':h') + if filewritable(directory) != 2 + " If the directory of the dynamic tags file is not writable, we fall + " back to another type of tags file. + call xolox#misc#msg#warn("easytags.vim %s: Dynamic tags files enabled but %s not writable so falling back.", g:xolox#easytags#version, directory) + let tagsfile = '' + endif + endif + if !empty(tagsfile) + return s:select_tags_file(tagsfile, 'dynamic') + endif + return '' +endfunction + +function! xolox#easytags#get_file_type_specific_tagsfile() " {{{2 + " Get the pathname of the file type specific tags file to use. If the user + " configured file type specific tags files this function returns the + " pathname of the applicable file type specific tags file (which may not + " exist yet), otherwise it returns an empty string. + let vim_file_type = xolox#easytags#filetypes#canonicalize(&filetype) + if !empty(g:easytags_by_filetype) && !empty(vim_file_type) + let directory = xolox#misc#path#absolute(g:easytags_by_filetype) + let tagsfile = xolox#misc#path#merge(directory, vim_file_type) + if !empty(tagsfile) + return s:select_tags_file(tagsfile, 'file type specific') + endif + endif + return '' +endfunction + +function! xolox#easytags#get_global_tagsfile() " {{{2 + " Get the pathname of the global tags file. Returns the absolute pathname of + " the global tags file. + let tagsfile = xolox#misc#option#get('easytags_file') + return s:select_tags_file(expand(tagsfile), 'global') +endfunction + +function! s:select_tags_file(tagsfile, kind) " {{{2 + " If the selected tags file exists, make sure its writable. Also provide the + " user with feedback about the tags file selection process. + if filereadable(a:tagsfile) && filewritable(a:tagsfile) != 1 + let message = "The %s tags file %s isn't writable!" + throw printf(message, a:kind, fnamemodify(a:tagsfile, ':~')) + endif + " Provide the user with feedback about the tags file selection process. + call xolox#misc#msg#debug("easytags.vim %s: Selected %s tags file %s.", g:xolox#easytags#version, a:kind, a:tagsfile) + " Canonicalize the tags file's pathname. + return xolox#misc#path#absolute(a:tagsfile) +endfunction + +function! xolox#easytags#syntax_groups_to_ignore() " {{{2 + " Get a string matching the syntax groups where dynamic highlighting should + " *not* apply. This is complicated by the fact that Vim has a tendency to do + " this: + " + " Vim(syntax):E409: Unknown group name: doxygen.* + " + " This happens when a group wildcard doesn't match *anything*. Why does Vim + " always have to make everything so complicated? :-( + let groups = ['.*String.*', '.*Comment.*'] + for group_name in ['cIncluded', 'cCppOut2', 'cCppInElse2', 'cCppOutIf2', 'pythonDocTest', 'pythonDocTest2'] + if hlexists(group_name) + call add(groups, group_name) + endif + endfor + " Doxygen is an "add-on syntax script", it's usually used in combination: + " :set syntax=c.doxygen + " It gets special treatment because it defines a dozen or so groups :-) + if hlexists('doxygenComment') + call add(groups, 'doxygen.*') + endif + return join(groups, ',') +endfunction + +function! xolox#easytags#async_callback(response) " {{{2 + if has_key(a:response, 'result') + call s:report_results(a:response['result'], 1) + else + call xolox#misc#msg#warn("easytags.vim %s: Asynchronous tags file update failed! (%s at %s)", g:xolox#easytags#version, a:response['exception'], a:response['throwpoint']) + endif +endfunction + +function! xolox#easytags#session_is_loading() " {{{2 + return exists('g:SessionLoad') +endfunction + +function! xolox#easytags#disable_automatic_updates() " {{{2 + let s:easytags_auto_update_save = xolox#misc#option#get('easytags_auto_update', 1) + let g:easytags_auto_update = 0 +endfunction + +function! xolox#easytags#restore_automatic_updates() " {{{2 + if exists('s:easytags_auto_update_save') + let g:easytags_auto_update = s:easytags_auto_update_save + unlet s:easytags_auto_update_save + endif +endfunction + +function! xolox#easytags#why_so_slow() " {{{2 + let message = [printf("easytags.vim %s: Timings since you started Vim:", g:xolox#easytags#version)] + call add(message, printf(" - %s seconds updating tags", g:xolox#easytags#update_timer.format())) + call add(message, printf(" - %s seconds highlighting tags", g:xolox#easytags#highlight_timer.format())) + call add(message, printf(" - %s seconds highlighting tags using ':syntax match')", g:xolox#easytags#syntax_match_timer.format())) + call add(message, printf(" - %s seconds highlighting tags using ':syntax keyword')", g:xolox#easytags#syntax_keyword_timer.format())) + call add(message, printf(" - %s seconds filtering tags for highlighting (stage 1)", g:xolox#easytags#syntax_filter_stage_1_timer.format())) + call add(message, printf(" - %s seconds filtering tags for highlighting (stage 2)", g:xolox#easytags#syntax_filter_stage_2_timer.format())) + echo join(message, "\n") +endfunction + +" Public API for definition of file type specific dynamic syntax highlighting. {{{1 + +function! xolox#easytags#define_tagkind(object) " {{{2 + if !has_key(a:object, 'pattern_prefix') + let a:object.pattern_prefix = g:xolox#easytags#default_pattern_prefix + endif + if !has_key(a:object, 'pattern_suffix') + let a:object.pattern_suffix = g:xolox#easytags#default_pattern_suffix + endif + if !has_key(s:tagkinds, a:object.filetype) + let s:tagkinds[a:object.filetype] = [] + endif + call add(s:tagkinds[a:object.filetype], a:object) +endfunction + +" Miscellaneous script-local functions. {{{1 + +function! s:report_results(response, async) " {{{2 + if !xolox#misc#option#get('easytags_suppress_report', 0) + let actions = [] + if a:response['num_updated'] > 0 + call add(actions, printf('updated %i tags', a:response['num_updated'])) + endif + if a:response['num_filtered'] > 0 + call add(actions, printf('filtered %i invalid tags', a:response['num_filtered'])) + endif + if !empty(actions) + let function = a:async ? 'xolox#misc#msg#debug' : 'xolox#misc#msg#info' + let actions_string = xolox#misc#str#ucfirst(join(actions, ' and ')) + let command_type = a:async ? 'asynchronously' : 'synchronously' + call call(function, ["easytags.vim %s: %s in %s (%s).", g:xolox#easytags#version, actions_string, a:response['elapsed_time'], command_type]) + endif + endif +endfunction + +function! s:python_available() " {{{2 + if !exists('s:is_python_available') + try + execute 'pyfile' fnameescape(g:easytags_python_script) + redir => output + silent python easytags_ping() + redir END + let s:is_python_available = (output =~ 'it works!') + catch + let s:is_python_available = 0 + endtry + endif + return s:is_python_available +endfunction + +function! s:highlight_with_python(syntax_group, tagkind) " {{{2 + if xolox#misc#option#get('easytags_python_enabled', 1) && s:python_available() + " Gather arguments for Python function. + let context = {} + let context['tagsfiles'] = tagfiles() + let context['syntaxgroup'] = a:syntax_group + " TODO This doesn't support file type groups! + let context['filetype'] = xolox#easytags#filetypes#to_ctags(xolox#easytags#filetypes#canonicalize(&filetype)) + let context['tagkinds'] = get(a:tagkind, 'tagkinds', '') + let context['prefix'] = get(a:tagkind, 'pattern_prefix', '') + let context['suffix'] = get(a:tagkind, 'pattern_suffix', '') + let context['filters'] = get(a:tagkind, 'python_filter', {}) + let context['ignoresyntax'] = xolox#easytags#syntax_groups_to_ignore() + " Call the Python function and intercept the output. + try + redir => commands + python import vim + silent python print easytags_gensyncmd(**vim.eval('context')) + redir END + execute commands + return 1 + catch + redir END + " If the Python script raised an error, don't run it again. + let g:easytags_python_enabled = 0 + endtry + endif + return 0 +endfunction + +" Built-in file type & tag kind definitions. {{{1 + +" Don't bother redefining everything below when this script is sourced again. +if exists('s:tagkinds') + finish +endif + +let s:tagkinds = {} + +" Enable line continuation. +let s:cpo_save = &cpo +set cpo&vim + +" Lua. {{{2 + +call xolox#easytags#define_tagkind({ + \ 'filetype': 'lua', + \ 'hlgroup': 'luaFunc', + \ 'tagkinds': 'f'}) + +" C and C++. {{{2 +" +" C and C++ are both treated as C++, for details refer +" to https://github.com/xolox/vim-easytags/issues/91. + +call xolox#easytags#define_tagkind({ + \ 'filetype': 'cpp', + \ 'hlgroup': 'cType', + \ 'tagkinds': '[cgstu]'}) + +call xolox#easytags#define_tagkind({ + \ 'filetype': 'cpp', + \ 'hlgroup': 'cEnum', + \ 'tagkinds': 'e'}) + +call xolox#easytags#define_tagkind({ + \ 'filetype': 'cpp', + \ 'hlgroup': 'cPreProc', + \ 'tagkinds': 'd'}) + +call xolox#easytags#define_tagkind({ + \ 'filetype': 'cpp', + \ 'hlgroup': 'cFunction', + \ 'tagkinds': '[fp]'}) + +highlight def link cEnum Identifier +highlight def link cFunction Function + +if xolox#misc#option#get('easytags_include_members', 0) + call xolox#easytags#define_tagkind({ + \ 'filetype': 'cpp', + \ 'hlgroup': 'cMember', + \ 'tagkinds': 'm'}) + highlight def link cMember Identifier +endif + +" PHP. {{{2 + +call xolox#easytags#define_tagkind({ + \ 'filetype': 'php', + \ 'hlgroup': 'phpFunctions', + \ 'tagkinds': 'f', + \ 'pattern_suffix': '(\@='}) + +call xolox#easytags#define_tagkind({ + \ 'filetype': 'php', + \ 'hlgroup': 'phpClasses', + \ 'tagkinds': 'c'}) + +" Vim script. {{{2 + +call xolox#easytags#define_tagkind({ + \ 'filetype': 'vim', + \ 'hlgroup': 'vimAutoGroup', + \ 'tagkinds': 'a'}) + +highlight def link vimAutoGroup vimAutoEvent + +call xolox#easytags#define_tagkind({ + \ 'filetype': 'vim', + \ 'hlgroup': 'vimCommand', + \ 'tagkinds': 'c', + \ 'pattern_prefix': '\(\(^\|\s\):\?\)\@<=', + \ 'pattern_suffix': '\(!\?\(\s\|$\)\)\@='}) + +" Exuberant Ctags doesn't mark script local functions in Vim scripts as +" "static". When your tags file contains search patterns this plug-in can use +" those search patterns to check which Vim script functions are defined +" globally and which script local. + +call xolox#easytags#define_tagkind({ + \ 'filetype': 'vim', + \ 'hlgroup': 'vimFuncName', + \ 'vim_filter': 'v:val.kind ==# "f" && get(v:val, "cmd", "") !~? ''\w\|\\w|\bs:\w)' }, + \ 'pattern_prefix': '\C\%(\\)\@\w\|\\w|\bs:\w)' }, + \ 'pattern_prefix': '\C\%(\\)'}) + +highlight def link vimScriptFuncName vimFuncName + +" Python. {{{2 + +call xolox#easytags#define_tagkind({ + \ 'filetype': 'python', + \ 'hlgroup': 'pythonFunction', + \ 'tagkinds': 'f', + \ 'pattern_prefix': '\%(\\|\s\|&\|^\)\@<=\<'}) + +highlight def link perlFunctionTag Operator + +" }}} + +" Restore "cpoptions". +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/easytags/filetypes.vim b/.vim/autoload/xolox/easytags/filetypes.vim new file mode 100644 index 0000000..4749a9d --- /dev/null +++ b/.vim/autoload/xolox/easytags/filetypes.vim @@ -0,0 +1,139 @@ +" Vim script +" Author: Peter Odding +" Last Change: November 13, 2014 +" URL: http://peterodding.com/code/vim/easytags/ + +" This submodule of the vim-easytags plug-in translates between back and forth +" between Vim file types and Exuberant Ctags languages. This is complicated by +" a couple of things: +" +" - Vim allows file types to be combined like `filetype=c.doxygen'. +" +" - Some file types need to be canonicalized, for example the `htmldjango' +" Vim file type should be treated as the `html' Exuberant Ctags language. + +" Whether we've run Exuberant Ctags to discover the supported file types. +let s:discovered_filetypes = 0 + +" List of supported Vim file types. +let s:supported_filetypes = [] + +" Mapping of Exuberant Ctags languages to Vim file types and vice versa. +let g:xolox#easytags#filetypes#ctags_to_vim = {} +let g:xolox#easytags#filetypes#vim_to_ctags = {} + +" Mapping of Vim file types to canonical file types. +let s:canonical_filetypes = {} + +" Mapping of canonical Vim file types to their groups. +let s:filetype_groups = {} + +function! xolox#easytags#filetypes#add_group(...) " {{{1 + " Define a group of Vim file types whose tags should be stored together. + let canonical_filetype = tolower(a:1) + let other_filetypes = map(a:000[1:], 'tolower(v:val)') + let s:filetype_groups[canonical_filetype] = other_filetypes + for ft in other_filetypes + let s:canonical_filetypes[ft] = canonical_filetype + endfor +endfunction + +function! xolox#easytags#filetypes#add_mapping(vim_filetype, ctags_language) " {{{1 + " Map an Exuberant Ctags language to a Vim file type and vice versa. + let vim_filetype = tolower(a:vim_filetype) + let ctags_language = tolower(a:ctags_language) + let g:xolox#easytags#filetypes#ctags_to_vim[ctags_language] = vim_filetype + let g:xolox#easytags#filetypes#vim_to_ctags[vim_filetype] = ctags_language +endfunction + +function! xolox#easytags#filetypes#to_vim(ctags_language) " {{{1 + " Translate an Exuberant Ctags language to a Vim file type. + let ctags_language = tolower(a:ctags_language) + return get(g:xolox#easytags#filetypes#ctags_to_vim, ctags_language, ctags_language) +endfunction + +function! xolox#easytags#filetypes#to_ctags(vim_filetype) " {{{1 + " Translate a Vim file type to an Exuberant Ctags language. + let vim_filetype = tolower(a:vim_filetype) + return get(g:xolox#easytags#filetypes#vim_to_ctags, vim_filetype, vim_filetype) +endfunction + +function! xolox#easytags#filetypes#canonicalize(vim_filetype_value) " {{{1 + " Select a canonical, supported Vim file type given a value of &filetype. + call s:discover_supported_filetypes() + " Split the possibly combined Vim file type into individual file types. + for filetype in split(tolower(a:vim_filetype_value), '\.') + " Canonicalize the Vim file type. + let filetype = get(s:canonical_filetypes, filetype, filetype) + if index(s:supported_filetypes, filetype) >= 0 + return filetype + endif + endfor + return '' +endfunction + +function! xolox#easytags#filetypes#find_ctags_aliases(canonical_vim_filetype) " {{{1 + " Find Exuberant Ctags languages that correspond to a canonical, supported Vim file type. + if has_key(s:filetype_groups, a:canonical_vim_filetype) + let filetypes = [a:canonical_vim_filetype] + call extend(filetypes, s:filetype_groups[a:canonical_vim_filetype]) + return map(filetypes, 'xolox#easytags#filetypes#to_ctags(v:val)') + else + return [xolox#easytags#filetypes#to_ctags(a:canonical_vim_filetype)] + endif +endfunction + +function! s:discover_supported_filetypes() " {{{1 + " Initialize predefined groups & mappings and discover supported file types. + if !s:discovered_filetypes + " Discover the file types supported by Exuberant Ctags? + let command_line = xolox#easytags#ctags_command() + if !empty(command_line) + let starttime = xolox#misc#timer#start() + let command_line .= ' --list-languages' + for line in xolox#misc#os#exec({'command': command_line})['stdout'] + if line =~ '\[disabled\]$' + " Ignore languages that have been explicitly disabled using `--languages=-Vim'. + continue + elseif line =~ '^\w\S*$' + call add(s:supported_filetypes, xolox#easytags#filetypes#to_vim(xolox#misc#str#trim(line))) + elseif line =~ '\S' + call xolox#misc#msg#warn("easytags.vim %s: Failed to parse line of output from ctags --list-languages: %s", g:xolox#easytags#version, string(line)) + endif + endfor + let msg = "easytags.vim %s: Retrieved %i supported languages in %s." + call xolox#misc#timer#stop(msg, g:xolox#easytags#version, len(s:supported_filetypes), starttime) + endif + " Add file types supported by language specific programs. + call extend(s:supported_filetypes, keys(xolox#misc#option#get('easytags_languages', {}))) + " Don't run s:discover_supported_filetypes() more than once. + let s:discovered_filetypes = 1 + endif +endfunction + +" }}}1 + +" Define the default file type groups. It's important that C normalizes to C++ +" because of the following points: +" +" - Vim and Exuberant Ctags consistently treat *.h files as C++. I guess this +" is because A) the filename extension is ambiguous and B) C++ is a +" superset of C so the mapping makes sense. +" +" - Because of the above point, when you use file type specific tags files +" and you're editing C source code you'll be missing everything defined in +" your *.h files. Depending on your programming style those tags might be +" redundant or they might not be. +" +" To solve this dilemma the vim-easytags plug-in groups the C and C++ file +" types together and tells Exuberant Ctags to treat it all as C++ because C++ +" is a superset of C. +call xolox#easytags#filetypes#add_group('cpp', 'c') +call xolox#easytags#filetypes#add_group('html', 'htmldjango') + +" Define the default file type mappings. +call xolox#easytags#filetypes#add_mapping('cpp', 'c++') +call xolox#easytags#filetypes#add_mapping('cs', 'c#') +call xolox#easytags#filetypes#add_mapping(exists('g:filetype_asp') ? g:filetype_asp : 'aspvbs', 'asp') + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/easytags/update.vim b/.vim/autoload/xolox/easytags/update.vim new file mode 100644 index 0000000..d35a338 --- /dev/null +++ b/.vim/autoload/xolox/easytags/update.vim @@ -0,0 +1,288 @@ +" Vim script +" Author: Peter Odding +" Last Change: August 8, 2014 +" URL: http://peterodding.com/code/vim/easytags/ + +" This Vim auto-load script contains the parts of vim-easytags that are used +" to update tags files. The vim-easytags plug-in can run this code in one of +" two ways: +" +" - Synchronously inside your main Vim process, blocking your editing session +" during the tags file update (not very nice as your tags files get larger +" and updating them becomes slower). +" +" - Asynchronously in a separate Vim process to update a tags file in the +" background without blocking your editing session (this provides a much +" nicer user experience). +" +" This code is kept separate from the rest of the plug-in to force me to use +" simple form of communication (a Vim dictionary with all of the state +" required to update tags files) which in the future can be used to implement +" an alternative update mechanism in a faster scripting language (for example +" I could translate the Vim dictionary to JSON and feed it to Python). + +function! xolox#easytags#update#with_vim(params) " {{{1 + let counters = {} + let starttime = xolox#misc#timer#start() + call xolox#misc#msg#debug("easytags.vim %s: Executing %s.", g:xolox#easytags#version, a:params['command']) + let lines = xolox#misc#os#exec({'command': a:params['command']})['stdout'] + let entries = xolox#easytags#update#parse_entries(lines) + let counters['num_updated'] = len(entries) + let directory = get(a:params, 'directory', '') + let cache = s:create_cache() + if !empty(directory) + let counters['num_filtered'] = s:save_by_filetype(a:params['filter_tags'], [], entries, cache, directory) + else + let counters['num_filtered'] = s:filter_merge_tags(a:params['filter_tags'], a:params['tagsfile'], entries, cache) + endif + let counters['elapsed_time'] = xolox#misc#timer#convert(starttime) + return counters +endfunction + +function! xolox#easytags#update#convert_by_filetype(undo) " {{{1 + try + if empty(g:easytags_by_filetype) + throw "Please set g:easytags_by_filetype before running :TagsByFileType!" + endif + let global_tagsfile = expand(g:easytags_file) + let disabled_tagsfile = global_tagsfile . '.disabled' + if !a:undo + let [headers, entries] = xolox#easytags#update#read_tagsfile(global_tagsfile) + call s:save_by_filetype(0, headers, entries) + call rename(global_tagsfile, disabled_tagsfile) + let msg = "easytags.vim %s: Finished copying tags from %s to %s! Note that your old tags file has been renamed to %s instead of deleting it, should you want to restore it." + call xolox#misc#msg#info(msg, g:xolox#easytags#version, g:easytags_file, g:easytags_by_filetype, disabled_tagsfile) + else + let headers = [] + let all_entries = [] + for tagsfile in split(glob(g:easytags_by_filetype . '/*'), '\n') + let [headers, entries] = xolox#easytags#update#read_tagsfile(tagsfile) + call extend(all_entries, entries) + endfor + call xolox#easytags#update#write_tagsfile(global_tagsfile, headers, all_entries) + call xolox#misc#msg#info("easytags.vim %s: Finished copying tags from %s to %s!", g:xolox#easytags#version, g:easytags_by_filetype, g:easytags_file) + endif + catch + call xolox#misc#msg#warn("easytags.vim %s: %s (at %s)", g:xolox#easytags#version, v:exception, v:throwpoint) + endtry +endfunction + +function! s:filter_merge_tags(filter_tags, tagsfile, output, cache) " {{{1 + let [headers, entries] = xolox#easytags#update#read_tagsfile(a:tagsfile) + let tagged_files = s:find_tagged_files(a:output, a:cache) + if !empty(tagged_files) + call filter(entries, '!has_key(tagged_files, a:cache.canonicalize(v:val[1]))') + endif + " Filter tags for non-existing files? + let count_before_filter = len(entries) + if a:filter_tags + call filter(entries, 'a:cache.exists(v:val[1])') + endif + let num_filtered = count_before_filter - len(entries) + " Merge the old and new tags. + call extend(entries, a:output) + " Now we're ready to save the tags file. + if !xolox#easytags#update#write_tagsfile(a:tagsfile, headers, entries) + let msg = "Failed to write filtered tags file %s!" + throw printf(msg, fnamemodify(a:tagsfile, ':~')) + endif + return num_filtered +endfunction + +function! s:find_tagged_files(entries, cache) " {{{1 + let tagged_files = {} + for entry in a:entries + let filename = a:cache.canonicalize(entry[1]) + if filename != '' + if !has_key(tagged_files, filename) + let tagged_files[filename] = 1 + endif + endif + endfor + return tagged_files +endfunction + +function! s:save_by_filetype(filter_tags, headers, entries, cache, directory) " {{{1 + let filetypes = {} + let num_invalid = 0 + let num_filtered = 0 + for entry in a:entries + let ctags_ft = matchstr(entry[4], '^language:\zs\S\+$') + if empty(ctags_ft) + " TODO This triggers on entries where the pattern contains tabs. The interesting thing is that Vim reads these entries fine... Fix it in xolox#easytags#update#read_tagsfile()? + let num_invalid += 1 + if &vbs >= 1 + call xolox#misc#msg#debug("easytags.vim %s: Skipping tag without 'language:' field: %s", + \ g:xolox#easytags#version, string(entry)) + endif + else + let vim_ft = xolox#easytags#filetypes#to_vim(ctags_ft) + if !has_key(filetypes, vim_ft) + let filetypes[vim_ft] = [] + endif + call add(filetypes[vim_ft], entry) + endif + endfor + if num_invalid > 0 + call xolox#misc#msg#warn("easytags.vim %s: Skipped %i lines without 'language:' tag!", g:xolox#easytags#version, num_invalid) + endif + let directory = xolox#misc#path#absolute(a:directory) + for vim_ft in keys(filetypes) + let tagsfile = xolox#misc#path#merge(directory, vim_ft) + let existing = filereadable(tagsfile) + call xolox#misc#msg#debug("easytags.vim %s: Writing %s tags to %s tags file %s.", + \ g:xolox#easytags#version, len(filetypes[vim_ft]), + \ existing ? "existing" : "new", tagsfile) + if !existing + call xolox#easytags#update#write_tagsfile(tagsfile, a:headers, filetypes[vim_ft]) + else + let num_filtered += s:filter_merge_tags(a:filter_tags, tagsfile, filetypes[vim_ft], a:cache) + endif + endfor + return num_filtered +endfunction + +function! xolox#easytags#update#read_tagsfile(tagsfile) " {{{1 + " I'm not sure whether this is by design or an implementation detail but + " it's possible for the "!_TAG_FILE_SORTED" header to appear after one or + " more tags and Vim will apparently still use the header! For this reason + " the xolox#easytags#update#write_tagsfile() function should also recognize it, + " otherwise Vim might complain with "E432: Tags file not sorted". + let headers = [] + let entries = [] + let num_invalid = 0 + if filereadable(a:tagsfile) + let lines = readfile(a:tagsfile) + else + let lines = [] + endif + for line in lines + if line =~# '^!_TAG_' + call add(headers, line) + else + let entry = xolox#easytags#update#parse_entry(line) + if !empty(entry) + call add(entries, entry) + else + let num_invalid += 1 + endif + endif + endfor + if num_invalid > 0 + call xolox#misc#msg#warn("easytags.vim %s: Ignored %i invalid line(s) in %s!", g:xolox#easytags#version, num_invalid, a:tagsfile) + endif + return [headers, entries] +endfunction + +function! xolox#easytags#update#parse_entry(line) " {{{1 + let fields = split(a:line, '\t') + return len(fields) >= 3 ? fields : [] +endfunction + +function! xolox#easytags#update#parse_entries(lines) " {{{1 + call map(a:lines, 'xolox#easytags#update#parse_entry(v:val)') + return filter(a:lines, '!empty(v:val)') +endfunction + +function! xolox#easytags#update#write_tagsfile(tagsfile, headers, entries) " {{{1 + " This function always sorts the tags file but understands "foldcase". + let sort_order = 0 + let sort_header_present = 0 + let sort_header_pattern = '^!_TAG_FILE_SORTED\t\zs\d' + " Discover the sort order defined in the tags file headers. + let i = 0 + for line in a:headers + let match = matchstr(line, sort_header_pattern) + if !empty(match) + let sort_header_present = 1 + let sort_order = match + 0 + if sort_order == 0 + let sort_order = 2 + let a:headers[i] = substitute(line, sort_header_pattern, '2', '') + endif + endif + endfor + if !sort_header_present + " If no sorting is defined in the tags file headers we default to + " "foldcase" sorting and add the header. + let sort_order = 2 + call add(a:headers, "!_TAG_FILE_SORTED\t2\t/0=unsorted, 1=sorted, 2=foldcase/") + endif + call xolox#easytags#update#join_entries(a:entries) + if sort_order == 1 + call sort(a:entries) + else + call sort(a:entries, function('xolox#easytags#update#foldcase_compare')) + endif + let lines = [] + if xolox#misc#os#is_win() + " Exuberant Ctags on Windows requires \r\n but Vim's writefile() doesn't add them! + for line in a:headers + call add(lines, line . "\r") + endfor + for line in a:entries + call add(lines, line . "\r") + endfor + else + call extend(lines, a:headers) + call extend(lines, a:entries) + endif + " Make sure the directory exists. + let directory = fnamemodify(a:tagsfile, ':h') + if !isdirectory(directory) + call mkdir(directory, 'p') + endif + " Write the new contents to a temporary file and atomically rename the + " temporary file into place while preserving the file's permissions. + return xolox#misc#perm#update(a:tagsfile, lines) +endfunction + +function! s:enumerate(list) + let items = [] + let index = 0 + for item in a:list + call add(items, [index, item]) + let index += 1 + endfor + return items +endfunction + +function! xolox#easytags#update#join_entry(value) " {{{1 + return type(a:value) == type([]) ? join(a:value, "\t") : a:value +endfunction + +function! xolox#easytags#update#join_entries(values) " {{{1 + call map(a:values, 'xolox#easytags#update#join_entry(v:val)') + return filter(a:values, '!empty(v:val)') +endfunction + +function! xolox#easytags#update#foldcase_compare(a, b) " {{{1 + let a = toupper(a:a) + let b = toupper(a:b) + return a == b ? 0 : a ># b ? 1 : -1 +endfunction + +function! s:create_cache() " {{{1 + let cache = {'canonicalize_cache': {}, 'exists_cache': {}} + function cache.canonicalize(pathname) dict + let cache = self['canonicalize_cache'] + if !empty(a:pathname) + if !has_key(cache, a:pathname) + let cache[a:pathname] = xolox#easytags#utils#canonicalize(a:pathname) + endif + return cache[a:pathname] + endif + return '' + endfunction + function cache.exists(pathname) dict + let cache = self['exists_cache'] + if !empty(a:pathname) + if !has_key(cache, a:pathname) + let cache[a:pathname] = filereadable(a:pathname) + endif + return cache[a:pathname] + endif + return 0 + endfunction + return cache +endfunction diff --git a/.vim/autoload/xolox/easytags/utils.vim b/.vim/autoload/xolox/easytags/utils.vim new file mode 100644 index 0000000..a88c7a8 --- /dev/null +++ b/.vim/autoload/xolox/easytags/utils.vim @@ -0,0 +1,20 @@ +" Vim script +" Author: Peter Odding +" Last Change: June 20, 2014 +" URL: http://peterodding.com/code/vim/easytags/ + +" Utility functions for vim-easytags. + +function! xolox#easytags#utils#canonicalize(pathname) + if !empty(a:pathname) + return xolox#misc#path#absolute(xolox#easytags#utils#resolve(a:pathname)) + endif + return a:pathname +endfunction + +function! xolox#easytags#utils#resolve(pathname) + if !empty(a:pathname) && xolox#misc#option#get('easytags_resolve_links', 0) + return resolve(a:pathname) + endif + return a:pathname +endfunction diff --git a/.vim/autoload/xolox/misc.vim b/.vim/autoload/xolox/misc.vim new file mode 100644 index 0000000..72b12e0 --- /dev/null +++ b/.vim/autoload/xolox/misc.vim @@ -0,0 +1,7 @@ +" The version of my miscellaneous scripts. +" +" Author: Peter Odding +" Last Change: March 15, 2015 +" URL: http://peterodding.com/code/vim/misc/ + +let g:xolox#misc#version = '1.17.2' diff --git a/.vim/autoload/xolox/misc/async.vim b/.vim/autoload/xolox/misc/async.vim new file mode 100644 index 0000000..294a3a1 --- /dev/null +++ b/.vim/autoload/xolox/misc/async.vim @@ -0,0 +1,261 @@ +" Asynchronous Vim script evaluation. +" +" Author: Peter Odding +" Last Change: September 17, 2014 +" URL: http://peterodding.com/code/vim/misc/ +" +" The `xolox#misc#async#call()` function builds on top of `xolox#misc#os#exec()` +" to support asynchronous evaluation of Vim scripts. The first (and for now +" only) use case is my [vim-easytags][] plug-in which has a bunch of +" conflicting requirements: +" +" 1. I want the [vim-easytags][] plug-in to be as portable as possible. +" Ideally everything is implemented in Vim script because that's the only +" thing I can rely on to be available for all potential users of the +" plug-in! +" +" 2. Because of point one I've been forced to implement tags file reading, +" parsing, (fold case) sorting and writing in Vim script. This is fine for +" small tags files but once they grow to a couple of megabytes it becomes +" annoying because Vim is unresponsive during tags file updates (key +" presses are fortunately buffered due to Vim's input model but that +" doesn't make it a nice user experience :-). +" +" 3. I could (and did in the past) come up with all sorts of hacks to speed +" things up without switching away from Vim script, but none of them are +" going to solve the fundamental problem that Vim's unresponsive hiccups +" become longer as tags files grow larger. +" +" By now it should be clear where this is heading: _Why not handle tags file +" updates in a Vim process that runs in the background without blocking the +" Vim process that the user is interacting with?_ It turns out that there are +" quite a few details to take care of, but with those out of the way, it might +" just work! I'm actually hoping to make asynchronous updates the default mode +" in [vim-easytags][]. This means I need this functionality to be as +" portable and robust as possible. +" +" **Status:** This code has seen little testing so I wouldn't trust it too +" much just yet. On the other hand, as I said, my intention is to make this +" functionality as portable and robust as possible. You be the judge :-). +" +" [vim-easytags]: http://peterodding.com/code/vim/easytags/ + +if !exists('g:xolox#misc#async#counter') + " Increasing integer number used to match asynchronous responses to the + " requests that generated them. + let g:xolox#misc#async#counter = 1 +endif + +if !exists('g:xolox#misc#async#requests') + " Queue of asynchronous requests that haven't received a response yet. + let g:xolox#misc#async#requests = {} +endif + +function! xolox#misc#async#call(options) " {{{1 + " Call a Vim script function asynchronously by starting a hidden Vim process + " in the background. Once the function returns the hidden Vim process + " terminates itself. This function takes a single argument which is a + " dictionary with the following key/value pairs: + " + " - **function** (required): The name of the Vim function to call inside + " the child process (a string). I suggest using an [autoload][] function + " for this, see below. + " + " - **arguments** (optional): A list of arguments to pass to the function. + " This list is serialized to a string using [string()][] and deserialized + " using [eval()][]. + " + " - **callback** (optional): The name of a Vim function to call in the + " parent process when the child process has completed (a string). + " + " - **clientserver** (optional): If this is true (1) the child process will + " notify the parent process when it has finished (the default is true). + " This works using Vim's client/server support which is not always + " available. As a fall back Vim's [CursorHold][] automatic command is + " also supported (although the effect is not quite as instantaneous :-). + " + " This functionality is experimental and non trivial to use, so consider + " yourself warned :-). + " + " **Limitations** + " + " I'm making this functionality available in [vim-misc][] because I think it + " can be useful to other plug-ins, however if you are going to use it you + " should be aware of the following limitations: + " + " - Because of the use of multiple processes this functionality is only + " suitable for 'heavy' tasks. + " + " - The function arguments are serialized to a string which is passed to + " the hidden Vim process as a command line argument, so the amount of + " data you can pass will be limited by your operating environment. + " + " - The hidden Vim process is explicitly isolated from the user in several + " ways (see below for more details). This is to make sure that the hidden + " Vim processes are fast and don't clobber the user's editing sessions in + " any way. + " + " **Changes to how Vim normally works** + " + " You have to be aware that the hidden Vim process is initialized in a + " specific way that is very different from your regular Vim editing + " sessions: + " + " - Your [vimrc][] file is ignored using the `-u NONE` command line option. + " + " - Your [gvimrc][] file (if you even knew it existed ;-) is ignored using + " the `-U NONE` command line option. + " + " - Plug-in loading is skipped using the `--noplugin` command line option. + " + " - Swap files (see [swap-file][]) are disabled using the `-n` command line + " option. This makes sure asynchronous Vim processes don't disturb the + " user's editing session. + " + " - Your [viminfo][] file is ignored using the `-i NONE` command line + " option. Just like with swap files this makes sure asynchronous Vim + " processes don't disturb the user's editing session. + " + " - No-compatible mode is enabled using the `-N` command line option + " (usually the existence of your vimrc script would have achieved the + " same effect but since we disable loading of your vimrc we need to spell + " things out for Vim). + " + " **Use an auto-load function** + " + " The function you want to call is identified by its name which has to be + " defined, but I just explained above that all regular initialization is + " disabled for asynchronous Vim processes, so what gives? The answer is to + " use an [autoload][] function. This should work fine because the + " asynchronous Vim process 'inherits' the value of the ['runtimepath'][] + " option from your editing session. + " + " ['runtimepath']: http://vimdoc.sourceforge.net/htmldoc/options.html#'runtimepath' + " [autoload]: http://vimdoc.sourceforge.net/htmldoc/eval.html#autoload + " [CursorHold]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#CursorHold + " [eval()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#eval() + " [gvimrc]: http://vimdoc.sourceforge.net/htmldoc/gui.html#gvimrc + " [string()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#string() + " [swap-file]: http://vimdoc.sourceforge.net/htmldoc/recover.html#swap-file + " [vim-misc]: http://peterodding.com/code/vim/misc/ + " [viminfo]: http://vimdoc.sourceforge.net/htmldoc/starting.html#viminfo + " [vimrc]: http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc + let unique_number = g:xolox#misc#async#counter + let g:xolox#misc#async#counter += 1 + let request = {'function': a:options['function']} + let request['arguments'] = get(a:options, 'arguments', []) + let request['starttime'] = xolox#misc#timer#start() + let request['number'] = unique_number + let callback = get(a:options, 'callback') + if !empty(callback) + let request['callback'] = callback + endif + if get(a:options, 'clientserver', 1) && !empty(v:servername) + let request['servername'] = v:servername + else + let temporary_file = tempname() + let request['temporary_file'] = temporary_file + endif + let vim_command = printf('let &rtp = %s | call xolox#misc#async#inside_child(%s)', string(&rtp), string(request)) + call xolox#misc#msg#debug("vim-misc %s: Generated asynchronous Vim command #%i: %s", g:xolox#misc#version, unique_number, vim_command) + let quoted_program = xolox#misc#escape#shell(xolox#misc#os#find_vim('vim')) + let quoted_command = xolox#misc#escape#shell(vim_command) + let shell_command = printf('%s -u NONE -U NONE --noplugin -n -N -i NONE --cmd %s', quoted_program, quoted_command) + call xolox#misc#msg#debug("vim-misc %s: Generated asynchronous shell command #%i: %s", g:xolox#misc#version, unique_number, shell_command) + call xolox#misc#os#exec({'command': shell_command, 'async': 1}) + let g:xolox#misc#async#requests[unique_number] = request +endfunction + +function! xolox#misc#async#inside_child(request) " {{{1 + " Entry point inside the hidden Vim process that runs in the background. + " Invoked indirectly by `xolox#misc#async#call()` because it runs a command + " similar to the following: + " + " vim --cmd 'call xolox#misc#async#inside_child(...)' + " + " This function is responsible for calling the user defined function, + " capturing exceptions and reporting the results back to the parent Vim + " process using Vim's client/server support or a temporary file. + try + let response = {'number': a:request['number']} + let starttime = xolox#misc#timer#start() + try + " Call the user defined function and store its result. + let response['result'] = call(a:request['function'], a:request['arguments']) + catch + " Intercept errors raised by the user defined function. + let response['exception'] = v:exception + let response['throwpoint'] = v:throwpoint + endtry + " Record the elapsed time. + let response['elapsed_time'] = xolox#misc#timer#convert(starttime) + " Communicate the results back to the master Vim process. + let servername = get(a:request, 'servername', '') + if !empty(servername) + " Actively notify the parent process using Vim's client/server support? + call remote_expr(servername, printf('xolox#misc#async#callback_to_parent(%s)', string(response))) + else + " 'Passively' notify the parent process by creating the expected + " temporary file. + call xolox#misc#persist#save(a:request['temporary_file'], response) + endif + finally + " Make sure we terminate this hidden Vim process. + quitall! + endtry +endfunction + +function! xolox#misc#async#callback_to_parent(response) " {{{1 + " When Vim was compiled with client/server support this function (in the + " parent process) will be called by `xolox#misc#async#inside_child()` (in + " the child process) after the user defined function has returned. This + " enables more or less instant callbacks after running an asynchronous + " function. + let unique_number = a:response['number'] + let request = g:xolox#misc#async#requests[unique_number] + call xolox#misc#timer#stop("vim-misc %s: Processing asynchronous callback #%i after %s ..", g:xolox#misc#version, unique_number, request['starttime']) + call remove(g:xolox#misc#async#requests, unique_number) + let callback = get(request, 'callback') + if !empty(callback) + call call(callback, [a:response]) + endif +endfunction + +function! xolox#misc#async#periodic_callback() " {{{1 + " When client/server support is not being used the vim-misc plug-in + " improvises: It uses Vim's [CursorHold][] event to periodically check if an + " asynchronous process has written its results to one of the expected + " temporary files. If a response is found the temporary file is read and + " deleted and then `xolox#misc#async#callback_to_parent()` is called to + " process the response. + " + " [CursorHold]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#CursorHold + if !empty(g:xolox#misc#async#requests) + let num_processed = 0 + call xolox#misc#msg#debug("vim-misc %s: Checking for asynchronous responses (%i responses not yet received) ..", g:xolox#misc#version, len(g:xolox#misc#async#requests)) + for unique_number in sort(keys(g:xolox#misc#async#requests)) + let request = g:xolox#misc#async#requests[unique_number] + let temporary_file = get(request, 'temporary_file', '') + if !empty(temporary_file) && getfsize(temporary_file) > 0 + try + call xolox#misc#msg#debug("vim-misc %s: Found asynchronous response by %s in %s ..", g:xolox#misc#version, request['function'], temporary_file) + call xolox#misc#async#callback_to_parent(xolox#misc#persist#load(temporary_file)) + let num_processed += 1 + finally + call delete(temporary_file) + endtry + endif + endfor + call xolox#misc#msg#debug("vim-misc %s: Processed %i asynchronous responses (%i responses not yet received).", g:xolox#misc#version, num_processed, len(g:xolox#misc#async#requests)) + endif +endfunction + +" }}}1 + +" The interval in the options below is set to one (1) although the default +" value for &updatetime is four seconds. Because vim-misc never modifies +" &updatetime the interval will effectively default to four seconds unless the +" user has set &updatetime to a lower value themselves. +call xolox#misc#cursorhold#register({'function': 'xolox#misc#async#periodic_callback', 'interval': 1}) + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/misc/buffer.vim b/.vim/autoload/xolox/misc/buffer.vim new file mode 100644 index 0000000..01dca6e --- /dev/null +++ b/.vim/autoload/xolox/misc/buffer.vim @@ -0,0 +1,80 @@ +" Handling of special buffers +" +" Author: Peter Odding +" Last Change: May 19, 2013 +" URL: http://peterodding.com/code/vim/misc/ +" +" The functions defined here make it easier to deal with special Vim buffers +" that contain text generated by a Vim plug-in. For example my [vim-notes +" plug-in] [vim-notes] generates several such buffers: +" +" - [:RecentNotes] [RecentNotes] lists recently modified notes +" - [:ShowTaggedNotes] [ShowTaggedNotes] lists notes grouped by tags +" - etc. +" +" Because the text in these buffers is generated, Vim shouldn't bother with +" swap files and it should never prompt the user whether to save changes to +" the generated text. +" +" [vim-notes]: http://peterodding.com/code/vim/notes/ +" [RecentNotes]: http://peterodding.com/code/vim/notes/#recentnotes_command +" [ShowTaggedNotes]: http://peterodding.com/code/vim/notes/#showtaggednotes_command + +function! xolox#misc#buffer#is_empty() " {{{1 + " Checks if the current buffer is an empty, unchanged buffer which can be + " reused. Returns 1 if an empty buffer is found, 0 otherwise. + return !&modified && expand('%') == '' && line('$') <= 1 && getline(1) == '' +endfunction + +function! xolox#misc#buffer#prepare(...) " {{{1 + " Open a special buffer, i.e. a buffer that will hold generated contents, + " not directly edited by the user. The buffer can be customized by passing a + " dictionary with the following key/value pairs as the first argument: + " + " - **name** (required): The base name of the buffer (i.e. the base name of + " the file loaded in the buffer, even though it isn't really a file and + " nothing is really 'loaded' :-) + " - **path** (required): The pathname of the buffer. May be relevant if + " [:lcd] [lcd] or ['autochdir'] [acd] is being used. + " + " [lcd]: http://vimdoc.sourceforge.net/htmldoc/editing.html#:lcd + " [acd]: http://vimdoc.sourceforge.net/htmldoc/options.html#'autochdir' + if a:0 == 1 && type(a:1) == type('') + " Backwards compatibility with old interface. + let options = {'name': a:1, 'path': a:1} + elseif type(a:1) == type({}) + let options = a:1 + else + throw "Invalid arguments" + endif + let winnr = 1 + let found = 0 + for bufnr in tabpagebuflist() + if xolox#misc#path#equals(options['path'], bufname(bufnr)) + execute winnr . 'wincmd w' + let found = 1 + break + else + let winnr += 1 + endif + endfor + if !(found || xolox#misc#buffer#is_empty()) + vsplit + endif + silent execute 'edit' fnameescape(options['path']) + lcd " clear working directory + setlocal buftype=nofile bufhidden=hide noswapfile + let &l:statusline = '[' . options['name'] . ']' + call xolox#misc#buffer#unlock() + silent %delete +endfunction + +function! xolox#misc#buffer#lock() " {{{1 + " Lock a special buffer so that its contents can no longer be edited. + setlocal readonly nomodifiable nomodified +endfunction + +function! xolox#misc#buffer#unlock() " {{{1 + " Unlock a special buffer so that its content can be updated. + setlocal noreadonly modifiable +endfunction diff --git a/.vim/autoload/xolox/misc/complete.vim b/.vim/autoload/xolox/misc/complete.vim new file mode 100644 index 0000000..e3818d4 --- /dev/null +++ b/.vim/autoload/xolox/misc/complete.vim @@ -0,0 +1,26 @@ +" Tab completion for user defined commands. +" +" Author: Peter Odding +" Last Change: July 9, 2014 +" URL: http://peterodding.com/code/vim/misc/ + +function! xolox#misc#complete#keywords(arglead, cmdline, cursorpos) + " This function can be used to perform keyword completion for user defined + " Vim commands based on the contents of the current buffer. Here's an + " example of how you would use it: + " + " :command -nargs=* -complete=customlist,xolox#misc#complete#keywords MyCmd call s:MyCmd() + let words = {} + for line in getline(1, '$') + for word in split(line, '\W\+') + let words[word] = 1 + endfor + endfor + let arguments = [keys(filter(words, 'v:key =~# a:arglead'))] + if &ignorecase + call add(arguments, 1) + endif + return call('sort', arguments) +endfunction + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/misc/cursorhold.vim b/.vim/autoload/xolox/misc/cursorhold.vim new file mode 100644 index 0000000..cbbde1f --- /dev/null +++ b/.vim/autoload/xolox/misc/cursorhold.vim @@ -0,0 +1,71 @@ +" Rate limiting for Vim's CursorHold event. +" +" Author: Peter Odding +" Last Change: June 22, 2014 +" URL: http://peterodding.com/code/vim/misc/ +" +" Several of my Vim plug-ins (e.g. [vim-easytags][], [vim-notes][] and +" [vim-session][]) use Vim's [CursorHold][] and [CursorHoldI][] events to +" perform periodic tasks when the user doesn't press any keys for a couple of +" seconds. These events by default fire after four seconds, this is +" configurable using Vim's ['updatetime'][] option. The problem that this +" script solves is that there are Vim plug-ins which set the ['updatetime'][] +" option to unreasonably low values, thereby breaking my Vim plug-ins and +" probably a lot of other Vim plug-ins out there. When users complain about +" this I can tell them that another Vim plug-in is to blame, but users don't +" care for the difference, their Vim is broken! So I implemented a workaround. +" This script enables registration of [CursorHold][] event handlers with a +" configurable interval (expressed in seconds). The event handlers will be +" called no more than once every interval. +" +" ['updatetime']: http://vimdoc.sourceforge.net/htmldoc/options.html#'updatetime' +" [CursorHold]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#CursorHold +" [CursorHoldI]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#CursorHoldI +" [vim-easytags]: http://peterodding.com/code/vim/easytags/ +" [vim-notes]: http://peterodding.com/code/vim/notes/ +" [vim-session]: http://peterodding.com/code/vim/session/ + +if !exists('g:xolox#misc#cursorhold#handlers') + let g:xolox#misc#cursorhold#handlers = [] +endif + +function! xolox#misc#cursorhold#register(options) + " Register a [CursorHold][] event handler with a custom interval. This + " function takes a single argument which is a dictionary with the following + " fields: + " + " - **function** (required): The name of the event handler function (a + " string). + " + " - **arguments** (optional): A list of arguments to pass to the event + " handler function (defaults to an empty list). + " + " - **interval** (optional): The number of seconds between calls to the + " event handler (defaults to 4). + call add(g:xolox#misc#cursorhold#handlers, copy(a:options)) +endfunction + +function! xolox#misc#cursorhold#autocmd() + " The 'top level event handler' that's called by Vim whenever the + " [CursorHold][] or [CursorHoldI][] event fires. It iterates through the + " event handlers registered using `xolox#misc#cursorhold#register()` and + " calls each event handler at the appropriate interval, keeping track of + " the time when each event handler was last run. + for handler in g:xolox#misc#cursorhold#handlers + let function = handler['function'] + let last_run = get(handler, 'last_run', 0) + let interval = get(handler, 'interval', 4) + call xolox#misc#msg#debug("vim-misc %s: Checking handler %s with interval %i and last run %i ..", g:xolox#misc#version, function, interval, last_run) + " Rate limit in case &updatetime is set (very) low. + let time_until_next_run = (last_run + interval) - localtime() + if time_until_next_run > 0 + call xolox#misc#msg#debug("vim-misc %s: Rate limiting handler %s (time until next run: %i seconds).", g:xolox#misc#version, function, time_until_next_run) + else + call xolox#misc#msg#debug("vim-misc %s: Running handler %s ..", g:xolox#misc#version, function) + call call(function, get(handler, 'arguments', [])) + let handler['last_run'] = localtime() + endif + endfor +endfunction + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/misc/echo.exe b/.vim/autoload/xolox/misc/echo.exe new file mode 100644 index 0000000000000000000000000000000000000000..52f4e792df13bebd4f5743f29ba8fbe59fb40915 GIT binary patch literal 7680 zcmeHMdu&_P89&aWaZ{&uA+93m=q*cVN9wH5c9bL?rtR%x#BGwsX`!L6W8cKi9NXCU zwiJ=la$~7CXX!eLp-t>T)M=Y0{@5Q(tA^$UTFpf(Q$P&5fu=~yHb;)MXk-vZh4=f; zweu(uY|^Iv0Vg`|@B7a0dz^=FJP(~`rHrvMN8NMfvf?X-uzN`-_$A`Q@*y zyJ%^7WnD)ooRs2;SZ~7LF9rP3XiSy56)B-brEpZ*b>N`X9}6lCRaKR>1<|cCV=b0a z_U0?Aw-#3$XKO7hEajE#CX7^?qsMMT?Lgi{eYe>zF>%uf;TNeDCB`X{UV@PLh*{Kg z6%De;CdM|1)_=Kx++!ajvO!fIRWWZPOq5C20&cWKk|3fX5%jBm#w419OrdDCn4T-# zFi3+*#x9Z}Fu;}}*B~!QZpKCzbVal6ptqB&wbh6C{LWyozA991R$ zo;|&~J>+n^S^jtWWov3wJutM}vU_k;`wNz=8L9x){moIWGPA3eOu%xhniZ`=0LU$C zmbKc=Zw>9S>;c2?X@&jzi^cWPdtxY8Mq*O$a+eJl?C0(P^3+@Q!9NkMUA1dAzs0xN z)A#IYddEKaLyYMkcG*)L4O-bgcm^$ddV0_B?lFCK_lfA{mxs>of&uci!!@YV6`0TY z(pIVt!x)a-;k1o952Pt5bGy=2RBcZ$r|L`T6;yqZPY+czZ+hI;e9seBdwOiou=@8g zG2+C?DtmeqBhzEKioPx~N?E5U3n)_$<@0&csiMk&K$iTXwqHA-?@72-asyGUe2#q;-?&`dBEt z!_7h)FxuKzlI_Keez{to&8s`~*^r9Xaka(}QVb!)ck~jB+)-Nt6Z5JoU~UU-1b5y^ zpaFJ)3rr4^8+;4Eq3PvQeT>UBt=v=H#=VYqF5A$ywq@@YAZi}IL?o6aN$f?Et8)p& z`qYNbO!;}JN=X-ZnLYIlbTZ{+0Sj6q)VT096ugQ`qv|ZmO!;Y)lmNw^F41RQnln>A zh`|yX^f>evEr!RD+f$scFU||5x%u^>W>_P8C!7HbAvA5K6r##inr(uiZx;)ytGJUI zSTZ$gPrZ*ReLJmcF>!N&u1O$O*Kj8xZgP?e>Pj+L_HAr#ER?&&)TXIQ%-Oi0F`T5E z(6~vq4&1}VEce=Y*^oVL)!%n%)g~omaoc%&y3LY$O|uIQebjP+gynu^vKaz|N#5kO zs!xPkps66`9viPd)1Ga>aU#w~t$UG(Pt;=dycUGm)K^=i1(&U+*F09kR70o;B-*+W z!BkGhQEld8CXIe2KWQw3{{(GO$yNG4UE0kHklWKcEU8hg$uvFFti;zwdp`gxR5SIq#p|?LXrbj9`5KYsD$qc^&}3Y`Hr!GIVH5)-!ajHp?!Cog z2(CS~7UMTSMv$tN`oJ1+S%^zWF+9^5d4|@>$WvyOrHXr}MUbhhxd$x>-L9_S@-*CR z$kVxTY(v8{n~|>*aqcGWoz-7*7~WYfUl%0Txo1|tm#IkzsuwZaK0>ImXJ`4U_PkRv z4>Z{E0j^EgZ>32t&vNW&2d*9jY16dkgj~a$g-}DD08U{TNgv2EZ6yR5o-FrXH@p*M ztSMpKB(4a3V2Y_xePD)ZA$_|z!f>uqa26tuJZo(WweG}-ldci{B{v|MXRO1-nH@5N z%rsN!71QXZsr8pEh6s_1_d)x~PFRyL*$3YQ1};w+^7R`$Uo@wEFipnwWc8C}47=Go zEo4!wOnx6TMY!=fxE*J%Q@qg$a|iffy8`<7(&%$rxtxV|^Fh&a9unr*o?Viyx}fwo zmkHA^R@&4uj%VfM1w!x5>W`J-#CaMWfs;;)+dnDzbA3hSHZH=3)7-{OT0>(5OkC=? z_U3Lphk4+&XFn)k0$Jg7%{IPw?bcC!yj&k`oV$f!+oXmjZ5(y;LM83#y%wB_w2cdAGJ@ODmTe(wdiL2< z-(KL-*u2)}(Mh|#uDB^|aBOH6CKwU%IO=Yli${1=Y}ExWB>{6Dt)amFNEla}cht8q zDST8spG{|8us}H>b!gRD@3=rg6s97cadE|Fp9B>&G32)e0q%g*%bNX$J)jS~&D7=g zv^=iQHfrvolRs}y3o*jC+X&)EeQQs9#|`H;XlZM(utR zF;q{zrrs(bEp^J$y;;1~=P&BX=SW!5Q@CkAXG$}w#6c~#^W479Jz9)w&9kIJ9iOBS zmmT8DY}A(hS{`rAm7%;Zw{Bq!EV=SLV6x~@{%7&7!EGjtuinbNXq7a{Hmw|kxhgz? z#8bnXdu#Kkpw*|OPI1HGoG!dsJTvCH;(VTMl4tDaJ|Js&W}0xgpZl9I^K89$hRZYc z@^sVKspFWd_e|q}EnEw^<=i_(_VG?}d8$dy4(!FnQ0kciAUqG~#1kAiu#p7Ohqo!39x$CiimzXdE_~eE&oI*bw(|ec_El z?}5@+7d(H&)1hemK1P3VD7Lo^8^hY3P5%S8%w@be=iZZ<^6x+h;+L5ZS9*-*L&tEp zgqY-J!4XoYHE7gPtzRBL*m=lMU|ey3_F3}IR&gJeWy+s}99&}gO!-d>t-P}Zle}sZ zHi}`*JNHu0`2)-vj*(r|!5im!bhCHN#f6{37o^*1b=m?j93}5o;6wXPDX2E3p=xANtNXRNg?yVGR9#1-7$W4L!Wnh0SG(i>qF zH0T#5^Bp}x@h^S|tfm3%ec6}2*E1|X_uSS-T??m2${AJ|5$nD4>EA~}lvrz1ZFzGCVEjrlFFI5J1imF79Gv+zixwE~aAsC4;HpYBn(Y?%fI1pENha;+zU;*ay#eF_sI2sl#htUUj zzds!HCwi02285UbX+L`sb4f+jlIZx=kdjC+_6+m+gMC_3_4Ne9STStM3&i^AJ1b*R zv)^O(PMZ>Z{&?J{o{VEYL#P5uT=j+g(O^VLY-a3v<_pB4Y9bctfi|C|PnQLvip)9^ zC#7R`Ny+63DUtYksVA1ecl(5bZ}?~;_`MWsb47?bG#0x?a+c9RgvlA7>`BjIST6je^3R)|Si#3OCcqKN$9 z7idaeJQWNl{oN5lhkX){MFc)6)*~fj{fd-S9?_I&KuOYnAWUdU2%%)^XSN|E9`T<9 z9Q+4^)RwRzB-*mlhGZzFMS}E?41XjRRR{wmm+QEaNWvCq7nCUuEHKo^$*DXPRv}x3 zN*jeCdSa1C>;ze29=0EbPbh&{Z#4Xv5)|U*HC2L*m4MT=fB$}X;m z#Y8BU2tS77$RCkZe>aUE7vr$B8V(dju|==$aI-!8y;2gsi)d;%l9cXhxVK?Tarf5X z%~(u$9x-V_9|z}05`_Q_7Cg%8(XLA(pik4=iZS}&(R$$EzQZjK`gR^@ZHq)$ literal 0 HcmV?d00001 diff --git a/.vim/autoload/xolox/misc/escape.vim b/.vim/autoload/xolox/misc/escape.vim new file mode 100644 index 0000000..29a16ca --- /dev/null +++ b/.vim/autoload/xolox/misc/escape.vim @@ -0,0 +1,56 @@ +" String escaping functions. +" +" Author: Peter Odding +" Last Change: May 19, 2013 +" URL: http://peterodding.com/code/vim/misc/ + +function! xolox#misc#escape#pattern(string) " {{{1 + " Takes a single string argument and converts it into a [:substitute] + " [subcmd] / [substitute()] [subfun] pattern string that matches the given + " string literally. + " + " [subfun]: http://vimdoc.sourceforge.net/htmldoc/eval.html#substitute() + " [subcmd]: http://vimdoc.sourceforge.net/htmldoc/change.html#:substitute + if type(a:string) == type('') + let string = escape(a:string, '^$.*\~[]') + return substitute(string, '\n', '\\n', 'g') + endif + return '' +endfunction + +function! xolox#misc#escape#substitute(string) " {{{1 + " Takes a single string argument and converts it into a [:substitute] + " [subcmd] / [substitute()] [subfun] replacement string that inserts the + " given string literally. + if type(a:string) == type('') + let string = escape(a:string, '\&~%') + return substitute(string, '\n', '\\r', 'g') + endif + return '' +endfunction + +function! xolox#misc#escape#shell(string) " {{{1 + " Takes a single string argument and converts it into a quoted command line + " argument. + " + " I was going to add a long rant here about Vim's ['shellslash' option] + " [shellslash], but really, it won't make any difference. Let's just suffice + " to say that I have yet to encounter a single person out there who uses + " this option for its intended purpose (running a UNIX style shell on + " Microsoft Windows). + " + " [shellslash]: http://vimdoc.sourceforge.net/htmldoc/options.html#'shellslash' + if xolox#misc#os#is_win() + try + let ssl_save = &shellslash + set noshellslash + return shellescape(a:string) + finally + let &shellslash = ssl_save + endtry + else + return shellescape(a:string) + endif +endfunction + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/misc/format.vim b/.vim/autoload/xolox/misc/format.vim new file mode 100644 index 0000000..44f7b54 --- /dev/null +++ b/.vim/autoload/xolox/misc/format.vim @@ -0,0 +1,46 @@ +" Human friendly string formatting for Vim. +" +" Author: Peter Odding +" Last Change: June 2, 2013 +" URL: http://peterodding.com/code/vim/misc/ + +function! xolox#misc#format#pluralize(count, singular, plural) " {{{1 + " Concatenate a counter (the first argument, expected to be an integer) with + " a singular or plural label (the second and third arguments, both expected + " to be strings). + if a:count == 0 + return printf('no %s', a:plural) + else + return printf('%i %s', a:count, a:count == 1 ? a:singular : a:plural) + endif +endfunction + +function! xolox#misc#format#timestamp(ts) " {{{1 + " Format a time stamp (a string containing a formatted floating point + " number) into a human friendly format, for example 70 seconds is phrased as + " "1 minute and 10 seconds". + let seconds = a:ts + 0 + " Fast common case with extra precision from reltime(). + if seconds < 5 + let extract = matchstr(a:ts, '^\d\+\(\.0*[1-9][1-9]\?\)\?') + if extract =~ '[123456789]' + return extract . ' second' . (extract != '1' ? 's' : '') + endif + endif + " Generic but slow code. + let result = [] + for [name, size] in [['day', 60 * 60 * 24], ['hour', 60 * 60], ['minute', 60], ['second', 1]] + if seconds >= size + let counter = seconds / size + let seconds = seconds % size + let suffix = counter != 1 ? 's' : '' + call add(result, printf('%i %s%s', counter, name, suffix)) + endif + endfor + " Format the resulting text? + if len(result) == 1 + return result[0] + else + return join(result[0:-2], ', ') . ' and ' . result[-1] + endif +endfunction diff --git a/.vim/autoload/xolox/misc/list.vim b/.vim/autoload/xolox/misc/list.vim new file mode 100644 index 0000000..548592a --- /dev/null +++ b/.vim/autoload/xolox/misc/list.vim @@ -0,0 +1,42 @@ +" List handling functions. +" +" Author: Peter Odding +" Last Change: June 2, 2013 +" URL: http://peterodding.com/code/vim/misc/ + +function! xolox#misc#list#unique(list) " {{{1 + " Remove duplicate values from the given list in-place (preserves order). + call reverse(a:list) + call filter(a:list, 'count(a:list, v:val) == 1') + return reverse(a:list) +endfunction + +function! xolox#misc#list#binsert(list, value, ...) " {{{1 + " Performs in-place binary insertion, which depending on your use case can + " be more efficient than calling Vim's [sort()] [sort] function after each + " insertion (in cases where a single, final sort is not an option). Expects + " three arguments: + " + " 1. A list + " 2. A value to insert + " 3. 1 (true) when case should be ignored, 0 (false) otherwise + " + " [sort]: http://vimdoc.sourceforge.net/htmldoc/eval.html#sort() + let idx = s:binsert_r(a:list, 0, len(a:list), a:value, exists('a:1') && a:1) + return insert(a:list, a:value, idx) +endfunction + +function! s:binsert_r(list, low, high, value, ignorecase) + let mid = a:low + (a:high - a:low) / 2 + if a:low == a:high + return a:low + elseif a:ignorecase ? a:value >? a:list[mid] : a:value > a:list[mid] + return s:binsert_r(a:list, mid + 1, a:high, a:value, a:ignorecase) + elseif a:ignorecase ? a:value +" Last Change: March 15, 2015 +" URL: http://peterodding.com/code/vim/misc/ + +if !exists('g:xolox_message_buffer') + " For when I lose my :messages history :-\ + let g:xolox_message_buffer = 100 +endif + +if !exists('g:xolox_messages') + let g:xolox_messages = [] +endif + +function! xolox#misc#msg#info(...) " {{{1 + " Show a formatted informational message to the user. + " + " This function has the same argument handling as Vim's [printf()] [] + " function with one notable difference: Any arguments which are not numbers + " or strings are coerced to strings using Vim's [string()] [] function. + " + " In the case of `xolox#misc#msg#info()`, automatic string coercion simply + " makes the function a bit easier to use. + " + " The messages emitted by this function have no highlighting. Previously + " these messages were highlighted using the [Title group] [hl-title], but it + " was pointed out in [pull request 16] [pr-16] that this group shouldn't be + " used for informational messages because it is meant for titles and because + " of this some color schemes use colors that stand out quite a bit, causing + " the informational messages to look like errors. + " + " [hl-title]: http://vimdoc.sourceforge.net/htmldoc/syntax.html#hl-Title + " [pr-16]: https://github.com/xolox/vim-misc/pull/16 + " [printf()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#printf() + " [string()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#string() + call s:show_message('None', a:000) +endfunction + +function! xolox#misc#msg#warn(...) " {{{1 + " Show a formatted warning message to the user. + " + " This function has the same argument handling as the + " `xolox#misc#msg#info()` function. + call s:show_message('WarningMsg', a:000) +endfunction + +function! xolox#misc#msg#debug(...) " {{{1 + " Show a formatted debugging message to the user, *if the user has enabled + " increased verbosity by setting Vim's ['verbose'] [] option to one + " (1) or higher*. + " + " This function has the same argument handling as the + " `xolox#misc#msg#info()` function. + " + " In the case of `xolox#misc#msg#debug()`, automatic string coercion + " provides lazy evaluation in the sense that complex data structures are + " only converted to strings when the user has enabled increased verbosity. + " + " ['verbose']: http://vimdoc.sourceforge.net/htmldoc/options.html#'verbose' + if &vbs >= 1 + call s:show_message('Question', a:000) + endif +endfunction + +function! s:show_message(hlgroup, args) " {{{1 + " The implementation of info() and warn(). + let nargs = len(a:args) + if nargs == 1 + let message = a:args[0] + elseif nargs >= 2 + let args = map(copy(a:args), 's:coerce_argument(v:val)') + let message = call('printf', args) + endif + if exists('message') + try + " Temporarily disable Vim's |hit-enter| prompt and mode display. + if !exists('s:more_save') + let s:more_save = &more + let s:ruler_save = &ruler + let s:smd_save = &showmode + endif + set nomore noshowmode + if winnr('$') == 1 | set noruler | endif + augroup PluginXoloxHideMode + autocmd! CursorHold,CursorHoldI * call s:clear_message() + augroup END + execute 'echohl' a:hlgroup + " Redraw to avoid the |hit-enter| prompt. We use :silent to avoid issues + " like this one: https://github.com/xolox/vim-easytags/issues/69. + silent! redraw + for line in split(message, "\n") + echomsg line + endfor + if g:xolox_message_buffer > 0 + call add(g:xolox_messages, message) + if len(g:xolox_messages) > g:xolox_message_buffer + call remove(g:xolox_messages, 0) + endif + endif + finally + " Always clear message highlighting, even when interrupted by Ctrl-C. + echohl none + endtry + endif +endfunction + +function! s:coerce_argument(value) " {{{1 + " Callback to coerce printf() arguments into strings. + let value_type = type(a:value) + if value_type != type(0) && value_type != type('') + return string(a:value) + else + return a:value + endif +endfunction + +function! s:clear_message() " {{{1 + " Callback to clear message after some time has passed. + echo '' + let &more = s:more_save + let &showmode = s:smd_save + let &ruler = s:ruler_save + unlet s:more_save s:ruler_save s:smd_save + autocmd! PluginXoloxHideMode + augroup! PluginXoloxHideMode +endfunction + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/misc/open.vim b/.vim/autoload/xolox/misc/open.vim new file mode 100644 index 0000000..ff0b5e2 --- /dev/null +++ b/.vim/autoload/xolox/misc/open.vim @@ -0,0 +1,100 @@ +" Integration between Vim and its environment. +" +" Author: Peter Odding +" Last Change: June 19, 2013 +" URL: http://peterodding.com/code/vim/misc/ + +let s:enoimpl = "vim-misc %s: %s() hasn't been implemented for your platform! If you have suggestions, please get in touch at https://github.com/xolox/vim-misc/issues" +let s:handlers = ['gnome-open', 'kde-open', 'exo-open', 'xdg-open', 'cygstart'] + +function! xolox#misc#open#file(location, ...) " {{{1 + " Given a pathname or URL as the first argument, this opens the file with + " the program associated with the file type. So for example a text file + " might open in Vim, an `*.html` file would probably open in your web + " browser and a media file would open in a media player. + " + " This should work on Windows, Mac OS X and most Linux distributions. If + " this fails to find a file association, you can pass one or more external + " commands to try as additional arguments. For example: + " + " :call xolox#misc#open#file('/path/to/my/file', 'firefox', 'google-chrome') + " + " This generally shouldn't be necessary but it might come in handy now and + " then. + if xolox#misc#os#is_win() + try + call xolox#shell#open_with_windows_shell(a:location) + catch /^Vim\%((\a\+)\)\=:E117/ + let command = '!start CMD /C START "" %s' + silent execute printf(command, xolox#misc#escape#shell(a:location)) + endtry + return + elseif xolox#misc#os#is_mac() + call xolox#misc#msg#debug("vim-misc %s: Detected Mac OS X, using 'open' command to open %s ..", g:xolox#misc#version, string(a:location)) + let cmd = 'open ' . shellescape(a:location) . ' 2>&1' + call s:handle_error(cmd, system(cmd)) + return + else + for handler in s:handlers + a:000 + if executable(handler) + call xolox#misc#msg#debug("vim-misc %s: Using '%s' to open '%s'.", g:xolox#misc#version, handler, a:location) + let cmd = shellescape(handler) . ' ' . shellescape(a:location) . ' 2>&1' + call s:handle_error(cmd, system(cmd)) + return + endif + endfor + endif + throw printf(s:enoimpl, g:xolox#misc#version, 'xolox#misc#open#file') +endfunction + +function! xolox#misc#open#url(url) " {{{1 + " Given a URL as the first argument, this opens the URL in your preferred or + " best available web browser: + " + " - In GUI environments a graphical web browser will open (or a new tab will + " be created in an existing window) + " - In console Vim without a GUI environment, when you have any of `lynx`, + " `links` or `w3m` installed it will launch a command line web browser in + " front of Vim (temporarily suspending Vim) + let url = a:url + if url !~ '^\w\+://' + call xolox#misc#msg#debug("vim-misc %s: The URL %s doesn't contain a scheme, improvising ..", g:xolox#misc#version, string(url)) + if url !~ '@' + call xolox#misc#msg#debug("vim-misc %s: Defaulting to http:// URL scheme ..", g:xolox#misc#version) + let url = 'http://' . url + elseif url !~ '^mailto:' + call xolox#misc#msg#debug("vim-misc %s: Defaulting to mailto: URL scheme ..", g:xolox#misc#version) + let url = 'mailto:' . url + endif + endif + let on_unix = has('unix') + let not_on_mac = !xolox#misc#os#is_mac() + let no_gui_available = (has('gui_running') == 0 && $DISPLAY == '') + if on_unix && not_on_mac && no_gui_available + call xolox#misc#msg#debug("vim-misc %s: Using command line web browser because no GUI seems to be available ..", g:xolox#misc#version) + for browser in ['lynx', 'links', 'w3m'] + call xolox#misc#msg#debug("vim-misc %s: Checking whether %s command line web browser is installed ..", g:xolox#misc#version, string(browser)) + if executable(browser) + call xolox#misc#msg#debug("vim-misc %s: Found %s, using it to open %s ..", g:xolox#misc#version, string(browser), string(url)) + execute '!' . browser fnameescape(url) + call s:handle_error(browser . ' ' . url, '') + return + endif + endfor + endif + call xolox#misc#msg#debug("vim-misc %s: Defaulting to GUI web browser to open %s ..", g:xolox#misc#version, string(url)) + call xolox#misc#open#file(url, 'firefox', 'google-chrome') +endfunction + +function! s:handle_error(cmd, output) " {{{1 + if v:shell_error + let message = "vim-misc %s: Failed to execute program! (command line: %s%s)" + let output = strtrans(xolox#misc#str#trim(a:output)) + if output != '' + let output = ", output: " . string(output) + endif + throw printf(message, g:xolox#misc#version, a:cmd, output) + endif +endfunction + +" vim: et ts=2 sw=2 fdm=marker diff --git a/.vim/autoload/xolox/misc/option.vim b/.vim/autoload/xolox/misc/option.vim new file mode 100644 index 0000000..97fc88e --- /dev/null +++ b/.vim/autoload/xolox/misc/option.vim @@ -0,0 +1,115 @@ +" Vim and plug-in option handling. +" +" Author: Peter Odding +" Last Change: June 2, 2013 +" URL: http://peterodding.com/code/vim/misc/ + +function! xolox#misc#option#get(name, ...) " {{{1 + " Expects one or two arguments: 1. The name of a variable and 2. the default + " value if the variable does not exist. + " + " Returns the value of the variable from a buffer local variable, global + " variable or the default value, depending on which is defined. + " + " This is used by some of my Vim plug-ins for option handling, so that users + " can customize options for specific buffers. + if exists('b:' . a:name) + " Buffer local variable. + return eval('b:' . a:name) + elseif exists('g:' . a:name) + " Global variable. + return eval('g:' . a:name) + elseif exists('a:1') + " Default value. + return a:1 + endif +endfunction + +function! xolox#misc#option#split(value) " {{{1 + " Given a multi-value Vim option like ['runtimepath'] [rtp] this returns a + " list of strings. For example: + " + " :echo xolox#misc#option#split(&runtimepath) + " ['/home/peter/Projects/Vim/misc', + " '/home/peter/Projects/Vim/colorscheme-switcher', + " '/home/peter/Projects/Vim/easytags', + " ...] + " + " [rtp]: http://vimdoc.sourceforge.net/htmldoc/options.html#'runtimepath' + let values = split(a:value, '[^\\]\zs,') + return map(values, 's:unescape(v:val)') +endfunction + +function! s:unescape(s) + return substitute(a:s, '\\\([\\,]\)', '\1', 'g') +endfunction + +function! xolox#misc#option#join(values) " {{{1 + " Given a list of strings like the ones returned by + " `xolox#misc#option#split()`, this joins the strings together into a + " single value that can be used to set a Vim option. + let values = copy(a:values) + call map(values, 's:escape(v:val)') + return join(values, ',') +endfunction + +function! s:escape(s) + return escape(a:s, ',\') +endfunction + +function! xolox#misc#option#split_tags(value) " {{{1 + " Customized version of `xolox#misc#option#split()` with specialized + " handling for Vim's ['tags' option] [tags]. + " + " [tags]: http://vimdoc.sourceforge.net/htmldoc/options.html#'tags' + let values = split(a:value, '[^\\]\zs,') + return map(values, 's:unescape_tags(v:val)') +endfunction + +function! s:unescape_tags(s) + return substitute(a:s, '\\\([\\, ]\)', '\1', 'g') +endfunction + +function! xolox#misc#option#join_tags(values) " {{{1 + " Customized version of `xolox#misc#option#join()` with specialized + " handling for Vim's ['tags' option] [tags]. + let values = copy(a:values) + call map(values, 's:escape_tags(v:val)') + return join(values, ',') +endfunction + +function! s:escape_tags(s) + return escape(a:s, ', ') +endfunction + +function! xolox#misc#option#eval_tags(value, ...) " {{{1 + " Evaluate Vim's ['tags' option] [tags] without looking at the file + " system, i.e. this will report tags files that don't exist yet. Expects + " the value of the ['tags' option] [tags] as the first argument. If the + " optional second argument is 1 (true) only the first match is returned, + " otherwise (so by default) a list with all matches is returned. + let pathnames = [] + let first_only = exists('a:1') ? a:1 : 0 + for pattern in xolox#misc#option#split_tags(a:value) + " Make buffer relative pathnames absolute. + if pattern =~ '^\./' + let suffix = matchstr(pattern, '^./\zs.*$') + let pattern = xolox#misc#path#merge(expand('%:p:h'), suffix) + endif + " Make working directory relative pathnames absolute. + if xolox#misc#path#is_relative(pattern) + let pattern = xolox#misc#path#merge(getcwd(), pattern) + endif + " Ignore the trailing `;' for recursive upwards searching because we + " always want the most specific pathname available. + let pattern = substitute(pattern, ';$', '', '') + " Expand the pattern. + call extend(pathnames, split(expand(pattern), "\n")) + if first_only && !empty(pathnames) + return pathnames[0] + endif + endfor + return first_only ? '' : pathnames +endfunction + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/misc/os.vim b/.vim/autoload/xolox/misc/os.vim new file mode 100644 index 0000000..ea96116 --- /dev/null +++ b/.vim/autoload/xolox/misc/os.vim @@ -0,0 +1,271 @@ +" Operating system interfaces. +" +" Author: Peter Odding +" Last Change: June , 2013 +" URL: http://peterodding.com/code/vim/misc/ + +function! xolox#misc#os#is_mac() " {{{1 + " Returns 1 (true) when on Mac OS X, 0 (false) otherwise. You would expect + " this to simply check the Vim feature list, but for some obscure reason the + " `/usr/bin/vim` included in Mac OS X (verified on version 10.7.5) returns 0 + " (false) in response to `has('mac')`, so we check the output of `uname` + " to avoid false negatives. + if !exists('s:is_mac') + " By default we assume we are *not* on Mac OS X. + let s:is_mac = 0 + if has('mac') || has('macunix') || has('gui_mac') + " If Vim's feature list indicates we are on Mac OS X, we have our answer :-). + let s:is_mac = 1 + elseif !xolox#misc#os#is_win() + " Otherwise we check the output of `uname' to avoid false negatives. + let result = xolox#misc#os#exec({'command': 'uname', 'check': 0}) + if result['exit_code'] == 0 && get(result['stdout'], 0, '') == 'Darwin' + let s:is_mac = 1 + endif + endif + endif + return s:is_mac +endfunction + +function! xolox#misc#os#is_win() " {{{1 + " Returns 1 (true) when on Microsoft Windows, 0 (false) otherwise. + return has('win16') || has('win32') || has('win64') +endfunction + +function! xolox#misc#os#find_vim(...) " {{{1 + " Returns the program name of Vim as a string. On Windows and UNIX this just + " [v:progname] [] as an absolute pathname while on Mac OS X there is + " some special magic to find MacVim's executable even though it's usually + " not on the executable search path. If you want, you can override the + " value returned from this function by setting the global variable + " `g:xolox#misc#os#vim_progname`. + " + " By default the choice of console Vim vs graphical Vim is made based on + " the value of [v:progname] [], but if you have a preference you can pass + " the string `vim` or `gvim` as the first and only argument. + " + " [v:progname]: http://vimdoc.sourceforge.net/htmldoc/eval.html#v:progname + if exists('a:1') + let program_name = a:1 + else + let program_name = v:progname + endif + if exists('g:xolox#misc#os#vim_progname') + let pathname = g:xolox#misc#os#vim_progname + else + let pathname = '' + endif + if empty(pathname) && xolox#misc#os#is_mac() + " Special handling for Mac OS X where MacVim is usually not on the $PATH. + " This always returns the "Vim" executable and not "MacVim" (regardless of + " the caller's preference) because "MacVim" has funky dock magic going on. + call xolox#misc#msg#debug("vim-misc %s: Trying MacVim workaround to find Vim executable ..", g:xolox#misc#version) + let segments = xolox#misc#path#split($VIMRUNTIME) + if segments[-3:] == ['Resources', 'vim', 'runtime'] + let pathname = xolox#misc#path#join(segments[0:-4] + ['MacOS', 'Vim']) + call xolox#misc#msg#debug("vim-misc %s: The MacVim workaround resulted in the Vim executable %s.", g:xolox#misc#version, string(pathname)) + endif + endif + if empty(pathname) + " Default logic. + call xolox#misc#msg#debug("vim-misc %s: Looking for Vim executable named %s on search path ..", g:xolox#misc#version, string(program_name)) + let candidates = xolox#misc#path#which(program_name) + if !empty(candidates) + call xolox#misc#msg#debug("vim-misc %s: Found %i candidate(s) on search path: %s.", g:xolox#misc#version, len(candidates), string(candidates)) + let pathname = candidates[0] + endif + endif + call xolox#misc#msg#debug("vim-misc %s: Reporting Vim executable %s.", g:xolox#misc#version, string(pathname)) + return pathname +endfunction + +function! xolox#misc#os#exec(options) " {{{1 + " Execute an external command (hiding the console on Microsoft Windows when + " my [vim-shell plug-in] [vim-shell] is installed). + " + " Expects a dictionary with the following key/value pairs as the first + " argument: + " + " - **command** (required): The command line to execute + " - **async** (optional): set this to 1 (true) to execute the command in the + " background (asynchronously) + " - **stdin** (optional): a string or list of strings with the input for the + " external command + " - **check** (optional): set this to 0 (false) to disable checking of the + " exit code of the external command (by default an exception will be + " raised when the command fails) + " + " Returns a dictionary with one or more of the following key/value pairs: + " + " - **command** (always available): the generated command line that was used + " to run the external command + " - **exit_code** (only in synchronous mode): the exit status of the + " external command (an integer, zero on success) + " - **stdout** (only in synchronous mode): the output of the command on the + " standard output stream (a list of strings, one for each line) + " - **stderr** (only in synchronous mode): the output of the command on the + " standard error stream (as a list of strings, one for each line) + " + " [vim-shell]: http://peterodding.com/code/vim/shell/ + try + + " Unpack the options. + let cmd = a:options['command'] + let async = get(a:options, 'async', 0) + + " We need to know in a couple of places whether we are on Windows. + let is_win = xolox#misc#os#is_win() + + " Use vim-shell so we don't pop up a console window on Windows? If the + " caller specifically asks us *not* to use vim-shell, we'll respect that + " choice; this is very useful for automated tests :-). + if get(a:options, 'use_dll', 1) == 0 + let use_dll = 0 + else + let use_dll = xolox#misc#os#can_use_dll() + endif + + " Decide whether to redirect the standard output and standard error + " streams to temporary files. + let redirect_output = !async && (use_dll || !is_win) + + " Write the input for the external command to a temporary file? + if has_key(a:options, 'stdin') && use_dll + let tempin = tempname() + if type(a:options['stdin']) == type([]) + let lines = a:options['stdin'] + else + let lines = split(a:options['stdin'], "\n") + endif + call writefile(lines, tempin) + let cmd .= ' < ' . xolox#misc#escape#shell(tempin) + endif + + " Redirect the standard output and/or standard error streams of the + " external process to temporary files? (only in synchronous mode) + if redirect_output + let tempout = tempname() + let temperr = tempname() + let cmd = printf('(%s) 1>%s 2>%s', cmd, xolox#misc#escape#shell(tempout), xolox#misc#escape#shell(temperr)) + endif + + " Use vim-shell or system() to execute the external command? + if use_dll + call xolox#misc#msg#debug("vim-misc %s: Executing external command using compiled DLL: %s", g:xolox#misc#version, cmd) + let exit_code = xolox#shell#execute_with_dll(cmd, async) + else + + " Enable asynchronous mode (very platform specific). + if async + if is_win + let cmd = printf('start /b %s', cmd) + elseif has('unix') + let cmd = printf('(%s) &', cmd) + else + call xolox#misc#msg#warn("vim-misc %s: I don't know how to execute the command %s asynchronously on your platform! Falling back to synchronous mode...", g:xolox#misc#version, cmd) + endif + endif + + " On UNIX we explicitly execute the command line using 'sh' instead of + " the default shell, because we assume that standard output and standard + " error can be redirected separately, but (t)csh does not support this + " (and it might be the default shell). + if has('unix') + call xolox#misc#msg#debug("vim-misc %s: Generated shell expression: %s", g:xolox#misc#version, cmd) + let cmd = printf('sh -c %s', xolox#misc#escape#shell(cmd)) + endif + + " Let the user know what's happening (in case they're interested). + if async && is_win + call xolox#misc#msg#debug("vim-misc %s: Executing external command using !start command: %s", g:xolox#misc#version, cmd) + silent execute '!' . cmd + else + call xolox#misc#msg#debug("vim-misc %s: Executing external command using system() function: %s", g:xolox#misc#version, cmd) + let arguments = [cmd] + if has_key(a:options, 'stdin') + if type(a:options['stdin']) == type([]) + call add(arguments, join(a:options['stdin'], "\n")) + else + call add(arguments, a:options['stdin']) + endif + endif + let stdout = call('system', arguments) + let exit_code = v:shell_error + endif + + endif + + " Return the results as a dictionary with one or more key/value pairs. + let result = {'command': cmd} + if !async + let result['exit_code'] = exit_code + " Get the standard output of the command. + if redirect_output + let result['stdout'] = s:readfile(tempout, 'standard output', a:options['command']) + elseif exists('stdout') + let result['stdout'] = split(stdout, "\n") + else + let result['stdout'] = [] + endif + " Get the standard error of the command. + if exists('temperr') + let result['stderr'] = s:readfile(temperr, 'standard error', a:options['command']) + else + let result['stderr'] = [] + endif + " If we just executed a synchronous command and the caller didn't + " specifically ask us *not* to check the exit code of the external + " command, we'll do so now. The idea here is that it should be easy + " to 'do the right thing'. + if get(a:options, 'check', 1) && exit_code != 0 + " Prepare an error message with enough details so the user can investigate. + let msg = printf("vim-misc %s: External command failed with exit code %d!", g:xolox#misc#version, result['exit_code']) + let msg .= printf("\nCommand line: %s", result['command']) + " If the external command reported an error, we'll include it in our message. + if !empty(result['stderr']) + " This is where we would normally expect to find an error message. + let msg .= printf("\nOutput on standard output stream:\n%s", join(result['stderr'], "\n")) + elseif !empty(result['stdout']) + " Exuberant Ctags on Windows XP reports errors on standard output :-x. + let msg .= printf("\nOutput on standard error stream:\n%s", join(result['stdout'], "\n")) + endif + throw msg + endif + endif + return result + + finally + " Cleanup any temporary files we created. + for name in ['tempin', 'tempout', 'temperr'] + if exists(name) + call delete({name}) + endif + endfor + endtry + +endfunction + +function! xolox#misc#os#can_use_dll() " {{{1 + " If a) we're on Microsoft Windows, b) the vim-shell plug-in is installed + " and c) the compiled DLL included in vim-shell works, we can use the + " vim-shell plug-in to execute external commands! Returns 1 (true) + " if we can use the DLL, 0 (false) otherwise. + let can_use_dll = 0 + try + let can_use_dll = xolox#shell#can_use_dll() + catch /^Vim\%((\a\+)\)\=:E117/ + " Silence E117. + endtry + return can_use_dll +endfunction + +function! s:readfile(fname, label, cmd) " {{{1 + try + return readfile(a:fname) + catch + call xolox#misc#msg#warn("vim-misc %s: Failed to read temporary file (%s) with %s of external command: %s! (external command: %s)", g:xolox#misc#version, a:fname, a:label, v:exception, a:cmd) + return [] + endtry +endfunction + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/misc/path.vim b/.vim/autoload/xolox/misc/path.vim new file mode 100644 index 0000000..6ff5589 --- /dev/null +++ b/.vim/autoload/xolox/misc/path.vim @@ -0,0 +1,278 @@ +" Pathname manipulation functions. +" +" Author: Peter Odding +" Last Change: July 7, 2014 +" URL: http://peterodding.com/code/vim/misc/ + +let s:windows_compatible = xolox#misc#os#is_win() + +function! xolox#misc#path#which(...) " {{{1 + " Scan the executable search path (`$PATH`) for one or more external + " programs. Expects one or more string arguments with program names. Returns + " a list with the absolute pathnames of all found programs. Here's an + " example: + " + " :echo xolox#misc#path#which('gvim', 'vim') + " ['/usr/local/bin/gvim', + " '/usr/bin/gvim', + " '/usr/local/bin/vim', + " '/usr/bin/vim'] + let extensions = s:windows_compatible ? split($PATHEXT, ';') : [''] + let matches = [] + let checked = {} + for program in a:000 + for directory in split($PATH, s:windows_compatible ? ';' : ':') + let directory = xolox#misc#path#absolute(directory) + if isdirectory(directory) + let found = 0 + for extension in extensions + let path = xolox#misc#path#merge(directory, program . extension) + if executable(path) + call add(matches, path) + let found = 1 + endif + endfor + if s:windows_compatible && ! found + " Maybe the extension is already contained in program; try without + " $PATHEXT. + let path = xolox#misc#path#merge(directory, program) + if executable(path) + call add(matches, path) + endif + endif + endif + endfor + endfor + return xolox#misc#list#unique(matches) +endfunction + +function! xolox#misc#path#split(path) " {{{1 + " Split a pathname (the first and only argument) into a list of pathname + " components. + " + " On Windows, pathnames starting with two slashes or backslashes are UNC + " paths where the leading slashes are significant... In this case we split + " like this: + " + " - Input: `'//server/share/directory'` + " - Result: `['//server', 'share', 'directory']` + " + " Everything except Windows is treated like UNIX until someone has a better + " suggestion :-). In this case we split like this: + " + " - Input: `'/foo/bar/baz'` + " - Result: `['/', 'foo', 'bar', 'baz']` + " + " To join a list of pathname components back into a single pathname string, + " use the `xolox#misc#path#join()` function. + if type(a:path) == type('') + if s:windows_compatible + if a:path =~ '^[\/][\/]' + " UNC pathname. + return split(a:path, '\%>2c[\/]\+') + else + " If it's not a UNC pathname we can simply split on slashes and + " backslashes, although we should preserve a leading slash (which + " denotes a pathname that is 'absolute to the current drive'). + let absolute = (a:path =~ '^[\/]') + let segments = split(a:path, '[\/]\+') + return absolute ? insert(segments, a:path[0]) : segments + endif + else + " Everything else is treated as UNIX. + let absolute = (a:path =~ '^/') + let segments = split(a:path, '/\+') + return absolute ? insert(segments, '/') : segments + endif + endif + return [] +endfunction + +function! xolox#misc#path#join(parts) " {{{1 + " Join a list of pathname components (the first and only argument) into a + " single pathname string. This is the counterpart to the + " `xolox#misc#path#split()` function and it expects a list of pathname + " components as returned by `xolox#misc#path#split()`. + if type(a:parts) == type([]) + if s:windows_compatible + return join(a:parts, xolox#misc#path#directory_separator()) + elseif get(a:parts, 0) == '/' + " Absolute path on UNIX (non-Windows). + return '/' . join(a:parts[1:], '/') + else + " Relative path on UNIX (non-Windows). + return join(a:parts, '/') + endif + endif + return '' +endfunction + +function! xolox#misc#path#directory_separator() " {{{1 + " Find the preferred directory separator for the platform and settings. + return exists('+shellslash') && &shellslash ? '/' : '\' +endfunction + +function! xolox#misc#path#absolute(path) " {{{1 + " Canonicalize and resolve a pathname, *regardless of whether it exists*. + " This is intended to support string comparison to determine whether two + " pathnames point to the same directory or file. + if type(a:path) == type('') + let path = a:path + " Make the pathname absolute. + if path =~ '^\~' + " Expand ~ to $HOME. + let path = $HOME . '/' . path[1:] + elseif xolox#misc#path#is_relative(path) + " Make relative pathnames absolute. + let path = getcwd() . '/' . path + endif + " Resolve symbolic links to find the canonical pathname. In my tests this + " also removes all symbolic pathname segments (`.' and `..'), even when + " the pathname does not exist. Also there used to be a bug in resolve() + " where it wouldn't resolve pathnames ending in a directory separator. + " Since it's not much trouble to work around, that's what we do. + let path = resolve(substitute(path, s:windows_compatible ? '[\/]\+$' : '/\+$', '', '')) + " Normalize directory separators (especially relevant on Windows). + let parts = xolox#misc#path#split(path) + if s:windows_compatible && parts[0] =~ '^[\/][\/]' + " Also normalize the two leading "directory separators" (I'm not + " sure what else to call them :-) in Windows UNC pathnames. + let parts[0] = repeat(xolox#misc#path#directory_separator(), 2) . parts[0][2:] + elseif s:windows_compatible && parts[0] =~ '^[\/]$' + " If a pathname is relative to the current drive we should add + " the drive letter in order to make the pathname absolute. + let parts[0] = matchstr(getcwd(), '^\a:') + endif + return xolox#misc#path#join(parts) + endif + return '' +endfunction + +function! xolox#misc#path#relative(path, base) " {{{1 + " Make an absolute pathname (the first argument) relative to a directory + " (the second argument). + let path = xolox#misc#path#split(a:path) + let base = xolox#misc#path#split(a:base) + while path != [] && base != [] && path[0] == base[0] + call remove(path, 0) + call remove(base, 0) + endwhile + let distance = repeat(['..'], len(base)) + return xolox#misc#path#join(distance + path) +endfunction + +function! xolox#misc#path#merge(parent, child, ...) " {{{1 + " Join a directory pathname and filename into a single pathname. + if type(a:parent) == type('') && type(a:child) == type('') + " TODO Use xolox#misc#path#is_relative()? + if s:windows_compatible + let parent = substitute(a:parent, '[\\/]\+$', '', '') + let child = substitute(a:child, '^[\\/]\+', '', '') + return parent . '\' . child + else + let parent = substitute(a:parent, '/\+$', '', '') + let child = substitute(a:child, '^/\+', '', '') + return parent . '/' . child + endif + endif + return '' +endfunction + +function! xolox#misc#path#commonprefix(paths) " {{{1 + " Find the common prefix of path components in a list of pathnames. + let common = xolox#misc#path#split(a:paths[0]) + for path in a:paths + let index = 0 + for segment in xolox#misc#path#split(path) + if len(common) <= index + break + elseif common[index] != segment + call remove(common, index, -1) + break + endif + let index += 1 + endfor + endfor + return xolox#misc#path#join(common) +endfunction + +function! xolox#misc#path#starts_with(a, b) " {{{1 + " Check whether the first pathname starts with the second pathname (expected + " to be a directory). This does not perform a regular string comparison; + " first it normalizes both pathnames, then it splits them into their + " pathname segments and then it compares the segments. + let a = xolox#misc#path#split(xolox#misc#path#absolute(a:a)) + let b = xolox#misc#path#split(xolox#misc#path#absolute(a:b)) + return a[0 : len(b) - 1] == b +endfunction + +function! xolox#misc#path#encode(path) " {{{1 + " Encode a pathname so it can be used as a filename. This uses URL encoding + " to encode special characters. + if s:windows_compatible + let mask = '[*|\\/:"<>?%]' + elseif xolox#misc#os#is_mac() + let mask = '[\\/%:]' + else + let mask = '[\\/%]' + endif + return substitute(a:path, mask, '\=printf("%%%x", char2nr(submatch(0)))', 'g') +endfunction + +function! xolox#misc#path#decode(encoded_path) " {{{1 + " Decode a pathname previously encoded with `xolox#misc#path#encode()`. + return substitute(a:encoded_path, '%\(\x\x\?\)', '\=nr2char("0x" . submatch(1))', 'g') +endfunction + +" xolox#misc#path#equals(a, b) - Check whether two pathnames point to the same file. {{{1 + +if s:windows_compatible + function! xolox#misc#path#equals(a, b) + return a:a ==? a:b || xolox#misc#path#absolute(a:a) ==? xolox#misc#path#absolute(a:b) + endfunction +else + function! xolox#misc#path#equals(a, b) + return a:a ==# a:b || xolox#misc#path#absolute(a:a) ==# xolox#misc#path#absolute(a:b) + endfunction +endif + +function! xolox#misc#path#is_relative(path) " {{{1 + " Returns true (1) when the pathname given as the first argument is + " relative, false (0) otherwise. + if a:path =~ '^\w\+://' + return 0 + elseif s:windows_compatible + return a:path !~ '^\(\w:\|[\\/]\)' + else + return a:path !~ '^/' + endif +endfunction + +function! xolox#misc#path#tempdir() " {{{1 + " Create a temporary directory and return the pathname of the directory. + if !exists('s:tempdir_counter') + let s:tempdir_counter = 1 + endif + if exists('*mkdir') + if s:windows_compatible + let template = $TMP . '\vim_tempdir_' + elseif filewritable('/tmp') == 2 + let template = '/tmp/vim_tempdir_' + endif + endif + if !exists('template') + throw "xolox#misc#path#tempdir() hasn't been implemented on your platform!" + endif + while 1 + let directory = template . s:tempdir_counter + try + call mkdir(directory, '', 0700) + return directory + catch /^Vim\%((\a\+)\)\=:E739/ + " Keep looking for a non-existing directory. + endtry + let s:tempdir_counter += 1 + endwhile +endfunction + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/misc/perm.vim b/.vim/autoload/xolox/misc/perm.vim new file mode 100644 index 0000000..851a74d --- /dev/null +++ b/.vim/autoload/xolox/misc/perm.vim @@ -0,0 +1,100 @@ +" Manipulation of UNIX file permissions. +" +" Author: Peter Odding +" Last Change: June 30, 2014 +" URL: http://peterodding.com/code/vim/misc/ +" +" Vim's [writefile()][] function cannot set file permissions for newly created +" files and although Vim script has a function to get file permissions (see +" [getfperm()][]) there is no equivalent for changing a file's permissions. +" +" This omission breaks the otherwise very useful idiom of updating a file by +" writing its new contents to a temporary file and then renaming the temporary +" file into place (which is as close as you're going to get to atomically +" updating a file's contents on UNIX) because the file's permissions will not +" be preserved! +" +" **Here's a practical example:** My [vim-easytags][] plug-in writes tags file +" updates to a temporary file and renames the temporary file into place. When +" I use `sudo -s` on Ubuntu Linux it preserves my environment variables so my +" `~/.vimrc` and the [vim-easytags][] plug-in are still loaded. Now when a +" tags file is written the file becomes owned by root (my effective user id in +" the `sudo` session). Once I leave the `sudo` session I can no longer update +" my tags file because it's now owned by root … ಠ_ಠ +" +" [getfperm()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#getfperm() +" [vim-easytags]: http://peterodding.com/code/vim/easytags/ +" [writefile()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#writefile() + +function! xolox#misc#perm#update(fname, contents) + " Atomically update a file's contents while preserving the owner, group and + " mode. The first argument is the pathname of the file to update (a string). + " The second argument is the list of lines to be written to the file. Writes + " the new contents to a temporary file and renames the temporary file into + " place, thereby preventing readers from reading a partially written file. + " Returns 1 if the file is successfully updated, 0 otherwise. + " + " Note that if `xolox#misc#perm#get()` and `xolox#misc#perm#set()` cannot be + " used to preserve the file owner/group/mode the file is still updated using + " a rename (for compatibility with non-UNIX systems and incompatible + " `/usr/bin/stat` implementations) so in that case you can still lose the + " file's owner/group/mode. + let starttime = xolox#misc#timer#start() + let temporary_file = printf('%s.tmp', a:fname) + call xolox#misc#msg#debug("vim-misc %s: Writing new contents of %s to temporary file %s ..", g:xolox#misc#version, a:fname, temporary_file) + if writefile(a:contents, temporary_file) == 0 + call xolox#misc#perm#set(temporary_file, xolox#misc#perm#get(a:fname)) + call xolox#misc#msg#debug("vim-misc %s: Replacing %s with %s ..", g:xolox#misc#version, a:fname, temporary_file) + if rename(temporary_file, a:fname) == 0 + call xolox#misc#timer#stop("vim-misc %s: Successfully updated %s using atomic rename in %s.", g:xolox#misc#version, a:fname, starttime) + return 1 + endif + endif + if filereadable(temporary_file) + call delete(temporary_file) + endif + return 0 +endfunction + +function! xolox#misc#perm#get(fname) + " Get the owner, group and permissions of the pathname given as the first + " argument. Returns an opaque value which you can later pass to + " `xolox#misc#perm#set()`. + let pathname = xolox#misc#path#absolute(a:fname) + if filereadable(pathname) + let command = printf('stat --format %s %s', '%U:%G:%a', shellescape(pathname)) + let result = xolox#misc#os#exec({'command': command, 'check': 0}) + if result['exit_code'] == 0 && len(result['stdout']) >= 1 + let tokens = split(result['stdout'][0], ':') + if len(tokens) == 3 + let [owner, group, mode] = tokens + let mode = '0' . mode + call xolox#misc#msg#debug("vim-misc %s: File %s has owner %s, group %s, mode %s.", g:xolox#misc#version, pathname, owner, group, mode) + return [owner, group, mode] + endif + endif + endif + return [] +endfunction + +function! xolox#misc#perm#set(fname, perms) + " Set the permissions (the second argument) of the pathname given as the + " first argument. Expects a permissions value created by + " `xolox#misc#perm#get()`. + if !empty(a:perms) + let pathname = xolox#misc#path#absolute(a:fname) + let [owner, group, mode] = a:perms + if s:run('chown %s:%s %s', owner, group, pathname) && s:run('chmod %s %s', mode, pathname) + call xolox#misc#msg#debug("vim-misc %s: Successfully set %s owner to %s, group to %s and permissions to %s.", g:xolox#misc#version, pathname, owner, group, mode) + return 1 + endif + endif + return 0 +endfunction + +function! s:run(command, ...) + let args = map(copy(a:000), 'shellescape(v:val)') + call insert(args, a:command, 0) + let result = xolox#misc#os#exec({'command': call('printf', args), 'check': 0}) + return result['exit_code'] == 0 +endfunction diff --git a/.vim/autoload/xolox/misc/persist.vim b/.vim/autoload/xolox/misc/persist.vim new file mode 100644 index 0000000..5b628fb --- /dev/null +++ b/.vim/autoload/xolox/misc/persist.vim @@ -0,0 +1,50 @@ +" Persist/recall Vim values from/to files. +" +" Author: Peter Odding +" Last Change: June 30, 2014 +" URL: http://peterodding.com/code/vim/misc/ +" +" Vim's [string()][] function can be used to serialize Vim script values like +" numbers, strings, lists, dictionaries and composites of them to a string +" which can later be evaluated using the [eval()][] function to turn it back +" into the original value. This Vim script provides functions to use these +" functions to persist and recall Vim values from/to files. This is very +" useful for communication between (possibly concurrent) Vim processes. + +function! xolox#misc#persist#load(filename, ...) " {{{1 + " Read a Vim value like a number, string, list or dictionary from a file + " using [readfile()][] and [eval()][]. The first argument is the filename of + " the file to read (a string). The optional second argument specifies the + " default value which is returned when the file can't be loaded. This + " function returns the loaded value or the default value (which itself + " defaults to the integer 0). + " + " [eval()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#eval() + " [readfile()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#readfile() + let default_value = exists('a:1') ? a:1 : 0 + try + let lines = readfile(a:filename) + return eval(join(lines, "\n")) + catch + return default_value + endtry +endfunction + +function! xolox#misc#persist#save(filename, value) " {{{1 + " Write a Vim value like a number, string, list or dictionary to a file + " using [string()][] and [writefile()][]. The first argument is the filename + " of the file to write (a string) and the second argument is the value to + " write (any value). + " + " This function writes the serialized value to an intermediate file which is + " then renamed into place atomically. This avoids issues with concurrent + " processes where for example a producer has written a partial file which is + " read by a consumer before the file is complete. In this case the consumer + " would read a corrupt value. The rename trick avoids this problem. + " + " [string()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#string() + " [writefile()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#writefile() + return xolox#misc#perm#update(a:filename, split(string(a:value), "\n")) +endfunction + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/misc/str.vim b/.vim/autoload/xolox/misc/str.vim new file mode 100644 index 0000000..edcab13 --- /dev/null +++ b/.vim/autoload/xolox/misc/str.vim @@ -0,0 +1,74 @@ +" String handling. +" +" Author: Peter Odding +" Last Change: September 17, 2014 +" URL: http://peterodding.com/code/vim/misc/ + +function! xolox#misc#str#slug(s) " {{{1 + " Convert a string to a "slug" - something that can be safely used in + " filenames and URLs without worrying about quoting/escaping of special + " characters. + return join(split(tolower(a:s), '\W\+'), '-') +endfunction + +function! xolox#misc#str#ucfirst(s) " {{{1 + " Uppercase the first character in a string (the first argument). + return substitute(a:s, '^.', '\U\0', '') +endfunction + +function! xolox#misc#str#unescape(s) " {{{1 + " Remove back slash escapes from a string (the first argument). + return substitute(a:s, '\\\(\_.\)', '\1', 'g') +endfunction + +function! xolox#misc#str#compact(s) " {{{1 + " Compact whitespace in a string (the first argument). + return join(split(a:s), " ") +endfunction + +function! xolox#misc#str#trim(s) " {{{1 + " Trim all whitespace from the start and end of a string (the first + " argument). + return substitute(a:s, '^\_s*\(.\{-}\)\_s*$', '\1', '') +endfunction + +function! xolox#misc#str#indent(text, num_spaces) " {{{1 + " Indent all lines in a multi-line string (the first argument) with a + " specific number of *space characters* (the second argument, an integer). + let lines = split(a:text, "\n") + let indent = repeat(' ', a:num_spaces) + let [idx, limit] = [0, len(lines)] + while idx < limit + if lines[idx] =~ '\S' + let lines[idx] = indent . lines[idx] + endif + let idx += 1 + endwhile + return join(lines, "\n") +endfunction + +function! xolox#misc#str#dedent(text) " {{{1 + " Remove common whitespace from a multi line string. + let lines = split(a:text, "\n") + " First we need to determine the common indentation of all non-empty lines. + for line in lines + if line =~ '\S' + let indent = matchstr(line, '^\s*') + if !exists('common_indent') + let common_indent = indent + elseif len(indent) < len(common_indent) + let common_indent = indent + endif + endif + endfor + " Now we will strip the common indentation. + let [idx, limit] = [0, len(lines)] + let pattern = '^' . common_indent + while idx < limit + let lines[idx] = substitute(lines[idx], pattern, '', '') + let idx += 1 + endwhile + return join(lines, "\n") +endfunction + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/misc/test.vim b/.vim/autoload/xolox/misc/test.vim new file mode 100644 index 0000000..df4d465 --- /dev/null +++ b/.vim/autoload/xolox/misc/test.vim @@ -0,0 +1,125 @@ +" Test runner & infrastructure for Vim plug-ins. +" +" Author: Peter Odding +" Last Change: June 2, 2013 +" URL: http://peterodding.com/code/vim/misc/ +" +" The Vim auto-load script `autoload/xolox/misc/test.vim` contains +" infrastructure that can be used to run an automated Vim plug-in test suite. +" It provides a framework for running test functions, keeping track of the +" test status, making assertions and reporting test results to the user. + +" The process handling tests cannot use the built-in "echo" command from the +" Windows shell because it has way too much idiosyncrasies for me to put up +" with. Seriously. Instead I'm using an "echo.exe" from the UnxUtils project. +if xolox#misc#os#is_win() + let g:xolox#misc#test#echo = xolox#misc#escape#shell(xolox#misc#path#merge(expand(':p:h'), 'echo.exe')) +else + let g:xolox#misc#test#echo = 'echo' +endif + +function! xolox#misc#test#reset() " {{{1 + " Reset counters for executed tests and passed/failed assertions. + let s:num_executed = 0 + let s:num_passed = 0 + let s:num_failed = 0 + let s:tests_started_at = xolox#misc#timer#start() +endfunction + +function! xolox#misc#test#summarize() " {{{1 + " Print a summary of test results, to be interpreted interactively. + call s:delimit_output() + call xolox#misc#timer#force("Took %s to run %s: %s passed, %s failed.", + \ s:tests_started_at, + \ xolox#misc#format#pluralize(s:num_executed, 'test', 'tests'), + \ xolox#misc#format#pluralize(s:num_passed, 'assertion', 'assertions'), + \ xolox#misc#format#pluralize(s:num_failed, 'assertion', 'assertions')) +endfunction + +function! xolox#misc#test#wrap(function) " {{{1 + " Call a function in a try/catch block and prevent exceptions from bubbling. + " The name of the function should be passed as the first and only argument; + " it should be a string containing the name of a Vim auto-load function. + let num_failed = s:num_failed + try + if s:num_passed + s:num_failed > 0 + call s:delimit_output() + endif + let test_name = split(a:function, '#')[-1] + let test_name = substitute(test_name, '_', ' ', 'g') + let test_name = substitute(test_name, '^.', '\U\0', '') + call xolox#misc#msg#info("Running test #%i: %s", s:num_executed + 1, test_name) + call call(a:function, []) + catch + call xolox#misc#msg#warn("Test %s raised exception:", a:function) + call xolox#misc#msg#warn("%s", v:exception) + call xolox#misc#msg#warn("(at %s)", v:throwpoint) + if num_failed == s:num_failed + " Make sure exceptions are counted as failures, but don't inflate the + " number of failed assertions when it's not needed (it can produce + " confusing test output). + call xolox#misc#test#failed() + endif + endtry + let s:num_executed += 1 +endfunction + +function! xolox#misc#test#passed() " {{{1 + " Record a test which succeeded. + let s:num_passed += 1 + call s:print_feedback() +endfunction + +function! xolox#misc#test#failed() " {{{1 + " Record a test which failed. + let s:num_failed += 1 + call s:print_feedback() +endfunction + +function! s:delimit_output() " {{{1 + " Print a delimiter between output of tests. + call xolox#misc#msg#info("%s", repeat("-", 40)) +endfunction + +function! s:print_feedback() " {{{1 + " Let the user know the status of the test suite. + call xolox#misc#msg#info("Test status: %s passed, %s failed ..", + \ xolox#misc#format#pluralize(s:num_passed, 'assertion', 'assertions'), + \ xolox#misc#format#pluralize(s:num_failed, 'assertion', 'assertions')) +endfunction + +function! xolox#misc#test#assert_true(expr) " {{{1 + " Check whether an expression is true. + if a:expr + call xolox#misc#test#passed() + else + call xolox#misc#test#failed() + let msg = "Expected value to be true, got %s instead" + throw printf(msg, string(a:expr)) + endif +endfunction + +function! xolox#misc#test#assert_equals(expected, received) " {{{1 + " Check whether two values are the same. + call xolox#misc#test#assert_same_type(a:expected, a:received) + if a:expected == a:received + call xolox#misc#test#passed() + else + call xolox#misc#test#failed() + let msg = "Expected value %s, received value %s!" + throw printf(msg, string(a:expected), string(a:received)) + endif +endfunction + +function! xolox#misc#test#assert_same_type(expected, received) " {{{1 + " Check whether two values are of the same type. + if type(a:expected) == type(a:received) + call xolox#misc#test#passed() + else + call xolox#misc#test#failed() + let msg = "Expected value of same type as %s, got value %s!" + throw printf(msg, string(a:expected), string(a:received)) + endif +endfunction + +call xolox#misc#test#reset() diff --git a/.vim/autoload/xolox/misc/tests.vim b/.vim/autoload/xolox/misc/tests.vim new file mode 100644 index 0000000..f3af1cb --- /dev/null +++ b/.vim/autoload/xolox/misc/tests.vim @@ -0,0 +1,301 @@ +" Tests for the miscellaneous Vim scripts. +" +" Author: Peter Odding +" Last Change: June , 2013 +" URL: http://peterodding.com/code/vim/misc/ +" +" The Vim auto-load script `autoload/xolox/misc/tests.vim` contains the +" automated test suite of the miscellaneous Vim scripts. Right now the +" coverage is not very high yet, but this will improve over time. + +let s:use_dll = 0 +let s:can_use_dll = xolox#misc#os#can_use_dll() + +function! xolox#misc#tests#run() " {{{1 + " Run the automated test suite of the miscellaneous Vim scripts. To be used + " interactively. Intended to be safe to execute irrespective of context. + call xolox#misc#test#reset() + " Run the tests. + call s:test_string_escaping() + call s:test_list_handling() + call s:test_option_handling() + call s:test_command_execution() + call s:test_string_handling() + call s:test_version_handling() + " Report a short summary to the user. + call xolox#misc#test#summarize() +endfunction + +function! s:wrap_exec_test(function) + " Wrapper for tests that use xolox#misc#os#exec(). If we're on Windows and + " the vim-shell plug-in is installed, the test will be run twice: Once with + " vim-shell disabled and once with vim-shell enabled. This makes sure that + " all code paths are tested as much as possible. + call xolox#misc#msg#debug("vim-misc %s: Temporarily disabling vim-shell so we can test vim-misc ..", g:xolox#misc#version) + let s:use_dll = 0 + call xolox#misc#test#wrap(a:function) + if s:can_use_dll + call xolox#misc#msg#debug("vim-misc %s: Re-enabling vim-shell so we can test that as well ..", g:xolox#misc#version) + let s:use_dll = 1 + call xolox#misc#test#wrap(a:function) + endif +endfunction + +" Tests for autoload/xolox/misc/escape.vim {{{1 + +function! s:test_string_escaping() + call xolox#misc#test#wrap('xolox#misc#tests#pattern_escaping') + call xolox#misc#test#wrap('xolox#misc#tests#substitute_escaping') + call s:wrap_exec_test('xolox#misc#tests#shell_escaping') +endfunction + +function! xolox#misc#tests#pattern_escaping() " {{{2 + " Test escaping of regular expression patterns with + " `xolox#misc#escape#pattern()`. + call xolox#misc#test#assert_equals('foo [qux] baz', substitute('foo [bar] baz', xolox#misc#escape#pattern('[bar]'), '[qux]', 'g')) + call xolox#misc#test#assert_equals('also very nasty', substitute('also ~ nasty', xolox#misc#escape#pattern('~'), 'very', 'g')) +endfunction + +function! xolox#misc#tests#substitute_escaping() " {{{2 + " Test escaping of substitution strings with + " `xolox#misc#escape#substitute()`. + call xolox#misc#test#assert_equals('nasty & tricky stuff', substitute('tricky stuff', 'tricky', xolox#misc#escape#substitute('nasty & tricky'), 'g')) +endfunction + +function! xolox#misc#tests#shell_escaping() " {{{2 + " Test escaping of shell arguments with `xolox#misc#escape#shell()`. + let expected_value = 'this < is > a | very " scary ^ string '' indeed' + let result = xolox#misc#os#exec({'command': g:xolox#misc#test#echo . ' ' . xolox#misc#escape#shell(expected_value), 'use_dll': s:use_dll}) + call xolox#misc#test#assert_equals(0, result['exit_code']) + call xolox#misc#test#assert_equals(0, result['exit_code']) + call xolox#misc#test#assert_same_type([], result['stdout']) + call xolox#misc#test#assert_equals(1, len(result['stdout'])) + " XXX On Windows using system() there's a trailing space I can't explain. + " However the point of this test was to show that all characters pass + " through unharmed, so for now I'll just ignore the space :-) + call xolox#misc#test#assert_equals(expected_value, xolox#misc#str#trim(result['stdout'][0])) +endfunction + +" Tests for autoload/xolox/misc/list.vim {{{1 + +function! s:test_list_handling() + call xolox#misc#test#wrap('xolox#misc#tests#making_a_list_unique') + call xolox#misc#test#wrap('xolox#misc#tests#binary_insertion') +endfunction + +function! xolox#misc#tests#making_a_list_unique() " {{{2 + " Test removing of duplicate values from lists with + " `xolox#misc#list#unique()`. + call xolox#misc#test#assert_equals([1, 2, 3, 4, 5], xolox#misc#list#unique([1, 1, 2, 3, 3, 4, 5, 5])) + " Should work for strings just as well. And it should preserve order. + call xolox#misc#test#assert_equals(['a', 'b', 'c'], xolox#misc#list#unique(['a', 'a', 'b', 'b', 'c'])) + " Just to make sure that lists without duplicate values pass through unharmed. + call xolox#misc#test#assert_equals([1, 2, 3, 4, 5], xolox#misc#list#unique([1, 2, 3, 4, 5])) +endfunction + +function! xolox#misc#tests#binary_insertion() " {{{2 + " Test the binary insertion algorithm implemented in + " `xolox#misc#list#binsert()`. + let list = ['a', 'B', 'e'] + " Insert 'c' (should end up between 'B' and 'e'). + call xolox#misc#list#binsert(list, 'c', 1) + call xolox#misc#test#assert_equals(['a', 'B', 'c', 'e'], list) + " Insert 'D' (should end up between 'c' and 'e'). + call xolox#misc#list#binsert(list, 'D', 1) + call xolox#misc#test#assert_equals(['a', 'B', 'c', 'D', 'e'], list) + " Insert 'f' (should end up after 'e', at the end). + call xolox#misc#list#binsert(list, 'f', 1) + call xolox#misc#test#assert_equals(['a', 'B', 'c', 'D', 'e', 'f'], list) +endfunction + +" Tests for autoload/xolox/misc/option.vim {{{1 + +function! s:test_option_handling() + call xolox#misc#test#wrap('xolox#misc#tests#getting_configuration_options') + call xolox#misc#test#wrap('xolox#misc#tests#splitting_of_multi_valued_options') + call xolox#misc#test#wrap('xolox#misc#tests#joining_of_multi_valued_options') +endfunction + +function! xolox#misc#tests#getting_configuration_options() " {{{2 + " Test getting of scoped plug-in configuration "options" with + " `xolox#misc#option#get()`. + let magic_name = 'a_variable_that_none_would_use' + call xolox#misc#test#assert_equals(0, xolox#misc#option#get(magic_name)) + " Test custom default values. + call xolox#misc#test#assert_equals([], xolox#misc#option#get(magic_name, [])) + " Set the option as a global variable. + let global_value = 'global variable' + let g:{magic_name} = global_value + call xolox#misc#test#assert_equals(global_value, xolox#misc#option#get(magic_name)) + " Set the option as a buffer local variable, thereby shadowing the global. + let local_value = 'buffer local variable' + let b:{magic_name} = local_value + call xolox#misc#test#assert_equals(local_value, xolox#misc#option#get(magic_name)) + " Sanity check that it's possible to unshadow as well. + unlet b:{magic_name} + call xolox#misc#test#assert_equals(global_value, xolox#misc#option#get(magic_name)) + " Cleanup after ourselves. + unlet g:{magic_name} + call xolox#misc#test#assert_equals(0, xolox#misc#option#get(magic_name)) +endfunction + +function! xolox#misc#tests#splitting_of_multi_valued_options() " {{{2 + " Test splitting of multi-valued Vim options with + " `xolox#misc#option#split()`. + call xolox#misc#test#assert_equals([], xolox#misc#option#split('')) + call xolox#misc#test#assert_equals(['just one value'], xolox#misc#option#split('just one value')) + call xolox#misc#test#assert_equals(['value 1', 'value 2'], xolox#misc#option#split('value 1,value 2')) + call xolox#misc#test#assert_equals(['value 1', 'value 2', 'tricky,value'], xolox#misc#option#split('value 1,value 2,tricky\,value')) +endfunction + +function! xolox#misc#tests#joining_of_multi_valued_options() " {{{2 + " Test joining of multi-valued Vim options with `xolox#misc#option#join()`. + call xolox#misc#test#assert_equals('', xolox#misc#option#join([])) + call xolox#misc#test#assert_equals('just one value', xolox#misc#option#join(['just one value'])) + call xolox#misc#test#assert_equals('value 1,value 2', xolox#misc#option#join(['value 1', 'value 2'])) + call xolox#misc#test#assert_equals('value 1,value 2,tricky\,value', xolox#misc#option#join(['value 1', 'value 2', 'tricky,value'])) +endfunction + +" Tests for autoload/xolox/misc/os.vim {{{1 + +function! s:test_command_execution() + call xolox#misc#test#wrap('xolox#misc#tests#finding_vim_on_the_search_path') + call s:wrap_exec_test('xolox#misc#tests#synchronous_command_execution') + call s:wrap_exec_test('xolox#misc#tests#synchronous_command_execution_with_stderr') + call s:wrap_exec_test('xolox#misc#tests#synchronous_command_execution_with_raising_of_errors') + call s:wrap_exec_test('xolox#misc#tests#synchronous_command_execution_without_raising_errors') + call s:wrap_exec_test('xolox#misc#tests#asynchronous_command_execution') +endfunction + +function! xolox#misc#tests#finding_vim_on_the_search_path() " {{{2 + " Test looking up Vim's executable on the search path using [v:progname] [] + " with `xolox#misc#os#find_vim()`. + " + " [v:progname]: http://vimdoc.sourceforge.net/htmldoc/eval.html#v:progname + let pathname = xolox#misc#os#find_vim() + call xolox#misc#test#assert_same_type('', pathname) + call xolox#misc#test#assert_true(executable(pathname)) +endfunction + +function! xolox#misc#tests#synchronous_command_execution() " {{{2 + " Test basic functionality of synchronous command execution with + " `xolox#misc#os#exec()`. + let result = xolox#misc#os#exec({'command': printf('%s output', g:xolox#misc#test#echo), 'use_dll': s:use_dll}) + call xolox#misc#test#assert_same_type({}, result) + call xolox#misc#test#assert_equals(0, result['exit_code']) + call xolox#misc#test#assert_equals(['output'], result['stdout']) +endfunction + +function! xolox#misc#tests#synchronous_command_execution_with_stderr() " {{{2 + " Test basic functionality of synchronous command execution with + " `xolox#misc#os#exec()` including the standard error stream (not available + " on Windows when vim-shell is not installed). + if !(xolox#misc#os#is_win() && !s:use_dll) + let result = xolox#misc#os#exec({'command': printf('%s output && %s errors >&2', g:xolox#misc#test#echo, g:xolox#misc#test#echo), 'use_dll': s:use_dll}) + call xolox#misc#test#assert_same_type({}, result) + call xolox#misc#test#assert_equals(0, result['exit_code']) + call xolox#misc#test#assert_equals(['output'], result['stdout']) + call xolox#misc#test#assert_equals(['errors'], result['stderr']) + endif +endfunction + +function! xolox#misc#tests#synchronous_command_execution_with_raising_of_errors() " {{{2 + " Test raising of errors during synchronous command execution with + " `xolox#misc#os#exec()`. + try + call xolox#misc#os#exec({'command': 'exit 1', 'use_dll': s:use_dll}) + call xolox#misc#test#assert_true(0) + catch + call xolox#misc#test#assert_true(1) + endtry +endfunction + +function! xolox#misc#tests#synchronous_command_execution_without_raising_errors() " {{{2 + " Test synchronous command execution without raising of errors with + " `xolox#misc#os#exec()`. + try + let result = xolox#misc#os#exec({'command': 'exit 42', 'check': 0, 'use_dll': s:use_dll}) + call xolox#misc#test#assert_true(1) + call xolox#misc#test#assert_equals(42, result['exit_code']) + catch + call xolox#misc#test#assert_true(0) + endtry +endfunction + +function! xolox#misc#tests#asynchronous_command_execution() " {{{2 + " Test the basic functionality of asynchronous command execution with + " `xolox#misc#os#exec()`. This runs the external command `mkdir` and tests + " that the side effect of creating the directory takes place. This might + " seem like a peculiar choice, but it's one of the few 100% portable + " commands (Windows + UNIX) that doesn't involve input/output streams. + let temporary_directory = xolox#misc#path#tempdir() + let random_name = printf('%i', localtime()) + let expected_directory = xolox#misc#path#merge(temporary_directory, random_name) + let command = 'mkdir ' . xolox#misc#escape#shell(expected_directory) + let result = xolox#misc#os#exec({'command': command, 'async': 1, 'use_dll': s:use_dll}) + call xolox#misc#test#assert_same_type({}, result) + " Make sure the command is really executed. + let timeout = localtime() + 30 + while !isdirectory(expected_directory) && localtime() < timeout + sleep 500 m + endwhile + call xolox#misc#test#assert_true(isdirectory(expected_directory)) +endfunction + +" Tests for autoload/xolox/misc/str.vim {{{1 + +function! s:test_string_handling() + call xolox#misc#test#wrap('xolox#misc#tests#string_case_transformation') + call xolox#misc#test#wrap('xolox#misc#tests#string_whitespace_compaction') + call xolox#misc#test#wrap('xolox#misc#tests#string_whitespace_trimming') + call xolox#misc#test#wrap('xolox#misc#tests#multiline_string_dedent') +endfunction + +function! xolox#misc#tests#string_case_transformation() + " Test string case transformation with `xolox#misc#str#ucfirst()`. + call xolox#misc#test#assert_equals('Foo', xolox#misc#str#ucfirst('foo')) + call xolox#misc#test#assert_equals('BAR', xolox#misc#str#ucfirst('BAR')) +endfunction + +function! xolox#misc#tests#string_whitespace_compaction() + " Test compaction of whitespace in strings with `xolox#misc#str#compact()`. + call xolox#misc#test#assert_equals('foo bar baz', xolox#misc#str#compact(' foo bar baz ')) + call xolox#misc#test#assert_equals('test', xolox#misc#str#compact("\ntest ")) +endfunction + +function! xolox#misc#tests#string_whitespace_trimming() + " Test trimming of whitespace in strings with `xolox#misc#str#trim()`. + call xolox#misc#test#assert_equals('foo bar baz', xolox#misc#str#trim("\nfoo bar baz ")) +endfunction + +function! xolox#misc#tests#multiline_string_dedent() + " Test dedenting of multi-line strings with `xolox#misc#str#dedent()`. + call xolox#misc#test#assert_equals('test', xolox#misc#str#dedent(' test')) + call xolox#misc#test#assert_equals("1\n\n2", xolox#misc#str#dedent(" 1\n\n 2")) + call xolox#misc#test#assert_equals("1\n\n 2", xolox#misc#str#dedent(" 1\n\n 2")) +endfunction + +" Tests for autoload/xolox/misc/version.vim {{{1 + +function! s:test_version_handling() + call xolox#misc#test#wrap('xolox#misc#tests#version_string_parsing') + call xolox#misc#test#wrap('xolox#misc#tests#version_string_comparison') +endfunction + +function! xolox#misc#tests#version_string_parsing() " {{{2 + " Test parsing of version strings with `xolox#misc#version#parse()`. + call xolox#misc#test#assert_equals([1], xolox#misc#version#parse('1')) + call xolox#misc#test#assert_equals([1, 5], xolox#misc#version#parse('1.5')) + call xolox#misc#test#assert_equals([1, 22, 3333, 44444, 55555], xolox#misc#version#parse('1.22.3333.44444.55555')) + call xolox#misc#test#assert_equals([1, 5], xolox#misc#version#parse('1x.5y')) +endfunction + +function! xolox#misc#tests#version_string_comparison() " {{{2 + " Test comparison of version strings with `xolox#misc#version#at_least()`. + call xolox#misc#test#assert_true(xolox#misc#version#at_least('1', '1')) + call xolox#misc#test#assert_true(!xolox#misc#version#at_least('1', '0')) + call xolox#misc#test#assert_true(xolox#misc#version#at_least('1', '2')) + call xolox#misc#test#assert_true(xolox#misc#version#at_least('1.2.3', '1.2.3')) + call xolox#misc#test#assert_true(!xolox#misc#version#at_least('1.2.3', '1.2')) + call xolox#misc#test#assert_true(xolox#misc#version#at_least('1.2.3', '1.2.4')) +endfunction diff --git a/.vim/autoload/xolox/misc/timer.vim b/.vim/autoload/xolox/misc/timer.vim new file mode 100644 index 0000000..e97a186 --- /dev/null +++ b/.vim/autoload/xolox/misc/timer.vim @@ -0,0 +1,130 @@ +" Timing of long during operations. +" +" Author: Peter Odding +" Last Change: July 19, 2014 +" URL: http://peterodding.com/code/vim/misc/ + +if !exists('g:timer_enabled') + let g:timer_enabled = 0 +endif + +if !exists('g:timer_verbosity') + let g:timer_verbosity = 1 +endif + +let s:has_reltime = has('reltime') +let s:unique_marker = 'xolox#misc#timer#value' + +function! xolox#misc#timer#resumable() " {{{1 + " Create a resumable timer object. This returns an object (a dictionary with + " functions) with the following "methods": + " + " - `start()` instructs the timer object to start counting elapsed time + " (when a timer object is created it is not automatically started). + " + " - `stop()` instructs the timer object to stop counting elapsed time. + " This adds the time elapsed since `start()` was last called to the + " total elapsed time. This method will raise an error if called out of + " sequence. + " + " - `format()` takes the total elapsed time and reports it as a string + " containing a formatted floating point number. + " + " Timer objects are meant to accurately time short running operations so + " they're dependent on Vim's [reltime()][] and [reltimestr()][] functions. + " In order to make it possible to use timer objects in my Vim plug-ins + " unconditionally there's a fall back to [localtime()][] when [reltime()][] + " is not available. In this mode the timer objects are not very useful but + " at least they shouldn't raise errors. + " + " [localtime()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#localtime() + " [reltime()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#reltime() + " [reltimestr()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#reltimestr() + let object = {'total': [0, 0]} + function object.start() dict + if s:has_reltime + let self.current = reltime() + else + let self.current = localtime() + endif + endfunction + function object.stop() dict + if empty(get(self, 'current')) + throw "timer.stop() called on a timer that was never started!" + endif + if s:has_reltime + let elapsed_time_string = xolox#misc#str#trim(reltimestr(reltime(self.current))) + " This is a bit silly (converting to a string and then parsing that) but + " the value of reltime() is documented as being platform specific... + let [seconds, microseconds] = split(elapsed_time_string, '\.') + let self.total[0] += substitute(seconds, '^0*', '', '') + let self.total[1] += substitute(microseconds, '^0*', '', '') + let self.current = [] + else + let self.total[0] += localtime() - self.current + let self.current = 0 + endif + endfunction + function object.format() dict + let seconds = self.total[0] + let microseconds = self.total[1] + if microseconds >= 1000000 + let additional_seconds = microseconds / 1000000 + let seconds += additional_seconds + let microseconds -= additional_seconds * 1000000 + endif + return printf('%i.%06i', seconds, microseconds) + endfunction + return object +endfunction + +function! xolox#misc#timer#start() " {{{1 + " Start a timer. This returns a list which can later be passed to + " `xolox#misc#timer#stop()`. + return [s:unique_marker, s:has_reltime ? reltime() : localtime()] +endfunction + +function! xolox#misc#timer#stop(...) " {{{1 + " Show a formatted debugging message to the user, if the user has enabled + " increased verbosity by setting Vim's ['verbose'] [verbose] option to one + " (1) or higher. + " + " This function has the same argument handling as Vim's [printf()] [printf] + " function with one difference: At the point where you want the elapsed time + " to be embedded, you write `%s` and you pass the list returned by + " `xolox#misc#timer#start()` as an argument. + " + " [verbose]: http://vimdoc.sourceforge.net/htmldoc/options.html#'verbose' + " [printf]: http://vimdoc.sourceforge.net/htmldoc/eval.html#printf() + if (g:timer_enabled || &verbose >= g:timer_verbosity) + call call('xolox#misc#msg#info', map(copy(a:000), 'xolox#misc#timer#convert(v:val)')) + endif +endfunction + +function! xolox#misc#timer#force(...) " {{{1 + " Show a formatted message to the user. This function has the same argument + " handling as Vim's [printf()] [printf] function with one difference: At the + " point where you want the elapsed time to be embedded, you write `%s` and + " you pass the list returned by `xolox#misc#timer#start()` as an argument. + call call('xolox#misc#msg#info', map(copy(a:000), 'xolox#misc#timer#convert(v:val)')) +endfunction + +function! xolox#misc#timer#convert(value) " {{{1 + " Convert the value returned by `xolox#misc#timer#start()` to a string + " representation of the elapsed time since `xolox#misc#timer#start()` was + " called. Other values are returned unmodified (this allows using it with + " Vim's [map()][] function). + " + " [map()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#map() + if type(a:value) == type([]) && len(a:value) == 2 && a:value[0] == s:unique_marker + if s:has_reltime + let ts = xolox#misc#str#trim(reltimestr(reltime(a:value[1]))) + else + let ts = localtime() - a:value[1] + endif + return xolox#misc#format#timestamp(ts) + endif + return a:value +endfunction + +" vim: ts=2 sw=2 et diff --git a/.vim/autoload/xolox/misc/version.vim b/.vim/autoload/xolox/misc/version.vim new file mode 100644 index 0000000..0f3ad67 --- /dev/null +++ b/.vim/autoload/xolox/misc/version.vim @@ -0,0 +1,34 @@ +" Version string handling. +" +" Author: Peter Odding +" Last Change: June 22, 2013 +" URL: http://peterodding.com/code/vim/misc/ + +function! xolox#misc#version#parse(version_string) + " Convert a version string to a list of integers. + let result = map(split(a:version_string, '\.'), 'v:val + 0') + call xolox#misc#msg#debug("vim-misc %s: Parsed version string %s into %s.", g:xolox#misc#version, string(a:version_string), string(result)) + return result +endfunction + +function! xolox#misc#version#at_least(expected_version, available_version) + " Check whether the second version string is equal to or greater than the + " first version string. Returns 1 (true) when it is, 0 (false) otherwise. + let expected_version = xolox#misc#version#parse(a:expected_version) + let available_version = xolox#misc#version#parse(a:available_version) + for idx in range(max([len(expected_version), len(available_version)])) + let expected_number = get(expected_version, idx, 0) + let available_number = get(available_version, idx, 0) + if available_number > expected_number + call xolox#misc#msg#debug("vim-misc %s: Available version (%s) is higher than expected version (%s).", g:xolox#misc#version, a:available_version, a:expected_version) + return 1 + elseif available_number < expected_number + call xolox#misc#msg#debug("vim-misc %s: Available version (%s) is lower than expected version (%s).", g:xolox#misc#version, a:available_version, a:expected_version) + return 0 + endif + endfor + call xolox#misc#msg#debug("vim-misc %s: Available version (%s) is equal to expected version (%s).", g:xolox#misc#version, a:available_version, a:expected_version) + return 1 +endfunction + +" vim: ts=2 sw=2 et diff --git a/.vim/colors/candycode.vim b/.vim/colors/candycode.vim new file mode 100644 index 0000000..3800d9d --- /dev/null +++ b/.vim/colors/candycode.vim @@ -0,0 +1,174 @@ +" Vim color file -- candycode +" Maintainer: Justin Constantino +" Last Change: 2006 Aug 12 + +set background=dark +highlight clear +let g:colors_name="candycode" + +let save_cpo = &cpo +set cpo&vim + +" basic highlight groups (:help highlight-groups) {{{ + +" text {{{ + +hi Normal guifg=#ffffff guibg=#050505 gui=NONE + \ ctermfg=white ctermbg=black cterm=NONE + +hi Folded guifg=#c2bfa5 guibg=#050505 gui=underline + \ ctermfg=lightgray ctermbg=black cterm=underline + +hi LineNr guifg=#928c75 guibg=NONE gui=NONE + \ ctermfg=darkgray ctermbg=NONE cterm=NONE + +hi Directory guifg=#00bbdd guibg=NONE gui=NONE + \ ctermfg=cyan ctermbg=NONE cterm=NONE +hi NonText guifg=#77ff22 guibg=NONE gui=bold + \ ctermfg=yellow ctermbg=NONE cterm=NONE +hi SpecialKey guifg=#559933 guibg=NONE gui=NONE + \ ctermfg=green ctermbg=NONE cterm=NONE + +hi SpellBad guifg=NONE guibg=NONE gui=undercurl + \ ctermfg=white ctermbg=darkred guisp=#ff0011 +hi SpellCap guifg=NONE guibg=NONE gui=undercurl + \ ctermfg=white ctermbg=darkblue guisp=#0044ff +hi SpellLocal guifg=NONE guibg=NONE gui=undercurl + \ ctermfg=black ctermbg=cyan guisp=#00dd99 +hi SpellRare guifg=NONE guibg=NONE gui=undercurl + \ ctermfg=white ctermbg=darkmagenta guisp=#ff22ee + +hi DiffAdd guifg=#ffffff guibg=#126493 gui=NONE + \ ctermfg=white ctermbg=darkblue cterm=NONE +hi DiffChange guifg=#000000 guibg=#976398 gui=NONE + \ ctermfg=black ctermbg=darkmagenta cterm=NONE +hi DiffDelete guifg=#000000 guibg=#be1923 gui=bold + \ ctermfg=black ctermbg=red cterm=bold +hi DiffText guifg=#ffffff guibg=#976398 gui=bold + \ ctermfg=white ctermbg=green cterm=bold + +" }}} +" borders / separators / menus {{{ + +hi FoldColumn guifg=#c8bcb9 guibg=#786d65 gui=bold + \ ctermfg=lightgray ctermbg=darkgray cterm=NONE +hi SignColumn guifg=#c8bcb9 guibg=#786d65 gui=bold + \ ctermfg=lightgray ctermbg=darkgray cterm=NONE + +hi Pmenu guifg=#000000 guibg=#a6a190 gui=NONE + \ ctermfg=white ctermbg=darkgray cterm=NONE +hi PmenuSel guifg=#ffffff guibg=#133293 gui=NONE + \ ctermfg=white ctermbg=lightblue cterm=NONE +hi PmenuSbar guifg=NONE guibg=#555555 gui=NONE + \ ctermfg=black ctermbg=black cterm=NONE +hi PmenuThumb guifg=NONE guibg=#cccccc gui=NONE + \ ctermfg=gray ctermbg=gray cterm=NONE + +hi StatusLine guifg=#000000 guibg=#c2bfa5 gui=bold + \ ctermfg=black ctermbg=white cterm=bold +hi StatusLineNC guifg=#444444 guibg=#c2bfa5 gui=NONE + \ ctermfg=darkgray ctermbg=white cterm=NONE +hi WildMenu guifg=#ffffff guibg=#133293 gui=bold + \ ctermfg=white ctermbg=darkblue cterm=bold +hi VertSplit guifg=#c2bfa5 guibg=#c2bfa5 gui=NONE + \ ctermfg=white ctermbg=white cterm=NONE + +hi TabLine guifg=#000000 guibg=#c2bfa5 gui=NONE + \ ctermfg=black ctermbg=white cterm=NONE +hi TabLineFill guifg=#000000 guibg=#c2bfa5 gui=NONE + \ ctermfg=black ctermbg=white cterm=NONE +hi TabLineSel guifg=#ffffff guibg=#133293 gui=NONE + \ ctermfg=white ctermbg=black cterm=NONE + +"hi Menu +"hi Scrollbar +"hi Tooltip + +" }}} +" cursor / dynamic / other {{{ + +hi Cursor guifg=#000000 guibg=#ffff99 gui=NONE + \ ctermfg=black ctermbg=white cterm=NONE +hi CursorIM guifg=#000000 guibg=#aaccff gui=NONE + \ ctermfg=black ctermbg=white cterm=reverse +hi CursorLine guifg=NONE guibg=#1b1b1b gui=NONE + \ ctermfg=NONE ctermbg=NONE cterm=NONE +hi CursorColumn guifg=NONE guibg=#1b1b1b gui=NONE + \ ctermfg=NONE ctermbg=NONE cterm=NONE + +hi Visual guifg=#ffffff guibg=#606070 gui=NONE + \ ctermfg=white ctermbg=lightblue cterm=NONE + +hi IncSearch guifg=#000000 guibg=#eedd33 gui=bold + \ ctermfg=white ctermbg=yellow cterm=NONE +hi Search guifg=#efefd0 guibg=#937340 gui=NONE + \ ctermfg=white ctermbg=darkgreen cterm=NONE + +hi MatchParen guifg=NONE guibg=#3377aa gui=NONE + \ ctermfg=white ctermbg=blue cterm=NONE + +"hi VisualNOS + +" }}} +" listings / messages {{{ + +hi ModeMsg guifg=#eecc18 guibg=NONE gui=NONE + \ ctermfg=yellow ctermbg=NONE cterm=NONE +hi Title guifg=#dd4452 guibg=NONE gui=bold + \ ctermfg=red ctermbg=NONE cterm=bold +hi Question guifg=#66d077 guibg=NONE gui=NONE + \ ctermfg=green ctermbg=NONE cterm=NONE +hi MoreMsg guifg=#39d049 guibg=NONE gui=NONE + \ ctermfg=green ctermbg=NONE cterm=NONE + +hi ErrorMsg guifg=#ffffff guibg=#ff0000 gui=bold + \ ctermfg=white ctermbg=red cterm=bold +hi WarningMsg guifg=#ccae22 guibg=NONE gui=bold + \ ctermfg=yellow ctermbg=NONE cterm=bold + +" }}} + +" }}} +" syntax highlighting groups (:help group-name) {{{ + +hi Comment guifg=#ff9922 guibg=NONE gui=NONE + \ ctermfg=brown ctermbg=NONE cterm=NONE + +hi Constant guifg=#ff6050 guibg=NONE gui=NONE + \ ctermfg=red ctermbg=NONE cterm=NONE +hi Boolean guifg=#ff6050 guibg=NONE gui=bold + \ ctermfg=red ctermbg=NONE cterm=bold + +hi Identifier guifg=#eecc44 guibg=NONE gui=NONE + \ ctermfg=yellow ctermbg=NONE cterm=NONE + +hi Statement guifg=#66d077 guibg=NONE gui=bold + \ ctermfg=green ctermbg=NONE cterm=bold + +hi PreProc guifg=#bb88dd guibg=NONE gui=NONE + \ ctermfg=darkmagenta ctermbg=NONE cterm=NONE + +hi Type guifg=#4093cc guibg=NONE gui=bold + \ ctermfg=lightblue ctermbg=NONE cterm=bold + +hi Special guifg=#9999aa guibg=NONE gui=bold + \ ctermfg=lightgray ctermbg=NONE cterm=bold + +hi Underlined guifg=#80a0ff guibg=NONE gui=underline + \ ctermfg=NONE ctermbg=NONE cterm=underline + \ term=underline + +hi Ignore guifg=#888888 guibg=NONE gui=NONE + \ ctermfg=darkgray ctermbg=NONE cterm=NONE + +hi Error guifg=#ffffff guibg=#ff0000 gui=NONE + \ ctermfg=white ctermbg=red cterm=NONE + +hi Todo guifg=#ffffff guibg=#ee7700 gui=bold + \ ctermfg=black ctermbg=yellow cterm=bold + +" }}} + +let &cpo = save_cpo + +" vim: fdm=marker fdl=0 diff --git a/.vim/colors/distinguished.vim b/.vim/colors/distinguished.vim new file mode 100644 index 0000000..db3af12 --- /dev/null +++ b/.vim/colors/distinguished.vim @@ -0,0 +1,181 @@ +" Author: Kim Silkebækken +" Source repository: https://github.com/Lokaltog/vim-distinguished + +" Initialization {{{ + set background=dark + + hi clear + if exists('syntax_on') + syntax reset + endif + + let g:colors_name = 'distinguished' + + if ! has('gui_running') + if &t_Co != 256 + echoe 'The ' . g:colors_name . ' color scheme requires gvim or a 256-color terminal' + + finish + endif + endif +" }}} +" Color dictionary parser {{{ + function! s:ColorDictParser(color_dict) + for [group, group_colors] in items(a:color_dict) + exec 'hi ' . group + \ . ' ctermfg=' . (group_colors[0] == '' ? 'NONE' : group_colors[0]) + \ . ' ctermbg=' . (group_colors[1] == '' ? 'NONE' : group_colors[1]) + \ . ' cterm=' . (group_colors[2] == '' ? 'NONE' : group_colors[2]) + \ + \ . ' guifg=' . (group_colors[3] == '' ? 'NONE' : '#' . group_colors[3]) + \ . ' guibg=' . (group_colors[4] == '' ? 'NONE' : '#' . group_colors[4]) + \ . ' gui=' . (group_colors[5] == '' ? 'NONE' : group_colors[5]) + endfor + endfunction +" }}} + +" | Highlight group | CTFG | CTBG | CTAttributes | || | GUIFG | GUIBG | GUIAttributes | +" |--------------------------------|-------|-------|-----------------| || |---------|----------|-----------------| +call s:ColorDictParser({ + \ 'Normal' : [ 231, 16, '', 'ffffff', '000000', ''] + \ , 'Visual' : [ 240, 253, '', '585858', 'dadada', ''] + \ + \ , 'Cursor' : [ '', '', '', 'ffffff', 'dd4010', ''] + \ , 'lCursor' : [ '', '', '', 'ffffff', '89b6e2', ''] + \ + \ , 'CursorLine' : [ '', 236, '', '', '3a3a3a', ''] + \ , 'CursorLineNr' : [ 231, 240, '', 'ffffff', '585858', ''] + \ , 'CursorColumn' : [ 231, 237, '', 'ffffff', '3a3a3a', ''] + \ + \ , 'Folded' : [ 249, 234, '', 'b2b2b2', '1c1c1c', ''] + \ , 'FoldColumn' : [ 243, 234, '', '767676', '1c1c1c', ''] + \ , 'SignColumn' : [ 231, 233, 'bold', 'ffffff', '121212', 'bold'] + \ , 'ColorColumn' : [ '', 233, '', '', '262626', ''] + \ + \ , 'StatusLine' : [ 231, 236, 'bold', 'ffffff', '303030', 'bold'] + \ , 'StatusLineNC' : [ 244, 232, '', '808080', '080808', ''] + \ + \ , 'LineNr' : [ 243, 235, '', '767676', '262626', ''] + \ , 'VertSplit' : [ 240, '', '', '585858', '1c1c1c', ''] + \ + \ , 'WildMenu' : [ 234, 231, '', '1c1c1c', 'ffffff', ''] + \ , 'Directory' : [ 143, '', 'bold', 'afaf5f', '', 'bold'] + \ , 'Underlined' : [ 130, '', '', 'af5f00', '', ''] + \ + \ , 'Question' : [ 74, '', 'bold', '5fafd7', '', 'bold'] + \ , 'MoreMsg' : [ 214, '', 'bold', 'ffaf00', '', 'bold'] + \ , 'WarningMsg' : [ 202, '', 'bold', 'ff5f00', '', 'bold'] + \ , 'ErrorMsg' : [ 196, '', 'bold', 'ff0000', '', 'bold'] + \ + \ , 'Comment' : [ 243, 233, '', '767676', '121212', ''] + \ , 'vimCommentTitleLeader' : [ 250, 233, '', 'bcbcbc', '121212', ''] + \ , 'vimCommentTitle' : [ 250, 233, '', 'bcbcbc', '121212', ''] + \ , 'vimCommentString' : [ 245, 233, '', '8a8a8a', '121212', ''] + \ + \ , 'TabLine' : [ 231, 238, '', 'ffffff', '444444', ''] + \ , 'TabLineSel' : [ 255, '', 'bold', 'eeeeee', '', 'bold'] + \ , 'TabLineFill' : [ 240, 238, '', '585858', '444444', ''] + \ , 'TabLineNumber' : [ 160, 238, 'bold', 'd70000', '444444', 'bold'] + \ , 'TabLineClose' : [ 245, 238, 'bold', '8a8a8a', '444444', 'bold'] + \ + \ , 'SpellCap' : [ 231, 31, 'bold', 'ffffff', '0087af', 'bold'] + \ + \ , 'SpecialKey' : [ 239, '', '', '4e4e4e', '', ''] + \ , 'NonText' : [ 88, '', '', '870000', '', ''] + \ , 'MatchParen' : [ 231, 25, 'bold', 'ffffff', '005faf', 'bold'] + \ + \ , 'Constant' : [ 137, '', 'bold', 'af875f', '', 'bold'] + \ , 'Special' : [ 150, '', '', 'afd787', '', ''] + \ , 'Identifier' : [ 66, '', 'bold', '5f8787', '', 'bold'] + \ , 'Statement' : [ 186, '', 'bold', 'd7d787', '', 'bold'] + \ , 'PreProc' : [ 247, '', '', '9e9e9e', '', ''] + \ , 'Type' : [ 67, '', 'bold', '5f87af', '', 'bold'] + \ , 'String' : [ 143, '', '', 'afaf5f', '', ''] + \ , 'Number' : [ 173, '', '', 'd7875f', '', ''] + \ , 'Define' : [ 173, '', '', 'd7875f', '', ''] + \ , 'Error' : [ 208, 124, '', 'ff8700', 'af0000', ''] + \ , 'Function' : [ 179, '', '', 'd7af5f', '', ''] + \ , 'Include' : [ 173, '', '', 'd7875f', '', ''] + \ , 'PreCondit' : [ 173, '', '', 'd7875f', '', ''] + \ , 'Keyword' : [ 173, '', '', 'd7875f', '', ''] + \ , 'Search' : [ 231, 131, '', '000000', 'ffff5f', 'underline,bold'] + \ , 'Title' : [ 231, '', '', 'ffffff', '', ''] + \ , 'Delimiter' : [ 246, '', '', '949494', '', ''] + \ , 'StorageClass' : [ 187, '', '', 'd7d7af', '', ''] + \ , 'Operator' : [ 180, '', '', 'd7af87', '', ''] + \ + \ , 'TODO' : [ 228, 94, 'bold', 'ffff87', '875f00', 'bold'] + \ + \ , 'SyntasticWarning' : [ 220, 94, '', 'ffff87', '875f00', 'bold'] + \ , 'SyntasticError' : [ 202, 52, '', 'ffff87', '875f00', 'bold'] + \ + \ , 'Pmenu' : [ 248, 240, '', 'a8a8a8', '585858', ''] + \ , 'PmenuSel' : [ 253, 245, '', 'dadada', '8a8a8a', ''] + \ , 'PmenuSbar' : [ 253, 248, '', 'dadada', 'a8a8a8', ''] + \ + \ , 'phpEOL' : [ 245, '', '', 'dadada', '', ''] + \ , 'phpStringDelim' : [ 94, '', '', '875f00', '', ''] + \ , 'phpDelimiter' : [ 160, '', '', 'd70000', '', ''] + \ , 'phpFunctions' : [ 221, '', 'bold', 'ffd75f', '', 'bold'] + \ , 'phpBoolean' : [ 172, '', 'bold', 'd78700', '', 'bold'] + \ , 'phpOperator' : [ 215, '', '', 'ffaf5f', '', ''] + \ , 'phpMemberSelector' : [ 138, '', 'bold', 'af8787', '', 'bold'] + \ , 'phpParent' : [ 227, '', '', 'ffff5f', '', ''] + \ + \ , 'PHPClassTag' : [ 253, '', '', 'dadada', '', ''] + \ , 'PHPInterfaceTag' : [ 253, '', '', 'dadada', '', ''] + \ , 'PHPFunctionTag' : [ 222, '', 'bold', 'ffd787', '', 'bold'] + \ + \ , 'pythonDocString' : [ 240, 233, '', '585858', '121212', ''] + \ , 'pythonDocStringTitle' : [ 245, 233, '', 'dadada', '121212', ''] + \ , 'pythonRun' : [ 65, '', '', '5f875f', '', ''] + \ , 'pythonBuiltinObj' : [ 67, '', 'bold', '5f87af', '', 'bold'] + \ , 'pythonSelf' : [ 250, '', 'bold', 'bcbcbc', '', 'bold'] + \ , 'pythonFunction' : [ 179, '', 'bold', 'd7af5f', '', 'bold'] + \ , 'pythonClass' : [ 221, '', 'bold', 'ffd75f', '', 'bold'] + \ , 'pythonExClass' : [ 130, '', '', 'af5f00', '', ''] + \ , 'pythonException' : [ 130, '', 'bold', 'af5f00', '', 'bold'] + \ , 'pythonOperator' : [ 186, '', '', 'd7d787', '', ''] + \ , 'pythonPreCondit' : [ 152, '', 'bold', 'afd7d7', '', 'bold'] + \ , 'pythonDottedName' : [ 166, '', '', 'd75f00', '', ''] + \ , 'pythonDecorator' : [ 124, '', 'bold', 'af0000', '', 'bold'] + \ + \ , 'PythonInterfaceTag' : [ 109, '', '', '87afaf', '', ''] + \ , 'PythonClassTag' : [ 221, '', '', 'ffd75f', '', ''] + \ , 'PythonFunctionTag' : [ 109, '', '', '87afaf', '', ''] + \ , 'PythonVariableTag' : [ 253, '', '', 'dadada', '', ''] + \ , 'PythonMemberTag' : [ 145, '', '', 'afafaf', '', ''] + \ + \ , 'CTagsImport' : [ 109, '', '', '87afaf', '', ''] + \ , 'CTagsClass' : [ 221, '', '', 'ffd75f', '', ''] + \ , 'CTagsFunction' : [ 109, '', '', '87afaf', '', ''] + \ , 'CTagsGlobalVariable' : [ 253, '', '', 'dadada', '', ''] + \ , 'CTagsMember' : [ 145, '', '', 'afafaf', '', ''] + \ + \ , 'xmlTag' : [ 149, '', 'bold', 'afd75f', '', 'bold'] + \ , 'xmlTagName' : [ 250, '', '', 'bcbcbc', '', ''] + \ , 'xmlEndTag' : [ 209, '', 'bold', 'ff875f', '', 'bold'] + \ + \ , 'cssImportant' : [ 166, '', 'bold', 'd75f00', '', 'bold'] + \ + \ , 'DiffAdd' : [ 112, 22, '', '87d700', '005f00', ''] + \ , 'DiffChange' : [ 220, 94, '', 'ffd700', '875f00', ''] + \ , 'DiffDelete' : [ 160, '', '', 'd70000', '', ''] + \ , 'DiffText' : [ 220, 94, 'reverse,bold', 'ffd700', '875f00', 'reverse,bold'] + \ + \ , 'diffLine' : [ 68, '', 'bold', '5f87d7', '', 'bold'] + \ , 'diffFile' : [ 242, '', '', '6c6c6c', '', ''] + \ , 'diffNewFile' : [ 242, '', '', '6c6c6c', '', ''] +\ }) + +hi link htmlTag xmlTag +hi link htmlTagName xmlTagName +hi link htmlEndTag xmlEndTag + +hi link phpCommentTitle vimCommentTitle +hi link phpDocTags vimCommentString +hi link phpDocParam vimCommentTitle + +hi link diffAdded DiffAdd +hi link diffChanged DiffChange +hi link diffRemoved DiffDelete diff --git a/.vim/colors/euler.vim b/.vim/colors/euler.vim new file mode 100644 index 0000000..3116081 --- /dev/null +++ b/.vim/colors/euler.vim @@ -0,0 +1,64 @@ +" Vim color file +" Modified from darkblue.vim +" @author Adam Blank + +set bg=dark +hi clear +if exists("syntax_on") + syntax reset +endif + +let colors_name = "euler" + +hi Normal guifg=#c0c0c0 guibg=#000040 ctermfg=lightgray ctermbg=black +"hi ErrorMsg guifg=#ffffff guibg=#287eff ctermfg=white ctermbg=lightblue +highlight ErrorMsg guifg=LightYellow guibg=FireBrick +hi Visual guifg=#8080ff guibg=fg gui=reverse ctermbg=235 +"hi VisualNOS guifg=#8080ff guibg=fg gui=reverse,underline ctermfg=bg ctermbg=fg cterm=reverse,underline +hi Todo guifg=#d14a14 guibg=#1248d1 ctermfg=red ctermbg=darkblue +hi Search guifg=#90fff0 guibg=#2050d0 ctermfg=white ctermbg=darkblue cterm=underline term=underline +hi IncSearch guifg=#b0ffff guibg=#2050d0 ctermfg=darkblue ctermbg=gray + +hi SpecialKey guifg=cyan ctermfg=darkcyan +hi Directory guifg=cyan ctermfg=cyan +hi Title guifg=magenta gui=none ctermfg=magenta cterm=bold +hi WarningMsg guifg=red ctermfg=red +hi WildMenu guifg=yellow guibg=black ctermfg=yellow ctermbg=black cterm=none term=none +hi ModeMsg guifg=#22cce2 ctermfg=white +hi MoreMsg ctermfg=darkgreen ctermfg=darkgreen +hi Question guifg=green gui=none ctermfg=green cterm=none +hi NonText guifg=#0030ff ctermfg=darkblue + + +"hi StatusLine guifg=blue guibg=darkgray gui=none ctermfg=blue ctermbg=gray term=none cterm=none +highlight StatusLine ctermfg=17 ctermbg=gray +hi VertSplit guifg=black guibg=darkgray gui=none ctermfg=black ctermbg=gray term=none cterm=none + +hi Folded guifg=#808080 guibg=#000040 ctermfg=darkgrey ctermbg=black cterm=bold term=bold +hi FoldColumn guifg=#808080 guibg=#000040 ctermfg=darkgrey ctermbg=black cterm=bold term=bold +hi LineNr guifg=#90f020 ctermfg=221 cterm=none + +hi DiffAdd guibg=darkblue ctermbg=darkblue term=none cterm=none +hi DiffChange guibg=darkmagenta ctermbg=magenta cterm=none +hi DiffDelete ctermfg=blue ctermbg=cyan gui=bold guifg=Blue guibg=DarkCyan +hi DiffText cterm=bold ctermbg=red gui=bold guibg=Red + +hi Cursor guifg=black guibg=yellow ctermfg=black ctermbg=yellow +hi lCursor guifg=black guibg=white ctermfg=black ctermbg=white + + +hi Comment ctermfg=239 guifg=#80a0ff +hi Constant ctermfg=107 guifg=#ffa0a0 cterm=none +hi Special ctermfg=107 guifg=Orange cterm=none gui=none +hi Identifier ctermfg=107 guifg=#40ffff cterm=none +hi Statement ctermfg=66 cterm=none guifg=#ffff60 gui=none +hi PreProc ctermfg=107 guifg=#ff80ff gui=none cterm=none +hi type ctermfg=25 guifg=#60ff60 gui=none cterm=none +hi Underlined cterm=underline term=underline +hi Ignore guifg=bg ctermfg=bg + +" suggested by tigmoid, 2008 Jul 18 +hi Pmenu guifg=#c0c0c0 guibg=#404080 +hi PmenuSel guifg=#c0c0c0 guibg=#2050d0 +hi PmenuSbar guifg=blue guibg=darkgray +hi PmenuThumb guifg=#c0c0c0 diff --git a/.vim/colors/genericdc-light.vim b/.vim/colors/genericdc-light.vim new file mode 100644 index 0000000..674f901 --- /dev/null +++ b/.vim/colors/genericdc-light.vim @@ -0,0 +1,98 @@ +set background=light +highlight clear + +if exists("syntax on") + syntax reset +endif + +let g:colors_name = "genericdc-light" + +hi Normal ctermfg=235 ctermbg=255 +hi Special ctermfg=234 ctermbg=NONE +hi Comment ctermfg=247 ctermbg=NONE cterm=italic +hi Constant ctermfg=237 ctermbg=NONE +hi String ctermfg=68 ctermbg=NONE +hi Number ctermfg=196 ctermbg=NONE +hi htmlTagName ctermfg=235 ctermbg=NONE +hi Identifier ctermfg=239 ctermbg=NONE +hi Statement ctermfg=242 ctermbg=NONE cterm=NONE +hi Boolean ctermfg=242 ctermbg=NONE cterm=NONE +hi PreProc ctermfg=244 ctermbg=NONE +hi Type ctermfg=239 ctermbg=NONE +hi Function ctermfg=240 ctermbg=NONE cterm=italic +hi Repeat ctermfg=244 ctermbg=NONE +hi Operator ctermfg=239 ctermbg=NONE +hi Error ctermfg=9 ctermbg=NONE +hi TODO ctermfg=135 ctermbg=NONE cterm=italic +hi linenr ctermfg=250 ctermbg=255 +hi CursorLineNR ctermfg=246 ctermbg=234 + +hi Visual ctermfg=255 ctermbg=241 cterm=italic +hi SpecialKey ctermfg=255 ctermbg=NONE +hi NonText ctermfg=255 ctermbg=NONE +hi ExtraWhitespace ctermbg=196 +hi MatchParen ctermfg=234 ctermbg=242 +hi Pmenu ctermfg=250 ctermbg=237 +hi PmenuSel ctermfg=255 ctermbg=75 + +hi ColorColumn ctermbg=253 + +match ExtraWhitespace /\s\+$/ + +hi link character constant +hi link number constant +hi link boolean constant +hi link Float Number +hi link Conditional Repeat +hi link Label Statement +hi link Keyword Statement +hi link Exception Statement +hi link Include PreProc +hi link Define PreProc +hi link Macro PreProc +hi link PreCondit PreProc +hi link StorageClass Type +hi link Structure Type +hi link Typedef Type +hi link htmlTag Special +hi link Tag Special +hi link SpecialChar Special +hi link Delimiter Special +hi link SpecialComment Special +hi link Debug Special + +" sytnax specific + +" javascript (ala vim-javascript-syntax) +hi javaScriptFuncArg ctermfg=244 ctermbg=NONE +hi javaScriptFuncExp ctermfg=239 +hi javaScriptBraces cterm=NONE + +hi link javaScriptDocTags Comment + + +" go (ala vim-go) +hi gotypes ctermfg=208 ctermbg=NONE cterm=italic +hi goDirective ctermfg=242 ctermbg=NONE cterm=italic + +hi link goTodo TODO +hi link goType gotypes +hi link goSignedInts gotypes +hi link goUnsignedInts gotypes +hi link goFloats gotypes +hi link goComplexes gotypes + +hi goOperator ctermfg=242 +hi goBuiltins ctermfg=70 +hi goDeclaration ctermfg=242 +hi goDeclType ctermfg=242 + +hi goFunction ctermfg=242 ctermbg=NONE cterm=italic +hi goMethod ctermfg=242 ctermbg=NONE cterm=NONE +hi goStruct ctermfg=235 ctermbg=NONE cterm=NONE +hi goStructDef ctermfg=235 ctermbg=NONE cterm=italic + + +" NerdTree +hi link NERDTreeDir Special +hi NERDTreeFile ctermfg=241 diff --git a/.vim/doc/airline.txt b/.vim/doc/airline.txt new file mode 100644 index 0000000..ddc81ce --- /dev/null +++ b/.vim/doc/airline.txt @@ -0,0 +1,793 @@ +*airline.txt* Lean and mean status/tabline that's light as air +*airline* + _ _ _ _ ~ + __ _(_)_ __ ___ __ _(_)_ __| (_)_ __ ___ ~ + \ \ / / | '_ ` _ \ _____ / _` | | '__| | | '_ \ / _ \ ~ + \ V /| | | | | | |_____| (_| | | | | | | | | | __/ ~ + \_/ |_|_| |_| |_| \__,_|_|_| |_|_|_| |_|\___| ~ + ~ +============================================================================== +CONTENTS *airline-contents* + + 01. Intro ............................................... |airline-intro| + 02. Features ......................................... |airline-features| + 03. Name ................................................. |airline-name| + 04. Configuration ............................... |airline-configuration| + 05. Commands ......................................... |airline-commands| + 06. Customization ............................... |airline-customization| + 07. Extensions ..................................... |airline-extensions| + 08. Advanced Customization ............. |airline-advanced-customization| + 09. Funcrefs ......................................... |airline-funcrefs| + 10. Pipeline ......................................... |airline-pipeline| + 11. Writing Extensions ..................... |airline-writing-extensions| + 12. Writing Themes ..................................... |airline-themes| + 13. Troubleshooting ........................... |airline-troubleshooting| + 14. Contributions ............................... |airline-contributions| + 15. License ........................................... |airline-license| + +============================================================================== +INTRODUCTION *airline-intro* + +vim-airline is a fast and lightweight alternative to powerline, written +in 100% vimscript with no outside dependencies. + +============================================================================== +FEATURES *airline-features* + +* tiny core written with extensibility in mind. +* integrates with many popular plugins. +* looks good with regular fonts, and provides configuration points so you + can use unicode or powerline symbols. +* optimized for speed; it loads in under a millisecond. +* fully customizable; if you know a little 'statusline' syntax you can + tweak it to your needs. +* extremely easy to write themes. + +============================================================================== +NAME *airline-name* + +Where did the name come from? + +I wrote this on an airplane, and since it's light as air it turned out to be a +good name :-) + +============================================================================== +CONFIGURATION *airline-configuration* + +There are a couple configuration values available (shown with their default +values): + +* the separator used on the left side > + let g:airline_left_sep='>' +< +* the separator used on the right side > + let g:airline_right_sep='<' +< +* enable modified detection > + let g:airline_detect_modified=1 + +* enable paste detection > + let g:airline_detect_paste=1 +< +* enable iminsert detection > + let g:airline_detect_iminsert=0 +< +* determine whether inactive windows should have the left section collapsed to + only the filename of that buffer. > + let g:airline_inactive_collapse=1 +< +* themes are automatically selected based on the matching colorscheme. this + can be overridden by defining a value. > + let g:airline_theme= +< +* if you want to patch the airline theme before it gets applied, you can + supply the name of a function where you can modify the palette. > + let g:airline_theme_patch_func = 'AirlineThemePatch' + function! AirlineThemePatch(palette) + if g:airline_theme == 'badwolf' + for colors in values(a:palette.inactive) + let colors[3] = 245 + endfor + endif + endfunction +< +* enable/disable automatic population of the `g:airline_symbols` dictionary + with powerline symbols. > + let g:airline_powerline_fonts=0 +< +* define the set of text to display for each mode. > + let g:airline_mode_map = {} " see source for the defaults + + " or copy paste the following into your vimrc for shortform text + let g:airline_mode_map = { + \ '__' : '-', + \ 'n' : 'N', + \ 'i' : 'I', + \ 'R' : 'R', + \ 'c' : 'C', + \ 'v' : 'V', + \ 'V' : 'V', + \ '' : 'V', + \ 's' : 'S', + \ 'S' : 'S', + \ '' : 'S', + \ } +< +* define the set of filename match queries which excludes a window from having + its statusline modified > + let g:airline_exclude_filenames = [] " see source for current list +< +* define the set of filetypes which are excluded from having its window + statusline modified > + let g:airline_exclude_filetypes = [] " see source for current list +< +* defines whether the preview window should be excluded from have its window + statusline modified (may help with plugins which use the preview window + heavily) > + let g:airline_exclude_preview = 0 +< +============================================================================== +COMMANDS *airline-commands* + +:AirlineTheme {theme-name} *:AirlineTheme* + Displays or changes the current theme. + +:AirlineToggleWhitespace *:AirlineToggleWhitespace* + Toggles whitespace detection. + +:AirlineToggle *:AirlineToggle* + Toggles between the standard 'statusline' and airline. + +:AirlineRefresh *:AirlineRefresh* + Refreshes all highlight groups and redraws the statusline. + +============================================================================== +CUSTOMIZATION *airline-customization* + +The following are some unicode symbols for customizing the left/right +separators, as well as the powerline font glyths. + +Note: You must define the dictionary first before setting values. Also, it's a +good idea to check whether if it exists as to avoid accidentally overwritting +its contents. > + if !exists('g:airline_symbols') + let g:airline_symbols = {} + endif + + " unicode symbols + let g:airline_left_sep = '»' + let g:airline_left_sep = '▶' + let g:airline_right_sep = '«' + let g:airline_right_sep = '◀' + let g:airline_symbols.linenr = '␊' + let g:airline_symbols.linenr = '␤' + let g:airline_symbols.linenr = '¶' + let g:airline_symbols.branch = '⎇' + let g:airline_symbols.paste = 'ρ' + let g:airline_symbols.paste = 'Þ' + let g:airline_symbols.paste = '∥' + let g:airline_symbols.whitespace = 'Ξ' + + " powerline symbols + let g:airline_left_sep = '' + let g:airline_left_alt_sep = '' + let g:airline_right_sep = '' + let g:airline_right_alt_sep = '' + let g:airline_symbols.branch = '' + let g:airline_symbols.readonly = '' + let g:airline_symbols.linenr = '' + + " old vim-powerline symbols + let g:airline_left_sep = '⮀' + let g:airline_left_alt_sep = '⮁' + let g:airline_right_sep = '⮂' + let g:airline_right_alt_sep = '⮃' + let g:airline_symbols.branch = '⭠' + let g:airline_symbols.readonly = '⭤' + let g:airline_symbols.linenr = '⭡' +< + +For more intricate customizations, you can replace the predefined sections +with the usual statusline syntax. + +Note: If you define any section variables it will replace the default values +entirely. If you want to disable only certain parts of a section you can try +using variables defined in the |airline-configuration| or |airline-extensions| +section. +> + variable names default contents + ---------------------------------------------------------------------------- + let g:airline_section_a (mode, paste, iminsert) + let g:airline_section_b (hunks, branch) + let g:airline_section_c (bufferline or filename) + let g:airline_section_gutter (readonly, csv) + let g:airline_section_x (tagbar, filetype, virtualenv) + let g:airline_section_y (fileencoding, fileformat) + let g:airline_section_z (percentage, line number, column number) + let g:airline_section_warning (syntastic, whitespace) + + " here is an example of how you could replace the branch indicator with + " the current working directory, followed by the filename. + let g:airline_section_b = '%{getcwd()}' + let g:airline_section_c = '%t' +< +============================================================================== +EXTENSIONS *airline-extensions* + +Most extensions are enabled by default and lazily loaded when the +corresponding plugin (if any) is detected. + +By default, airline will attempt to load any extension it can find in the +'runtimepath'. On some systems this can result in an undersirable startup +cost. You can disable the check with the following flag. > + let g:airline#extensions#disable_rtp_load = 1 +< + Note: Third party plugins that rely on this behavior will be affected. You + will need to manually load them. + +------------------------------------- *airline-default* +The default extension understands all of the `g:` variables in the +|airline-configuration| section, however it also has some more fine-tuned +configuration values that you can use. + +* control which sections get truncated and at what width. > + let g:airline#extensions#default#section_truncate_width = { + \ 'b': 79, + \ 'x': 60, + \ 'y': 88, + \ 'z': 45, + \ } + + " Note: set to an empty dictionary to disable truncation. + let g:airline#extensions#default#section_truncate_width = {} +< +* configure the layout of the sections by specificing an array of two arrays + (first array is the left side, second array is the right side). > + let g:airline#extensions#default#layout = [ + \ [ 'a', 'b', 'c' ], + \ [ 'x', 'y', 'z', 'warning' ] + \ ] +< +------------------------------------- *airline-quickfix* +The quickfix extension is a simple built-in extension which determines +whether the buffer is a quickfix or location list buffer, and adjusts the +title accordingly. + +* configure the title text for quickfix buffers > + let g:airline#extensions#quickfix#quickfix_text = 'Quickfix' +< +* configure the title text for location list buffers > + let g:airline#extensions#quickfix#location_text = 'Location' +< + +------------------------------------- *airline-bufferline* +vim-bufferline + +* enable/disable bufferline integration > + let g:airline#extensions#bufferline#enabled = 1 +< +* determine whether bufferline will overwrite customization variables > + let g:airline#extensions#bufferline#overwrite_variables = 1 +< +------------------------------------- *airline-branch* +fugitive.vim +lawrencium +vcscommand + +* enable/disable fugitive/lawrencium integration > + let g:airline#extensions#branch#enabled = 1 +< +* change the text for when no branch is detected > + let g:airline#extensions#branch#empty_message = '' + +* use vcscommand.vim if available > + let g:airline#extensions#branch#use_vcscommand = 0 + +* truncate long branch names to a fixed length > + let g:airline#extensions#branch#displayed_head_limit = 10 + +------------------------------------- *airline-syntastic* +syntastic + +* enable/disable syntastic integration > + let g:airline#extensions#syntastic#enabled = 1 +< +------------------------------------- *airline-tagbar* +tagbar + +* enable/disable tagbar integration > + let g:airline#extensions#tagbar#enabled = 1 +< +* change how tags are displayed (:help tagbar-statusline) > + let g:airline#extensions#tagbar#flags = '' (default) + let g:airline#extensions#tagbar#flags = 'f' + let g:airline#extensions#tagbar#flags = 's' + let g:airline#extensions#tagbar#flags = 'p' +< +------------------------------------- *airline-csv* +csv.vim + +* enable/disable csv integration for displaying the current column. > + let g:airline#extensions#csv#enabled = 1 +< +* change how columns are displayed. > + let g:airline#extensions#csv#column_display = 'Number' (default) + let g:airline#extensions#csv#column_display = 'Name' +< +------------------------------------- *airline-hunks* +vim-gitgutter +vim-signify +changesPlugin + +* enable/disable showing a summary of changed hunks under source control. > + let g:airline#extensions#hunks#enabled = 1 +< +* enable/disable showing only non-zero hunks. > + let g:airline#extensions#hunks#non_zero_only = 0 +< +* set hunk count symbols. > + let g:airline#extensions#hunks#hunk_symbols = ['+', '~', '-'] +< +------------------------------------- *airline-ctrlp* +ctrlp + +* configure which mode colors should ctrlp window use (takes effect + only if the active airline theme doesn't define ctrlp colors) > + let g:airline#extensions#ctrlp#color_template = 'insert' (default) + let g:airline#extensions#ctrlp#color_template = 'normal' + let g:airline#extensions#ctrlp#color_template = 'visual' + let g:airline#extensions#ctrlp#color_template = 'replace' +< + +* configure whether to show the previous and next modes (mru, buffer, etc...) +> + let g:airline#extensions#ctrlp#show_adjacent_modes = 1 +< +------------------------------------- *airline-virtualenv* +virtualenv + +* enable/disable virtualenv integration > + let g:airline#extensions#virtualenv#enabled = 1 +< +------------------------------------- *airline-eclim* +eclim + +* enable/disable eclim integration, which works well with the + |airline-syntastic| extension. > + let g:airline#extensions#eclim#enabled = 1 + +------------------------------------- *airline-whitespace* +* enable/disable detection of whitespace errors. > + let g:airline#extensions#whitespace#enabled = 1 +< +* customize the type of mixed indent checking to perform. > + " must be all spaces or all tabs before the first non-whitespace character + let g:airline#extensions#whitespace#mixed_indent_algo = 0 (default) + + " certain number of spaces are allowed after tabs, but not in between + " this algorithm works well for /** */ style comments in a tab-indented file + let g:airline#extensions#whitespace#mixed_indent_algo = 1 +< +* customize the whitespace symbol. > + let g:airline#extensions#whitespace#symbol = '!' +< +* configure which whitespace checks to enable. > + let g:airline#extensions#whitespace#checks = [ 'indent', 'trailing' ] +< +* configure the maximum number of lines where whitespace checking is enabled. > + let g:airline#extensions#whitespace#max_lines = 20000 +< +* configure whether a message should be displayed. > + let g:airline#extensions#whitespace#show_message = 1 +< +* configure the formatting of the warning messages. > + let g:airline#extensions#whitespace#trailing_format = 'trailing[%s]' + let g:airline#extensions#whitespace#mixed_indent_format = 'mixed-indent[%s]' +< +------------------------------------- *airline-tabline* +* enable/disable enhanced tabline. > + let g:airline#extensions#tabline#enabled = 0 +< +* enable/disable displaying buffers with a single tab. > + let g:airline#extensions#tabline#show_buffers = 1 +< +* configure filename match rules to exclude from the tabline. > + let g:airline#extensions#tabline#excludes = [] +< +* configure how numbers are calculated in tab mode. > + let g:airline#extensions#tabline#tab_nr_type = 0 " # of splits (default) + let g:airline#extensions#tabline#tab_nr_type = 1 " tab number +< +* enable/disable displaying tab number in tabs mode. > + let g:airline#extensions#tabline#show_tab_nr = 1 + +* enable/disable displaying tab type (far right) + let g:airline#extensions#tabline#show_tab_type = 1 + +* enable/disable displaying index of the buffer. + +When enabled, numbers will be displayed in the tabline and mappings will be +exposed to allow you to select a buffer directly. Up to 9 mappings will be +exposed. + + let g:airline#extensions#tabline#buffer_idx_mode = 1 + nmap 1 AirlineSelectTab1 + nmap 2 AirlineSelectTab2 + nmap 3 AirlineSelectTab3 + nmap 4 AirlineSelectTab4 + nmap 5 AirlineSelectTab5 + nmap 6 AirlineSelectTab6 + nmap 7 AirlineSelectTab7 + nmap 8 AirlineSelectTab8 + nmap 9 AirlineSelectTab9 + + Note: Mappings will be ignored within a NERDTree buffer. + +* defines the name of a formatter for how buffer names are displayed. > + let g:airline#extensions#tabline#formatter = 'default' + + " here is how you can define a 'foo' formatter: + function! airline#extensions#tabline#foo#format(bufnr, buffers) + return fnamemodify(bufname(a:bufnr), ':t') + endfunction + let g:airline#extensions#tabline#formatter = 'foo' +< + Note: the following variables are only used by the 'default' formatter. + + * configure whether buffer numbers should be shown. > + let g:airline#extensions#tabline#buffer_nr_show = 0 +< + * configure how buffer numbers should be formatted with |printf|. > + let g:airline#extensions#tabline#buffer_nr_format = '%s: ' +< + * configure the formatting of filenames (see |filename-modifiers|). > + let g:airline#extensions#tabline#fnamemod = ':p:.' +< + * configure collapsing parent directories in buffer name. > + let g:airline#extensions#tabline#fnamecollapse = 1 + + " The `unique_tail` algorithm will display the tail of the filename, unless + " there is another file of the same name, in which it will display it along + " with the containing parent directory. + let g:airline#extensions#tabline#formatter = 'unique_tail' + + " The `unique_tail_improved` - another algorithm, that will smartly uniquify + " buffers names with similar filename, suppressing common parts of paths. + let g:airline#extensions#tabline#formatter = 'unique_tail_improved' +< +* configure the minimum number of buffers needed to show the tabline. > + let g:airline#extensions#tabline#buffer_min_count = 0 +< + Note: this setting only applies to a single tab and when `show_buffers` is + true. + +* configure the minimum number of tabs needed to show the tabline. > + let g:airline#extensions#tabline#tab_min_count = 0 +< + Note: this setting only applies when `show_buffers` is false. + +* configure separators for the tabline only. > + let g:airline#extensions#tabline#left_sep = '' + let g:airline#extensions#tabline#left_alt_sep = '' + let g:airline#extensions#tabline#right_sep = '' + let g:airline#extensions#tabline#right_alt_sep = '' + +* configure whether close button should be shown + let g:airline#extensions#tabline#show_close_button = 1 + +* configure symbol used to represent close button + let g:airline#extensions#tabline#close_symbol = 'X' + +< +Note: Enabling this extension will modify 'showtabline' and 'guioptions'. + +------------------------------------- *airline-tmuxline* +tmuxline + +* enable/disable tmuxline integration > + let g:airline#extensions#tmuxline#enabled = 0 +< +* configure which mode colors should be used in tmux statusline > + let airline#extensions#tmuxline#color_template = 'normal' (default) + let airline#extensions#tmuxline#color_template = 'insert' + let airline#extensions#tmuxline#color_template = 'visual' + let airline#extensions#tmuxline#color_template = 'replace' +< +* if specified, setting this option will trigger writing to the file whenever the + airline theme is applied, i.e. when :AirlineTheme is executed and on vim + startup > + airline#extensions#tmuxline#snapshot_file = "~/.tmux-statusline-colors.conf" +< +------------------------------------- *airline-promptline* +promptline + +* configure the path to the snapshot .sh file. Mandatory option. The created + file should be sourced by the shell on login > + " in .vimrc + airline#extensions#promptline#snapshot_file = "~/.shell_prompt.sh" + + " in .bashrc/.zshrc + [ -f ~/.shell_prompt.sh ] && source ~/.shell_prompt.sh +< +* enable/disable promptline integration > + let g:airline#extensions#promptline#enabled = 0 +< +* configure which mode colors should be used in prompt > + let airline#extensions#promptline#color_template = 'normal' (default) + let airline#extensions#promptline#color_template = 'insert' + let airline#extensions#promptline#color_template = 'visual' + let airline#extensions#promptline#color_template = 'replace' +< +------------------------------------- *airline-nrrwrgn* +NrrwRgn + +* enable/disable NrrwRgn integration > + let g:airline#extensions#nrrwrgn#enabled = 1 + +------------------------------------- *airline-capslock* +vim-capslock + +* enable/disable vim-capslock integration > + let g:airline#extensions#capslock#enabled = 1 + +------------------------------------- *airline-windowswap* +vim-windowswap + +* enable/disable vim-windowswap integration > + let g:airline#extensions#windowswap#enabled = 1 + +* set marked window indicator string > + let g:airline#extensions#windowswap#indicator_text = 'WS' +< +============================================================================== +ADVANCED CUSTOMIZATION *airline-advanced-customization* + +The defaults will accomodate the mass majority of users with minimal +configuration. However, if you want to reposition sections or contents you can +do so with built-in helper functions, which makes it possible to create +sections in a more declarative style. + +------------------------------------- *airline-parts* +A part is something that contains metadata that eventually gets rendered into +the statusline. You can define parts that contain constant strings or +functions. Defining parts is needed if you want to use features like automatic +insertion of separators or hiding based on window width. + +For example, this is how you would define a part function: > + call airline#parts#define_function('foo', 'GetFooText') +< +Here is how you would define a part that is visible only if the window width +greater than a minimum width. > + call airline#parts#define_minwidth('foo', 50) +< +Parts can be configured to be visible conditionally. > + call airline#parts#define_condition('foo', 'getcwd() =~ "work_dir"') +< +Note: Part definitions are combinative; e.g. the two examples above modify the +same `foo` part. + +Note: Look at the source code and tests for the full API. + +------------------------------------- *airline-predefined-parts* +Before is a list of parts that are predefined by vim-airline. + +* `mode` displays the current mode +* `iminsert` displays the current insert method +* `paste` displays the paste indicator +* `filetype` displays the file type +* `readonly` displays the read only indicator +* `file` displays the filename and modified indicator +* `ffenc` displays the file format and encoding + +And the following are defined for their respective extensions: + +`hunks`, `branch`, `tagbar`, `syntastic`, `whitespace` + +------------------------------------- *airline-accents* +Accents can be defined on any part, like so: > + call airline#parts#define_accent('foo', 'red') +< +This will override the colors of that part by using what is defined in that +particular accent. In the above example, the `red` accent is used, which means +regardless of which section the part is used in, it will have red foreground +colors instead of the section's default foreground color. + +The following accents are defined by default. Themes can define their variants +of the colors, but defaults will be provided if missing. > + bold, italic, red, green, blue, yellow, orange, purple +< +The defaults configure the mode and line number parts to be bold, and the +readonly part to be red. + +------------------------------------- *airline-sections* +Once a part is defined, you can use helper functions to generate the +statuslines for each section. For example, to use the part above, we could +define a section like this: > + function! AirlineInit() + let g:airline_section_a = airline#section#create(['mode', ' ', 'foo']) + let g:airline_section_b = airline#section#create_left(['ffenc','file']) + let g:airline_section_c = airline#section#create(['%{getcwd()}']) + endfunction + autocmd VimEnter * call AirlineInit() +< +This will create a section with the `mode`, followed by a space, and our `foo` +part in section `a`. Section `b` will have two parts with a left-side +separator. And section `c` will contain the current path. You may notice that +the space and cwd are not defined parts. For convenience, if a part of that +key does not exist, it will be inserted as is. The unit tests will be a good +resource for possibilities. + +Note: The use of |VimEnter| is important, because most extensions are lazily +loaded, so we must give them a chance to define their parts before we can use +them. + +Note: The `airline#section#create` function and friends will do its best to +create a section with the appropriate separators, but it only works for +function and text parts. Special 'statusline' items like %f or raw/undefined +parts will not work as it is not possible to inspect their widths/contents +before rendering to the statusline. + +============================================================================== +FUNCREFS *airline-funcrefs* + +vim-airline internally uses funcrefs to integrate with third party plugins, +and you can tap into this functionality to extend it for you needs. This is +the most powerful way to customize the statusline, and sometimes it may be +easier to go this route than the above methods. + +Every section can have two values. The default value is the global `g:` +variable which is used in the absense of a `w:` value. This makes it very easy +to override only certain parts of the statusline by only defining window-local +variables for a subset of all sections. + +------------------------------------- *add_statusline_func* +The following is an example of how you can extend vim-airline to support a +new plugin. > + function! MyPlugin(...) + if &filetype == 'MyPluginFileType' + let w:airline_section_a = 'MyPlugin' + let w:airline_section_b = '%f' + let w:airline_section_c = '%{MyPlugin#function()}' + let g:airline_variable_referenced_in_statusline = 'foo' + endif + endfunction + call airline#add_statusline_func('MyPlugin') +< +Notice that only the left side of the statusline is overwritten. This means +the right side (the line/column numbers, etc) will be intact. + +------------------------------------- *remove_statusline_func* +You can also remove a function as well, which is useful for when you want a +temporary override. > + call airline#remove_statusline_func('MyPlugin') +< + +============================================================================== +PIPELINE *airline-pipeline* + +Sometimes you want to do more than just use overrides. The statusline funcref +is invoked and passed two arguments. The first of these arguments is the +statusline builder. You can use this to build completely custom statuslines +to your liking. Here is an example: > +> + function! MyPlugin(...) + " first variable is the statusline builder + let builder = a:1 + + " WARNING: the API for the builder is not finalized and may change + call builder.add_section('Normal', '%f') + call builder.add_section('WarningMsg', '%{getcwd()}') + call builder.split() + call builder.add_section('airline_z', '%p%%') + + " tell the core to use the contents of the builder + return 1 + endfunction +< +The above example uses various example highlight groups to demonstrate +that you can use any combination from the loaded colorscheme. However, if +you want colors to change between modes, you should use one of the section +highlight groups, e.g. `airline_a` and `airline_b`. + +The second variable is the context, which is a dictionary containing various +values such as whether the statusline is active or not, and the window number. +> + context = { + 'winnr': 'the window number for the statusline', + 'active': 'whether the window is active or not', + 'bufnr': 'the current buffer for this window', + } +< +------------------------------------- *airline-pipeline-return-codes* +The pipeline accepts various return codes and can be used to determine the +next action. The following are the supported codes: > + 0 the default, continue on with the next funcref + -1 do not modify the statusline + 1 modify the statusline with the current contents of the builder +< +Note: Any value other than 0 will halt the pipeline and prevent the next +funcref from executing. + +============================================================================== +WRITING EXTENSIONS *airline-writing-extensions* + +For contributions into the plugin, here are the following guidelines: + +1. For simple 'filetype' checks, they can be added directly into the +`extensions.vim` file. + +2. Pretty much everything else should live as a separate file under the +`extensions/` directory. + + a. Inside `extensions.vim`, add a check for some variable or command that + is always available (these must be defined in `plugin/`, and _not_ + `autoload/` of the other plugin). If it exists, then initialize the + extension. This ensures that the extension is loaded if and only if the + user has the other plugin installed. Also, a check to + `airline#extensions#foo_plugin#enabled` should be performed to allow the + user to disable it. + + b. Configuration variables for the extension should reside in the + extension, e.g. `g:airline#extensions#foo_plugin#bar_variable`. + +See the source of |example.vim| for documented code of how to write one. +Looking at the other extensions is also a good resource. + +============================================================================== +WRITING THEMES *airline-themes* + +Themes are written "close to the metal" -- you will need to know some basic +VimL syntax to write a theme, but if you've written in any programming +language before it will be easy to pick up. + +The |dark.vim| theme fully documents this procedure and will guide you through +the process. The |jellybeans.vim| theme is another example of how to write a +theme, but instead of manually declaring colors, it extracts the values from +highlight groups. + +============================================================================== +TROUBLESHOOTING *airline-troubleshooting* + +Q. There are no colors. +A. You need to set up your terminal correctly. For more details, see + . Alternatively, if you want + to bypass the automatic detection of terminal colors, you can force Vim + into 256 color mode with this: > + set t_Co=256 +< +Q. The statusline does not appear until I create a split. +A. This is the default setting of 'laststatus'. If you want it to appear all + the time, add the following to your vimrc: > + set laststatus=2 +< +Q. Powerline symbols are not showing up. +A. First, you must install patched powerline fonts. Second, you must enable + unicode in vim. > + set encoding=utf-8 +< +Q. There is a pause when leaving insert mode. +A. Add the following to your vimrc. > + set ttimeoutlen=50 +< +Q. The colors look a little off for some themes. +A. Certain themes are derived from the active colorscheme by extracting colors + from predefined highlight groups. These airline themes will look good for + their intended matching colorschemes, but will be hit or miss when loaded + with other colorschemes. + + +Solutions to other common problems can be found in the Wiki: + + +============================================================================== +CONTRIBUTIONS *airline-contributions* + +Contributions and pull requests are welcome. + +============================================================================== +LICENSE *airline-license* + +MIT License. Copyright © 2013-2014 Bailey Ling. + + + vim:tw=78:ts=8:ft=help:norl: diff --git a/.vim/doc/easytags.txt b/.vim/doc/easytags.txt new file mode 100644 index 0000000..8c23aea --- /dev/null +++ b/.vim/doc/easytags.txt @@ -0,0 +1,754 @@ +*easytags.txt* Automated tag generation and syntax highlighting in Vim + +=============================================================================== +Contents ~ + + 1. Introduction |easytags-introduction| + 2. Installation |easytags-installation| + 1. A note about Windows |easytags-note-about-windows| + 3. Commands |easytags-commands| + 1. The |:UpdateTags| command + 2. The |:HighlightTags| command + 4. Options |easytags-options| + 1. The |g:easytags_cmd| option + 2. The |g:easytags_opts| option + 3. The |g:easytags_async| option + 4. The |g:easytags_syntax_keyword| option + 5. The |g:easytags_languages| option + 6. The |g:easytags_file| option + 7. The |g:easytags_dynamic_files| option + 8. The |g:easytags_by_filetype| option + 9. The |g:easytags_events| option + 10. The |g:easytags_always_enabled| option + 11. The |g:easytags_on_cursorhold| option + 12. The |g:easytags_updatetime_min| option + 13. The |g:easytags_auto_update| option + 14. The |g:easytags_auto_highlight| option + 15. The |g:easytags_autorecurse| option + 16. The |g:easytags_include_members| option + 17. The |g:easytags_resolve_links| option + 18. The |g:easytags_suppress_ctags_warning| option + 19. The |g:easytags_suppress_report| option + 5. Customizing the easytags plug-in |customizing-easytags-plug-in| + 1. Passing custom command line arguments to Exuberant Ctags |easytags-passing-custom-command-line-arguments-to-exuberant-ctags| + 2. Update & highlight tags immediately after save |easytags-update-highlight-tags-immediately-after-save| + 3. How to customize the highlighting colors? |easytags-how-to-customize-highlighting-colors| + 6. Faster syntax highlighting using Python |easytags-faster-syntax-highlighting-using-python| + 1. The |g:easytags_python_enabled| option + 2. The |g:easytags_python_script| option + 7. Troubleshooting |easytags-troubleshooting| + 8. vim-easytags is slow! |vim-easytags-is-slow| + 1. |:HighlightTags| only works for the tags file created by |:UpdateTags| |easytags-highlighttags-only-works-for-tags-file-created-by-updatetags| + 2. The plug-in complains that Exuberant Ctags isn't installed |easytags-plug-in-complains-that-exuberant-ctags-isnt-installed| + 3. Vim locks up while the plug-in is running |easytags-vim-locks-up-while-plug-in-is-running| + 4. Failed to highlight tags because pattern is too big! |easytags-failed-to-highlight-tags-because-pattern-is-too-big| + 5. The plug-in doesn't seem to work in Cygwin |easytags-plug-in-doesnt-seem-to-work-in-cygwin| + 9. Contact |easytags-contact| + 10. License |easytags-license| + 11. References |easytags-references| + +=============================================================================== + *easytags-introduction* +Introduction ~ + +Vim has long been my favorite text editor and combined with Exuberant Ctags [1] +it has the potential to provide most of what I expect from an integrated +development environment [2]. Exuberant Ctags is the latest incarnation of a +family of computer programs [3] that scan source code files to create an index +of identifiers (tags) and where they are defined. Vim uses this index (a so- +called tags file) to enable you to jump to the definition of any identifier +using the Control-] (see |CTRL-]|) mapping. + +When you're familiar with integrated development environments you may recognize +this feature as "Go-to definition". One advantage of the combination of Vim and +Exuberant Ctags over integrated development environments is that Vim supports +syntax highlighting for over 500 file types [4] (!) and Exuberant Ctags can +generate tags for over 40 file types [5] as well... + +There's just one problem: You have to manually keep your tags files up-to-date +and this turns out to be a royal pain in the ass! So I set out to write a Vim +plug-in that would do this boring work for me. When I finished the plug-in's +basic functionality (one automatic command and a call to |system()| later) I +became interested in dynamic syntax highlighting, so I added that as well to +see if it would work -- surprisingly well I'm happy to report! + +=============================================================================== + *easytags-installation* +Installation ~ + +_Please note that the vim-easytags plug-in requires my vim-misc plug-in which +is separately distributed._ + +Unzip the most recent ZIP archives of the vim-easytags [6] and vim-misc [7] +plug-ins inside your Vim profile directory (usually this is '~/.vim' on UNIX +and '%USERPROFILE%\vimfiles' on Windows), restart Vim and execute the command +':helptags ~/.vim/doc' (use ':helptags ~\vimfiles\doc' instead on Windows). + +If you prefer you can also use Pathogen [8], Vundle [9] or a similar tool to +install and update the vim-easytags [10] and vim-misc [11] plug-ins using a +local clone of the git repository. + +Now try it out: Edit any file type supported by Exuberant Ctags and within ten +seconds the plug-in should create/update your tags file ('~/.vimtags' on UNIX, +'~/_vimtags' on Windows) with the tags defined in the file you just edited! +This means that whatever file you're editing in Vim (as long as it's on the +local file system), tags will always be available by the time you need them! + +Additionally if the file you just opened is an AWK, C#, C, C++, Objective-C, +Java, Lua, Perl, PHP, Python, Ruby, Shell, Tcl or Vim source file you should +also notice that the function and/or type names defined in the file have been +syntax highlighted. + +The 'easytags.vim' plug-in is intended to work automatically once it's +installed, but if you want to change how it works there are several options you +can change and commands you can execute from your own mappings and/or automatic +commands. These are all documented below. + +Note that if the plug-in warns you 'ctags' isn't installed you'll have to +download it from its homepage [1], or if you're running Debian/Ubuntu you can +install it by executing the following shell command: +> + $ sudo apt-get install exuberant-ctags +< +------------------------------------------------------------------------------- + *easytags-note-about-windows* +A note about Windows ~ + +On Windows the |system()| function used by 'easytags.vim' causes a command +prompt window to pop up while Exuberant Ctags is executing. If this bothers you +then you can install my shell.vim [12] plug-in which includes a DLL [13] that +works around this issue. Once you've installed both plug-ins it should work out +of the box! Please let me know if this doesn't work for you. + +=============================================================================== + *easytags-commands* +Commands ~ + +------------------------------------------------------------------------------- +The *:UpdateTags* command + +This command executes Exuberant Ctags [1] from inside Vim to update the global +tags file defined by |g:easytags_file|. When no arguments are given the tags +for the current file are updated, otherwise the arguments are passed on to +'ctags'. For example when you execute the Vim command ':UpdateTags -R ~/.vim' +(or ':UpdateTags -R ~\vimfiles' on Windows) the plug-in will execute 'ctags -R +~/.vim' for you (with some additional arguments, see the troubleshooting +section "|:HighlightTags| only works for the tags file created by +|:UpdateTags|" for more information). + +When you execute this command like ':UpdateTags!' (including the bang!) then +all tags whose files are missing will be filtered from the global tags file. + +Note that this command will be executed automatically every once in a while, +assuming you haven't changed |g:easytags_on_cursorhold|. + +------------------------------------------------------------------------------- +The *:HighlightTags* command + +When you execute this command while editing one of the supported file types +(see above) the relevant tags in the current file are highlighted. The tags to +highlight are gathered from all tags files known to Vim (through the |'tags'| +option). + +Note that this command will be executed automatically every once in a while, +assuming you haven't changed |g:easytags_on_cursorhold|. + +=============================================================================== + *easytags-options* +Options ~ + +The easytags plug-in should work out of the box but if you don't like the +default configuration you can change how it works by setting the variables +documented below. Most of these variables can also be changed for specific +files by setting a buffer local variable instead of the global variable. For +example to disable automatic highlighting (enabled by default) only in Python +files you can add the following line to your |vimrc| script: +> + :autocmd FileType python let b:easytags_auto_highlight = 0 +< +Note that buffer local variables always override global variables, so if you +want to undo this for a specific file you have to use |:unlet|: +> + :unlet b:easytags_auto_highlight +< +------------------------------------------------------------------------------- +The *g:easytags_cmd* option + +The plug-in will try to determine the location where Exuberant Ctags is +installed on its own but this might not always work because any given +executable named 'ctags' in your '$PATH' might not in fact be Exuberant Ctags +but some older, more primitive 'ctags' implementation which doesn't support the +same command line options and thus breaks the easytags plug-in. If this is the +case you can set the global variable |g:easytags_cmd| to the location where +you've installed Exuberant Ctags, e.g.: +> + :let g:easytags_cmd = '/usr/local/bin/ctags' +< +If you rely entirely on language-specific configuration and don't have a +general ctags program, set this to the empty string. + +------------------------------------------------------------------------------- +The *g:easytags_opts* option + +If you need to pass custom command line option(s) to the program specified by +|g:easytags_cmd| you can set this option to a list of strings to be passed to +Exuberant Ctags. Make sure to only use options that are valid in any context, +for example the concatenation of |g:easytags_cmd|, |g:easytags_opts| and +'--list-languages' should work as expected. Here's an example: +> + :let g:easytags_opts = ['--options=$VIM\ctags\ctags.cnf'] +< +The example above (based on issue 98 [14]) overrides the location of Exuberant +Ctags' configuration file. As you can see the command line option(s) may +contain environment variables, these will be expanded before passing the +options to Exuberant Ctags (to make sure it works in all environments). + +------------------------------------------------------------------------------- +The *g:easytags_async* option + +By default vim-easytags runs Exuberant Ctags and updates your tags file in the +foreground, blocking Vim in the process. As your tags files get larger this +becomes more annoying. It has been the number one complaint about vim-easytags +since I published the first release online. + +In version 3.5 of the vim-easytags plug-in support for asynchronous tags file +updates was added. It's not enabled by default yet because I want to make sure +I'm not breaking the plug-in for the majority of users. However after I've +gathered some feedback I definitely want to make this the default mode. + +By setting this option to true (1) you enable asynchronous tags file updates. +Good luck! ;-) + +Note that asynchronous updates on Windows currently require the installation of +my vim-shell [12] plug-in (for obscure technical reasons that I want to fix but +don't know how yet). + +------------------------------------------------------------------------------- +The *g:easytags_syntax_keyword* option + +When you look into how the dynamic syntax highlighting in the vim-easytags +plug-in works you'll realize that vim-easytags is really abusing Vim's syntax +highlighting engine. This can cause Vim to slow down to a crawl, depending on +how big your tags files are. To make things worse in Vim 7.4 a new regex engine +was introduced which exacerbates the problem (the patterns generated by vim- +easytags bring out the worst of the new regex engine). + +Since version 3.6 the vim-easytags plug-in tries to squeeze as much performance +as possible out of Vim by using keyword highlighting where this is possible +without sacrificing accuracy. If your Vim's syntax highlighting is still too +slow you can add the following to your |vimrc| script: +> + let g:easytags_syntax_keyword = 'always' +< +The default value of this option is 'auto' which means to use keyword +highlighting where this is possible without sacrificing accuracy. By changing +it to 'always' you're telling vim-easytags to sacrifice accuracy in order to +gain performance. Try it out and see what works best for you. + +Please note that right now this 'feature' is not integrated with the +"accelerated Python syntax highlighting" feature, because I'm considering +ripping that out and replacing it with a _fast_ Vim script implementation. + +------------------------------------------------------------------------------- +The *g:easytags_languages* option + +Exuberant Ctags supports many languages and can be extended via regular +expression patterns, but for some languages separate tools with ctags- +compatible output exist (e.g. jsctags [15] for Javascript). To use these, the +executable and its arguments must be configured: +> + let g:easytags_languages = { + \ 'language': { + \ 'cmd': g:easytags_cmd, + \ 'args': [], + \ 'fileoutput_opt': '-f', + \ 'stdout_opt': '-f-', + \ 'recurse_flag': '-R' + \ } + \} +< +Each key is a special language definition. The key is a Vim file type in +lowercase. The above snippet shows the defaults; you only need to specify +options that differ. + +------------------------------------------------------------------------------- +The *g:easytags_file* option + +As mentioned above the plug-in will store your tags in '~/.vimtags' on UNIX and +'~/_vimtags' on Windows. To change the location of this file, set the global +variable |g:easytags_file|, e.g.: +> + :let g:easytags_file = '~/.vim/tags' +< +A leading '~' in the |g:easytags_file| variable is expanded to your current +home directory ('$HOME' on UNIX, '%USERPROFILE%' on Windows). + +------------------------------------------------------------------------------- +The *g:easytags_dynamic_files* option + +By default |:UpdateTags| only writes to the global tags file, but it can be +configured to look for project specific tags files by adding the following +lines to your |vimrc| script: +> + :set tags=./tags; + :let g:easytags_dynamic_files = 1 +< +You can change the name of the tags file, the important thing is that it's +relative to your working directory or the buffer (using a leading './'). When +|g:easytags_dynamic_files| is set to 1 the easytags plug-in will write to the +first existing tags file seen by Vim (based on the |'tags'| option). In other +words: If a project specific tags file is found it will be used, otherwise the +plug-in falls back to the global tags file (or a file type specific tags file). + +If you set |g:easytags_dynamic_files| to 2 the easytags plug-in will +automatically create project specific tags based on the first name in the +'tags' option. In this mode the the global tags file or file type specific tags +files are only used for directories where you don't have write permissions. + +The |'tags'| option is reevaluated each time the plug-in runs, so which tags +file is selected can differ depending on the buffer and working directory. + +------------------------------------------------------------------------------- +The *g:easytags_by_filetype* option + +By default all tags are stored in a global tags file. When the tags file grows +beyond a certain size Vim will be slowed down by the easytags plug-in because +it has to read and process a large number of tags very frequently. + +To avoid this problem you can set |g:easytags_by_filetype| to the path of an +existing directory. The easytags plug-in will create separate tags files for +each file type in the configured directory. These tags files are automatically +registered by the easytags plug-in when the file type of a buffer is set. + +Note that the |g:easytags_dynamic_files| option takes precedence over this +option. + +If you already have a global tags file you can create file type specific tags +files from the global tags file using the command ':TagsByFileType'. + +------------------------------------------------------------------------------- +The *g:easytags_events* option + +This option can be used to customize the events that trigger the automatic +updating and highlighting performed by the easytags plug-in. The +|g:easytags_always_enabled| and |g:easytags_on_cursorhold| options are more +user friendly but limited ways to accomplish the same thing. + +Here's an example: Say you want the easytags plug-in to automatically update & +highlight tags for the current file right after you save the file. You can +accomplish this by adding the following line to your |vimrc| script: +> + :let g:easytags_events = ['BufWritePost'] +< +Note that if you set |g:easytags_events| in your |vimrc| script, the values of +the options |g:easytags_always_enabled| and |g:easytags_on_cursorhold| will be +ignored completely. + +------------------------------------------------------------------------------- +The *g:easytags_always_enabled* option + +By default the plug-in automatically generates and highlights tags when you +stop typing for a few seconds (this works using the |CursorHold| automatic +command). This means that when you edit a file, the dynamic highlighting won't +appear until you pause for a moment. If you don't like this you can configure +the plug-in to always enable dynamic highlighting: +> + :let g:easytags_always_enabled = 1 +< +Be warned that after setting this option you'll probably notice why it's +disabled by default: Every time you edit a file in Vim, the plug-in will first +run Exuberant Ctags and then highlight the tags, and this slows Vim down quite +a lot. I have some ideas on how to improve this latency by running Exuberant +Ctags in the background so stay tuned! + +Note: If you change this option it won't apply until you restart Vim, so you'll +have to set this option in your |vimrc| script. + +------------------------------------------------------------------------------- +The *g:easytags_on_cursorhold* option + +As I explained above the plug-in by default doesn't update or highlight your +tags until you stop typing for a moment. The plug-in tries hard to do the least +amount of work possible in this break but it might still interrupt your +workflow. If it does you can disable the periodic update: +> + :let g:easytags_on_cursorhold = 0 +< +Note: Like the |g:easytags_always_enabled| option, if you change this option it +won't apply until you restart Vim, so you'll have to set this option in your +|vimrc| script. + +------------------------------------------------------------------------------- +The *g:easytags_updatetime_min* option + +Vim's |'updatetime'| option controls how often the easytags plug-in is +automatically executed. A lot of popular Vim plug-ins manipulate this option to +control how often they are called. Unfortunately some of those plug-ins set +|'updatetime'| to a very low value (less than a second) and this can break the +easytags plug-in. Because of this the easytags plug-in compensates by keeping +track of when it was last executed. + +The default value of Vim's 'updatetime (see |'updatetime'|) option _and_ the +|g:easytags_updatetime_min| option is 4000 milliseconds (4 seconds). + +If you know what you're doing and you really want the easytags plug-in to be +executed more than once every 4 seconds you can lower the minimum acceptable +updatetime by setting |g:easytags_updatetime_min| to the number of milliseconds +(an integer). + +Note that although |g:easytags_updatetime_min| counts in milliseconds, the +easytags plug-in does not support subsecond granularity because it is limited +by Vim's |localtime()| function which has one-second resolution. + +------------------------------------------------------------------------------- +The *g:easytags_auto_update* option + +By default the plug-in automatically updates and highlights your tags when you +stop typing for a moment. If you want to disable automatic updating while +keeping automatic highlighting enabled you can set this option to false: +> + :let g:easytags_auto_update = 0 +< +------------------------------------------------------------------------------- +The *g:easytags_auto_highlight* option + +By default the plug-in automatically updates and highlights your tags when you +stop typing for a moment. If you want to disable automatic highlighting while +keeping automatic updating enabled you can set this option to false: +> + :let g:easytags_auto_highlight = 0 +< +------------------------------------------------------------------------------- +The *g:easytags_autorecurse* option + +When the |:UpdateTags| command is executed automatically or without arguments, +it defaults to updating just the tags for the current file. If you'd rather +have it recursively scan everything below the directory of the current file +then set this option to true (1): +> + :let g:easytags_autorecurse = 1 +< +You have to explicitly enable this option because it should only be used while +navigating around small directory trees. Imagine always having this option +enabled and then having to edit a file in e.g. the root of your home directory: +The 'easytags.vim' plug-in would freeze Vim for a long time while you'd have to +wait for Exuberant Ctags to scan thousands of files... + +Note that when you enable this option the 'easytags.vim' plug-in might ignore +other options like |g:easytags_resolve_links|. This is an implementation detail +which I intend to fix. + +------------------------------------------------------------------------------- +The *g:easytags_include_members* option + +Exuberant Ctags knows how to generate tags for struct/class members in C++ and +Java source code but doesn't do so by default because it can more than double +the size of your tags files, thus taking much longer to read/write the tags +file. When you enable the |g:easytags_include_members| option from your |vimrc| +script (before the 'easytags.vim' plug-in is loaded): +> + :let g:easytags_include_members = 1 +< +Exuberant Ctags will be instructed to include struct/class members using the ' +--extra=+q' command line argument and the 'easytags.vim' plug-in will highlight +them using the 'cMember' highlighting group. Because most color schemes don't +distinguish the Identifier and Type (see |group-name|) highlighting groups all +members will now probably look like type definitions. You can change that by +executing either of the following Vim commands (from your vimrc script, a file +type plug-in, etc.): +> + " If you like one of the existing styles you can link them: + highlight link cMember Special + + " You can also define your own style if you want: + highlight cMember gui=italic +< +------------------------------------------------------------------------------- +The *g:easytags_resolve_links* option + +UNIX has symbolic links [16] and hard links [17], both of which conflict with +the concept of having one unique location for every identifier. With regards to +hard links there's not much anyone can do, but because I use symbolic links +quite a lot I've added this option. It's disabled by default since it has a +small performance impact and might not do what unknowing users expect it to: +When you enable this option the plug-in will resolve symbolic links in +pathnames, which means your tags file will only contain entries with canonical +pathnames [18]. To enable this option (which I strongly suggest doing when you +run UNIX and use symbolic links) execute the following Vim command: +> + :let g:easytags_resolve_links = 1 +< +------------------------------------------------------------------------------- +The *g:easytags_suppress_ctags_warning* option + +If this is set and not false, it will suppress the warning on startup if ctags +is not found or not recent enough. +> + :let g:easytags_suppress_ctags_warning = 1 +< +------------------------------------------------------------------------------- +The *g:easytags_suppress_report* option + +If this is set and not false, it will suppress the report displayed on tag +updates. +> + :let g:easytags_suppress_report = 1 +< +=============================================================================== + *customizing-easytags-plug-in* +Customizing the easytags plug-in ~ + +Advanced users may wish to customize how the easytags plug-in works beyond the +point of changing configuration defaults. This section contains some hints +about this. If you have suggestions, please feel free to submit them. + +------------------------------------------------------------------------------- + *easytags-passing-custom-command-line-arguments-to-exuberant-ctags* +Passing custom command line arguments to Exuberant Ctags ~ + +You may want to run Exuberant Ctags with specific command line options, for +example the code_complete [19] plug-in requires the signature field to be +present. To do this you can create a configuration file for Exuberant Ctags, +e.g. '~/.ctags' on UNIX or '%USERPROFILE%\ctags.cnf' on Windows. The file +should contain one command line option per line. See the Exuberant Ctags manual +[20] for details. + +------------------------------------------------------------------------------- + *easytags-update-highlight-tags-immediately-after-save* +Update & highlight tags immediately after save ~ + +By default the easytags plug-in automatically updates & highlights tags for the +current file after several seconds of inactivity. This is done to prevent the +easytags plug-in from interrupting your workflow. + +If you want the easytags plug-in to automatically update & highlight tags for +the current file right after you save the file, you can add the following line +to your |vimrc| script: +> + :let g:easytags_events = ['BufWritePost'] +< +------------------------------------------------------------------------------- + *easytags-how-to-customize-highlighting-colors* +How to customize the highlighting colors? ~ + +The easytags plug-in defines new highlighting groups for dynamically +highlighted tags. These groups are linked to Vim's default groups so that +they're colored out of the box, but if you want you can change the styles. To +do so use a 'highlight' command such as the ones given a few paragraphs back. +Of course you'll need to change the group name. Here are the group names used +by the easytags plug-in: + +- **AWK**: 'awkFunctionTag' +- **C#:**'csClassOrStructTag', 'csMethodTag' +- **C, C++, Objective C:**'cTypeTag', 'cEnumTag', 'cPreProcTag', + 'cFunctionTag', 'cMemberTag' +- **Java:**'javaClassTag', 'javaInterfaceTag', 'javaMethodTag' +- **Lua:**'luaFuncTag' +- **Perl:**'perlFunctionTag' +- **PHP:**'phpFunctionsTag', 'phpClassesTag' +- **Python:**'pythonFunctionTag', 'pythonMethodTag', 'pythonClassTag' +- **Ruby:**'rubyModuleNameTag', 'rubyClassNameTag', 'rubyMethodNameTag' +- **Shell**: 'shFunctionTag' +- **Tcl**: 'tclCommandTag' +- **Vim:**'vimAutoGroupTag', 'vimCommandTag', 'vimFuncNameTag', + 'vimScriptFuncNameTag' + +As you can see each of these names ends in 'Tag' to avoid conflicts with the +syntax modes shipped with Vim. And about the singular/plural confusion: I've +tried to match the existing highlighting groups defined by popular syntax modes +(except of course for the 'Tag' suffix). + +=============================================================================== + *easytags-faster-syntax-highlighting-using-python* +Faster syntax highlighting using Python ~ + +The Vim script implementation of dynamic syntax highlighting is quite slow on +large tags files. When the Python Interface to Vim is enabled the easytags +plug-in will therefor automatically use a Python script that performs dynamic +syntax highlighting about twice as fast as the Vim script implementation. The +following options are available to change the default configuration. + +------------------------------------------------------------------------------- +The *g:easytags_python_enabled* option + +To disable the Python implementation of dynamic syntax highlighting you can set +this option to false (0). + +------------------------------------------------------------------------------- +The *g:easytags_python_script* option + +This option defines the pathname of the script that contains the Python +implementation of dynamic syntax highlighting. + +=============================================================================== + *easytags-troubleshooting* +Troubleshooting ~ + +=============================================================================== + *vim-easytags-is-slow* +vim-easytags is slow! ~ + +Yes, I know. I'm trying to make it faster but that's far from trivial. In the +process of trying to speed up vim-easytags I've added reporting of elapsed time +in several ways. If Vim seems very slow and you suspect this plug-in might be +the one to blame, increase Vim's verbosity level: +> + :set vbs=1 +< +Every time the plug-in executes it will time how long the execution takes and +add the results to Vim's message history, which you can view by executing the +|:messages| command. If you want a more fine grained impression of the time +spent by vim-easytags on various operations you can call the +'xolox#easytags#why_so_slow()' function: +> + :call xolox#easytags#why_so_slow() + easytags.vim 3.6.4: Timings since you started Vim: + - 0.094937 seconds updating tags + - 1.850201 seconds highlighting tags + - 0.035167 seconds highlighting tags using ':syntax match') + - 0.493910 seconds highlighting tags using ':syntax keyword') + - 0.413160 seconds filtering tags for highlighting (stage 1) + - 0.141747 seconds filtering tags for highlighting (stage 2) +< +------------------------------------------------------------------------------- + *easytags-highlighttags-only-works-for-tags-file-created-by-updatetags* +:HighlightTags only works for the tags file created by :UpdateTags ~ + +If you want to create tags files and have their tags highlighted by the +'easytags.vim' plug-in then you'll have to create the tags file with certain +arguments to Exuberant Ctags: +> + $ ctags --fields=+l --c-kinds=+p --c++-kinds=+p ... +< +The '--fields=+l' argument makes sure that Exuberant Ctags includes a +'language:...' property with each entry in the tags file. This is required by +the |:HighlightTags| command so it can filter tags by their file type. The +other two arguments make sure Exuberant Ctags generates tags for function +prototypes in C/C++ source code. + +If you have the |g:easytags_include_members| option enabled (its off by +default) then you'll also need to add the '--extra=+q' argument so that +Exuberant Ctags generates tags for structure/class members. + +------------------------------------------------------------------------------- + *easytags-plug-in-complains-that-exuberant-ctags-isnt-installed* +The plug-in complains that Exuberant Ctags isn't installed ~ + +After a Mac OS X user found out the hard way that the 'ctags' executable isn't +always Exuberant Ctags and we spend a few hours debugging the problem I added +proper version detection: The plug-in executes 'ctags --version' when Vim is +started to verify that Exuberant Ctags 5.5 or newer is installed. If it isn't +Vim will show the following message on startup: +> + easytags.vim: Plug-in not loaded because Exuberant Ctags isn't installed! + Please download & install Exuberant Ctags from http://ctags.sf.net +< +If the installed Exuberant Ctags version is too old the plug-in will complain: +> + easytags.vim: Plug-in not loaded because Exuberant Ctags 5.5 + or newer is required while you have version %s installed! +< +If you have the right version of Exuberant Ctags installed but the plug-in +still complains, try executing the following command from inside Vim: +> + :!which ctags +< +If this doesn't print the location where you installed Exuberant Ctags it means +your system already had a 'ctags' executable but it isn't compatible with +Exuberant Ctags 5.5 and you'll need to set the |g:easytags_cmd| option (see +above) so the plug-in knows which 'ctags' to run. + +------------------------------------------------------------------------------- + *easytags-vim-locks-up-while-plug-in-is-running* +Vim locks up while the plug-in is running ~ + +Once or twice now in several years I've experienced Exuberant Ctags getting +into an infinite loop when given garbage input. In my case this happened by +accident a few days ago :-|. Because my plug-in executes 'ctags' in the +foreground this will block Vim indefinitely! If this happens you might be able +to kill 'ctags' by pressing Control-C (see |CTRL-C|) but if that doesn't work +you can also kill it without stopping Vim using a task manager or the 'pkill' +command (available on most UNIX systems): +> + $ pkill -KILL ctags +< +------------------------------------------------------------------------------- + *easytags-failed-to-highlight-tags-because-pattern-is-too-big* +Failed to highlight tags because pattern is too big! ~ + +If the 'easytags.vim' plug-in fails to highlight your tags and the error +message mentions that the pattern is too big, your tags file has grown too +large for Vim to be able to highlight all tagged identifiers! I've had this +happen to me with 50 KB patterns because I added most of the headers in +'/usr/include/' to my tags file. Internally Vim raises the error |E339|: +Pattern too long and unfortunately the only way to avoid this problem once it +occurs is to reduce the number of tagged identifiers... + +In my case the solution was to move most of the tags from '/usr/include/' over +to project specific tags files which are automatically loaded by Vim when I +edit files in different projects because I've set the |'tags'| option as +follows: +> + :set tags=./.tags;,~/.vimtags +< +Once you've executed the above command, Vim will automatically look for a file +named '.tags' in the directory of the current file. Because of the ';' Vim also +recurses upwards so that you can nest files arbitrarily deep under your project +directories. + +------------------------------------------------------------------------------- + *easytags-plug-in-doesnt-seem-to-work-in-cygwin* +The plug-in doesn't seem to work in Cygwin ~ + +If you want to use the plug-in with Vim under Cygwin [21], you need to have the +Cygwin version of Ctags installed instead of the Windows version (thanks to +Alex Zuroff for reporting this!). + +=============================================================================== + *easytags-contact* +Contact ~ + +If you have questions, bug reports, suggestions, etc. the author can be +contacted at peter@peterodding.com. The latest version is available at +http://peterodding.com/code/vim/easytags/ and http://github.com/xolox/vim- +easytags. If you like this plug-in please vote for it on Vim Online [22]. + +=============================================================================== + *easytags-license* +License ~ + +This software is licensed under the MIT license [23]. © 2015 Peter Odding + and Ingo Karkat. + +Thanks go out to everyone who has helped to improve the vim-easytags plug-in +(whether through pull requests, bug reports or personal e-mails). + +=============================================================================== + *easytags-references* +References ~ + +[1] http://ctags.sourceforge.net/ +[2] http://en.wikipedia.org/wiki/Integrated_development_environment +[3] http://en.wikipedia.org/wiki/Ctags +[4] http://ftp.vim.org/vim/runtime/syntax/ +[5] http://ctags.sourceforge.net/languages.html +[6] http://peterodding.com/code/vim/downloads/easytags.zip +[7] http://peterodding.com/code/vim/downloads/misc.zip +[8] http://www.vim.org/scripts/script.php?script_id=2332 +[9] https://github.com/gmarik/vundle +[10] http://github.com/xolox/vim-easytags +[11] http://github.com/xolox/vim-misc +[12] http://peterodding.com/code/vim/shell/ +[13] http://en.wikipedia.org/wiki/Dynamic-link_library +[14] https://github.com/xolox/vim-easytags/issues/98 +[15] https://npmjs.org/package/jsctags +[16] http://en.wikipedia.org/wiki/Symbolic_link +[17] http://en.wikipedia.org/wiki/Hard_link +[18] http://en.wikipedia.org/wiki/Canonicalization +[19] http://www.vim.org/scripts/script.php?script_id=1764 +[20] http://ctags.sourceforge.net/ctags.html#FILES +[21] http://en.wikipedia.org/wiki/Cygwin +[22] http://www.vim.org/scripts/script.php?script_id=3114 +[23] http://en.wikipedia.org/wiki/MIT_License + +vim: ft=help diff --git a/.vim/doc/misc.txt b/.vim/doc/misc.txt new file mode 100644 index 0000000..4e2c02f --- /dev/null +++ b/.vim/doc/misc.txt @@ -0,0 +1,1212 @@ +*misc.txt* Miscellaneous auto-load Vim scripts + +=============================================================================== +Contents ~ + + 1. Introduction |misc-introduction| + 2. Installation |misc-installation| + 3. Function documentation |misc-function-documentation| + 1. Asynchronous Vim script evaluation |misc-asynchronous-vim-script-evaluation| + 1. The |xolox#misc#async#call()| function + 2. The |xolox#misc#async#inside_child()| function + 3. The |xolox#misc#async#callback_to_parent()| function + 4. The |xolox#misc#async#periodic_callback()| function + 2. Handling of special buffers |misc-handling-of-special-buffers| + 1. The |xolox#misc#buffer#is_empty()| function + 2. The |xolox#misc#buffer#prepare()| function + 3. The |xolox#misc#buffer#lock()| function + 4. The |xolox#misc#buffer#unlock()| function + 3. Tab completion for user defined commands |misc-tab-completion-for-user-defined-commands| + 1. The |xolox#misc#complete#keywords()| function + 4. Rate limiting for Vim's CursorHold event |misc-rate-limiting-for-vims-cursorhold-event| + 1. The |xolox#misc#cursorhold#register()| function + 2. The |xolox#misc#cursorhold#autocmd()| function + 5. String escaping functions |misc-string-escaping-functions| + 1. The |xolox#misc#escape#pattern()| function + 2. The |xolox#misc#escape#substitute()| function + 3. The |xolox#misc#escape#shell()| function + 6. Human friendly string formatting for Vim |misc-human-friendly-string-formatting-for-vim| + 1. The |xolox#misc#format#pluralize()| function + 2. The |xolox#misc#format#timestamp()| function + 7. List handling functions |misc-list-handling-functions| + 1. The |xolox#misc#list#unique()| function + 2. The |xolox#misc#list#binsert()| function + 8. Functions to interact with the user |misc-functions-to-interact-with-user| + 1. The |xolox#misc#msg#info()| function + 2. The |xolox#misc#msg#warn()| function + 3. The |xolox#misc#msg#debug()| function + 9. Integration between Vim and its environment |misc-integration-between-vim-its-environment| + 1. The |xolox#misc#open#file()| function + 2. The |xolox#misc#open#url()| function + 10. Vim and plug-in option handling |misc-vim-plug-in-option-handling| + 1. The |xolox#misc#option#get()| function + 2. The |xolox#misc#option#split()| function + 3. The |xolox#misc#option#join()| function + 4. The |xolox#misc#option#split_tags()| function + 5. The |xolox#misc#option#join_tags()| function + 6. The |xolox#misc#option#eval_tags()| function + 11. Operating system interfaces |misc-operating-system-interfaces| + 1. The |xolox#misc#os#is_mac()| function + 2. The |xolox#misc#os#is_win()| function + 3. The |xolox#misc#os#find_vim()| function + 4. The |xolox#misc#os#exec()| function + 5. The |xolox#misc#os#can_use_dll()| function + 12. Pathname manipulation functions |misc-pathname-manipulation-functions| + 1. The |xolox#misc#path#which()| function + 2. The |xolox#misc#path#split()| function + 3. The |xolox#misc#path#join()| function + 4. The |xolox#misc#path#directory_separator()| function + 5. The |xolox#misc#path#absolute()| function + 6. The |xolox#misc#path#relative()| function + 7. The |xolox#misc#path#merge()| function + 8. The |xolox#misc#path#commonprefix()| function + 9. The |xolox#misc#path#starts_with()| function + 10. The |xolox#misc#path#encode()| function + 11. The |xolox#misc#path#decode()| function + 12. The |xolox#misc#path#is_relative()| function + 13. The |xolox#misc#path#tempdir()| function + 13. Manipulation of UNIX file permissions |misc-manipulation-of-unix-file-permissions| + 1. The |xolox#misc#perm#update()| function + 2. The |xolox#misc#perm#get()| function + 3. The |xolox#misc#perm#set()| function + 14. Persist/recall Vim values from/to files |misc-persist-recall-vim-values-from-to-files| + 1. The |xolox#misc#persist#load()| function + 2. The |xolox#misc#persist#save()| function + 15. String handling |misc-string-handling| + 1. The |xolox#misc#str#slug()| function + 2. The |xolox#misc#str#ucfirst()| function + 3. The |xolox#misc#str#unescape()| function + 4. The |xolox#misc#str#compact()| function + 5. The |xolox#misc#str#trim()| function + 6. The |xolox#misc#str#indent()| function + 7. The |xolox#misc#str#dedent()| function + 16. Test runner & infrastructure for Vim plug-ins |misc-test-runner-infrastructure-for-vim-plug-ins| + 1. The |xolox#misc#test#reset()| function + 2. The |xolox#misc#test#summarize()| function + 3. The |xolox#misc#test#wrap()| function + 4. The |xolox#misc#test#passed()| function + 5. The |xolox#misc#test#failed()| function + 6. The |xolox#misc#test#assert_true()| function + 7. The |xolox#misc#test#assert_equals()| function + 8. The |xolox#misc#test#assert_same_type()| function + 17. Tests for the miscellaneous Vim scripts |tests-for-miscellaneous-vim-scripts| + 1. The |xolox#misc#tests#run()| function + 2. The |xolox#misc#tests#pattern_escaping()| function + 3. The |xolox#misc#tests#substitute_escaping()| function + 4. The |xolox#misc#tests#shell_escaping()| function + 5. The |xolox#misc#tests#making_a_list_unique()| function + 6. The |xolox#misc#tests#binary_insertion()| function + 7. The |xolox#misc#tests#getting_configuration_options()| function + 8. The |xolox#misc#tests#splitting_of_multi_valued_options()| function + 9. The |xolox#misc#tests#joining_of_multi_valued_options()| function + 10. The |xolox#misc#tests#finding_vim_on_the_search_path()| function + 11. The |xolox#misc#tests#synchronous_command_execution()| function + 12. The |xolox#misc#tests#synchronous_command_execution_with_stderr()| function + 13. The |xolox#misc#tests#synchronous_command_execution_with_raising_of_errors()| +function + 14. The |xolox#misc#tests#synchronous_command_execution_without_raising_errors()| +function + 15. The |xolox#misc#tests#asynchronous_command_execution()| function + 16. The |xolox#misc#tests#string_case_transformation()| function + 17. The |xolox#misc#tests#string_whitespace_compaction()| function + 18. The |xolox#misc#tests#string_whitespace_trimming()| function + 19. The |xolox#misc#tests#multiline_string_dedent()| function + 20. The |xolox#misc#tests#version_string_parsing()| function + 21. The |xolox#misc#tests#version_string_comparison()| function + 18. Timing of long during operations |misc-timing-of-long-during-operations| + 1. The |xolox#misc#timer#resumable()| function + 2. The |xolox#misc#timer#start()| function + 3. The |xolox#misc#timer#stop()| function + 4. The |xolox#misc#timer#force()| function + 5. The |xolox#misc#timer#convert()| function + 19. Version string handling |misc-version-string-handling| + 1. The |xolox#misc#version#parse()| function + 2. The |xolox#misc#version#at_least()| function + 4. Contact |misc-contact| + 5. License |misc-license| + 6. References |misc-references| + +=============================================================================== + *misc-introduction* +Introduction ~ + +The vim-misc plug-in contains Vim scripts that are used by most of the Vim +plug-ins I've written [1] yet don't really belong with any single one of the +plug-ins. Basically it's an extended standard library of Vim script functions +that I wrote during the development of my Vim profile and plug-ins. + +In the past these scripts were bundled with each plug-in, however that turned +out to be a maintenance nightmare for me. That's why the miscellaneous scripts +are now a proper plug-in with their own page on Vim Online. + +Because the miscellaneous scripts are no longer bundled with my Vim plug-ins, +users are now required to install the miscellaneous scripts separately. This is +unfortunate for users who are upgrading from a previous release that did bundle +the miscellaneous scripts, but I don't see any way around this. Sorry! + +=============================================================================== + *misc-installation* +Installation ~ + +Unzip the most recent ZIP archive [2] file inside your Vim profile directory +(usually this is '~/.vim' on UNIX and '%USERPROFILE%\vimfiles' on Windows), +restart Vim and execute the command ':helptags ~/.vim/doc' (use ':helptags +~\vimfiles\doc' instead on Windows). + +If you prefer you can also use Pathogen [3], Vundle [4] or a similar tool to +install & update the plug-in using a local clone of the git repository. + +=============================================================================== + *misc-function-documentation* +Function documentation ~ + +Below is the documentation for the functions included in the miscellaneous +scripts. Anyone is free to use these functions in their own Vim profile and/or +plug-ins. I care about backwards compatibility so won't break it without a good +reason to do so. + +For those who are curious: The function descriptions given below were extracted +from the source code of the miscellaneous scripts using the Python module +'vimdoctool.py' included in vim-tools [5]. + +The documentation of the 95 functions below was extracted from 19 Vim scripts +on March 15, 2015 at 11:10. + +------------------------------------------------------------------------------- + *misc-asynchronous-vim-script-evaluation* +Asynchronous Vim script evaluation ~ + +The |xolox#misc#async#call()| function builds on top of |xolox#misc#os#exec()| +to support asynchronous evaluation of Vim scripts. The first (and for now only) +use case is my vim-easytags [6] plug-in which has a bunch of conflicting +requirements: + +1. I want the vim-easytags [6] plug-in to be as portable as possible. + Ideally everything is implemented in Vim script because that's the only + thing I can rely on to be available for all potential users of the plug- + in! + +2. Because of point one I've been forced to implement tags file reading, + parsing, (fold case) sorting and writing in Vim script. This is fine for + small tags files but once they grow to a couple of megabytes it becomes + annoying because Vim is unresponsive during tags file updates (key + presses are fortunately buffered due to Vim's input model but that + doesn't make it a nice user experience :-). + +3. I could (and did in the past) come up with all sorts of hacks to speed + things up without switching away from Vim script, but none of them are + going to solve the fundamental problem that Vim's unresponsive hiccups + become longer as tags files grow larger. + +By now it should be clear where this is heading: _Why not handle tags file +updates in a Vim process that runs in the background without blocking the Vim +process that the user is interacting with?_ It turns out that there are quite a +few details to take care of, but with those out of the way, it might just work! +I'm actually hoping to make asynchronous updates the default mode in vim- +easytags [6]. This means I need this functionality to be as portable and robust +as possible. + +**Status:** This code has seen little testing so I wouldn't trust it too much +just yet. On the other hand, as I said, my intention is to make this +functionality as portable and robust as possible. You be the judge :-). + +------------------------------------------------------------------------------- +The *xolox#misc#async#call()* function + +Call a Vim script function asynchronously by starting a hidden Vim process in +the background. Once the function returns the hidden Vim process terminates +itself. This function takes a single argument which is a dictionary with the +following key/value pairs: + +- **function** (required): The name of the Vim function to call inside the + child process (a string). I suggest using an |autoload| function for this, + see below. + +- **arguments** (optional): A list of arguments to pass to the function. This + list is serialized to a string using |string()| and deserialized using + |eval()|. + +- **callback** (optional): The name of a Vim function to call in the parent + process when the child process has completed (a string). + +- **clientserver** (optional): If this is true (1) the child process will + notify the parent process when it has finished (the default is true). This + works using Vim's client/server support which is not always available. As a + fall back Vim's |CursorHold| automatic command is also supported (although + the effect is not quite as instantaneous :-). + +This functionality is experimental and non trivial to use, so consider yourself +warned :-). + +**Limitations** + +I'm making this functionality available in vim-misc [7] because I think it can +be useful to other plug-ins, however if you are going to use it you should be +aware of the following limitations: + +- Because of the use of multiple processes this functionality is only + suitable for 'heavy' tasks. + +- The function arguments are serialized to a string which is passed to the + hidden Vim process as a command line argument, so the amount of data you + can pass will be limited by your operating environment. + +- The hidden Vim process is explicitly isolated from the user in several ways + (see below for more details). This is to make sure that the hidden Vim + processes are fast and don't clobber the user's editing sessions in any + way. + +**Changes to how Vim normally works** + +You have to be aware that the hidden Vim process is initialized in a specific +way that is very different from your regular Vim editing sessions: + +- Your |vimrc| file is ignored using the '-u NONE' command line option. + +- Your |gvimrc| file (if you even knew it existed ;-) is ignored using the + '-U NONE' command line option. + +- Plug-in loading is skipped using the '--noplugin' command line option. + +- Swap files (see |swap-file|) are disabled using the '-n' command line + option. This makes sure asynchronous Vim processes don't disturb the user's + editing session. + +- Your |viminfo| file is ignored using the '-i NONE' command line option. + Just like with swap files this makes sure asynchronous Vim processes don't + disturb the user's editing session. + +- No-compatible mode is enabled using the '-N' command line option (usually + the existence of your vimrc script would have achieved the same effect but + since we disable loading of your vimrc we need to spell things out for + Vim). + +**Use an auto-load function** + +The function you want to call is identified by its name which has to be +defined, but I just explained above that all regular initialization is disabled +for asynchronous Vim processes, so what gives? The answer is to use an +|autoload| function. This should work fine because the asynchronous Vim process +'inherits' the value of the |'runtimepath'| option from your editing session. + +------------------------------------------------------------------------------- +The *xolox#misc#async#inside_child()* function + +Entry point inside the hidden Vim process that runs in the background. Invoked +indirectly by |xolox#misc#async#call()| because it runs a command similar to +the following: +> + vim --cmd 'call xolox#misc#async#inside_child(...)' +< +This function is responsible for calling the user defined function, capturing +exceptions and reporting the results back to the parent Vim process using Vim's +client/server support or a temporary file. + +------------------------------------------------------------------------------- +The *xolox#misc#async#callback_to_parent()* function + +When Vim was compiled with client/server support this function (in the parent +process) will be called by |xolox#misc#async#inside_child()| (in the child +process) after the user defined function has returned. This enables more or +less instant callbacks after running an asynchronous function. + +------------------------------------------------------------------------------- +The *xolox#misc#async#periodic_callback()* function + +When client/server support is not being used the vim-misc plug-in improvises: +It uses Vim's |CursorHold| event to periodically check if an asynchronous +process has written its results to one of the expected temporary files. If a +response is found the temporary file is read and deleted and then +|xolox#misc#async#callback_to_parent()| is called to process the response. + +------------------------------------------------------------------------------- + *misc-handling-of-special-buffers* +Handling of special buffers ~ + +The functions defined here make it easier to deal with special Vim buffers that +contain text generated by a Vim plug-in. For example my vim-notes plug-in [8] +generates several such buffers: + +- :RecentNotes [9] lists recently modified notes +- :ShowTaggedNotes [10] lists notes grouped by tags +- etc. + +Because the text in these buffers is generated, Vim shouldn't bother with swap +files and it should never prompt the user whether to save changes to the +generated text. + +------------------------------------------------------------------------------- +The *xolox#misc#buffer#is_empty()* function + +Checks if the current buffer is an empty, unchanged buffer which can be reused. +Returns 1 if an empty buffer is found, 0 otherwise. + +------------------------------------------------------------------------------- +The *xolox#misc#buffer#prepare()* function + +Open a special buffer, i.e. a buffer that will hold generated contents, not +directly edited by the user. The buffer can be customized by passing a +dictionary with the following key/value pairs as the first argument: + +- **name** (required): The base name of the buffer (i.e. the base name of the + file loaded in the buffer, even though it isn't really a file and nothing + is really 'loaded' :-) + +- **path** (required): The pathname of the buffer. May be relevant if |:lcd| + or |'autochdir'| is being used. + +------------------------------------------------------------------------------- +The *xolox#misc#buffer#lock()* function + +Lock a special buffer so that its contents can no longer be edited. + +------------------------------------------------------------------------------- +The *xolox#misc#buffer#unlock()* function + +Unlock a special buffer so that its content can be updated. + +------------------------------------------------------------------------------- + *misc-tab-completion-for-user-defined-commands* +Tab completion for user defined commands ~ + +------------------------------------------------------------------------------- +The *xolox#misc#complete#keywords()* function + +This function can be used to perform keyword completion for user defined Vim +commands based on the contents of the current buffer. Here's an example of how +you would use it: +> + :command -nargs=* -complete=customlist,xolox#misc#complete#keywords MyCmd call s:MyCmd() +< +------------------------------------------------------------------------------- + *misc-rate-limiting-for-vims-cursorhold-event* +Rate limiting for Vim's CursorHold event ~ + +Several of my Vim plug-ins (e.g. vim-easytags [6], vim-notes [8] and vim- +session [11]) use Vim's |CursorHold| and |CursorHoldI| events to perform +periodic tasks when the user doesn't press any keys for a couple of seconds. +These events by default fire after four seconds, this is configurable using +Vim's |'updatetime'| option. The problem that this script solves is that there +are Vim plug-ins which set the |'updatetime'| option to unreasonably low +values, thereby breaking my Vim plug-ins and probably a lot of other Vim plug- +ins out there. When users complain about this I can tell them that another Vim +plug-in is to blame, but users don't care for the difference, their Vim is +broken! So I implemented a workaround. This script enables registration of +|CursorHold| event handlers with a configurable interval (expressed in +seconds). The event handlers will be called no more than once every interval. + +------------------------------------------------------------------------------- +The *xolox#misc#cursorhold#register()* function + +Register a |CursorHold| event handler with a custom interval. This function +takes a single argument which is a dictionary with the following fields: + +- **function** (required): The name of the event handler function (a string). + +- **arguments** (optional): A list of arguments to pass to the event handler + function (defaults to an empty list). + +- **interval** (optional): The number of seconds between calls to the event + handler (defaults to 4). + +------------------------------------------------------------------------------- +The *xolox#misc#cursorhold#autocmd()* function + +The 'top level event handler' that's called by Vim whenever the |CursorHold| or +|CursorHoldI| event fires. It iterates through the event handlers registered +using |xolox#misc#cursorhold#register()| and calls each event handler at the +appropriate interval, keeping track of the time when each event handler was +last run. + +------------------------------------------------------------------------------- + *misc-string-escaping-functions* +String escaping functions ~ + +------------------------------------------------------------------------------- +The *xolox#misc#escape#pattern()* function + +Takes a single string argument and converts it into a |:substitute| / +|substitute()| pattern string that matches the given string literally. + +------------------------------------------------------------------------------- +The *xolox#misc#escape#substitute()* function + +Takes a single string argument and converts it into a |:substitute| / +|substitute()| replacement string that inserts the given string literally. + +------------------------------------------------------------------------------- +The *xolox#misc#escape#shell()* function + +Takes a single string argument and converts it into a quoted command line +argument. + +I was going to add a long rant here about Vim's |'shellslash'| option, but +really, it won't make any difference. Let's just suffice to say that I have yet +to encounter a single person out there who uses this option for its intended +purpose (running a UNIX style shell on Microsoft Windows). + +------------------------------------------------------------------------------- + *misc-human-friendly-string-formatting-for-vim* +Human friendly string formatting for Vim ~ + +------------------------------------------------------------------------------- +The *xolox#misc#format#pluralize()* function + +Concatenate a counter (the first argument, expected to be an integer) with a +singular or plural label (the second and third arguments, both expected to be +strings). + +------------------------------------------------------------------------------- +The *xolox#misc#format#timestamp()* function + +Format a time stamp (a string containing a formatted floating point number) +into a human friendly format, for example 70 seconds is phrased as "1 minute +and 10 seconds". + +------------------------------------------------------------------------------- + *misc-list-handling-functions* +List handling functions ~ + +------------------------------------------------------------------------------- +The *xolox#misc#list#unique()* function + +Remove duplicate values from the given list in-place (preserves order). + +------------------------------------------------------------------------------- +The *xolox#misc#list#binsert()* function + +Performs in-place binary insertion, which depending on your use case can be +more efficient than calling Vim's |sort()| function after each insertion (in +cases where a single, final sort is not an option). Expects three arguments: + +1. A list +2. A value to insert +3. 1 (true) when case should be ignored, 0 (false) otherwise + +------------------------------------------------------------------------------- + *misc-functions-to-interact-with-user* +Functions to interact with the user ~ + +------------------------------------------------------------------------------- +The *xolox#misc#msg#info()* function + +Show a formatted informational message to the user. + +This function has the same argument handling as Vim's |printf()| function with +one notable difference: Any arguments which are not numbers or strings are +coerced to strings using Vim's |string()| function. + +In the case of |xolox#misc#msg#info()|, automatic string coercion simply makes +the function a bit easier to use. + +The messages emitted by this function have no highlighting. Previously these +messages were highlighted using the Title group (see |hl-Title|), but it was +pointed out in pull request 16 [12] that this group shouldn't be used for +informational messages because it is meant for titles and because of this some +color schemes use colors that stand out quite a bit, causing the informational +messages to look like errors. + +------------------------------------------------------------------------------- +The *xolox#misc#msg#warn()* function + +Show a formatted warning message to the user. + +This function has the same argument handling as the |xolox#misc#msg#info()| +function. + +------------------------------------------------------------------------------- +The *xolox#misc#msg#debug()* function + +Show a formatted debugging message to the user, _if the user has enabled +increased verbosity by setting Vim's |'verbose'| option to one (1) or higher_. + +This function has the same argument handling as the |xolox#misc#msg#info()| +function. + +In the case of |xolox#misc#msg#debug()|, automatic string coercion provides +lazy evaluation in the sense that complex data structures are only converted to +strings when the user has enabled increased verbosity. + +------------------------------------------------------------------------------- + *misc-integration-between-vim-its-environment* +Integration between Vim and its environment ~ + +------------------------------------------------------------------------------- +The *xolox#misc#open#file()* function + +Given a pathname or URL as the first argument, this opens the file with the +program associated with the file type. So for example a text file might open in +Vim, an '*.html' file would probably open in your web browser and a media file +would open in a media player. + +This should work on Windows, Mac OS X and most Linux distributions. If this +fails to find a file association, you can pass one or more external commands to +try as additional arguments. For example: +> + :call xolox#misc#open#file('/path/to/my/file', 'firefox', 'google-chrome') +< +This generally shouldn't be necessary but it might come in handy now and then. + +------------------------------------------------------------------------------- +The *xolox#misc#open#url()* function + +Given a URL as the first argument, this opens the URL in your preferred or best +available web browser: + +- In GUI environments a graphical web browser will open (or a new tab will be + created in an existing window) + +- In console Vim without a GUI environment, when you have any of 'lynx', + 'links' or 'w3m' installed it will launch a command line web browser in + front of Vim (temporarily suspending Vim) + +------------------------------------------------------------------------------- + *misc-vim-plug-in-option-handling* +Vim and plug-in option handling ~ + +------------------------------------------------------------------------------- +The *xolox#misc#option#get()* function + +Expects one or two arguments: 1. The name of a variable and 2. the default +value if the variable does not exist. + +Returns the value of the variable from a buffer local variable, global variable +or the default value, depending on which is defined. + +This is used by some of my Vim plug-ins for option handling, so that users can +customize options for specific buffers. + +------------------------------------------------------------------------------- +The *xolox#misc#option#split()* function + +Given a multi-value Vim option like |'runtimepath'| this returns a list of +strings. For example: +> + :echo xolox#misc#option#split(&runtimepath) + ['/home/peter/Projects/Vim/misc', + '/home/peter/Projects/Vim/colorscheme-switcher', + '/home/peter/Projects/Vim/easytags', + ...] +< +------------------------------------------------------------------------------- +The *xolox#misc#option#join()* function + +Given a list of strings like the ones returned by |xolox#misc#option#split()|, +this joins the strings together into a single value that can be used to set a +Vim option. + +------------------------------------------------------------------------------- +The *xolox#misc#option#split_tags()* function + +Customized version of |xolox#misc#option#split()| with specialized handling for +Vim's |'tags'| option. + +------------------------------------------------------------------------------- +The *xolox#misc#option#join_tags()* function + +Customized version of |xolox#misc#option#join()| with specialized handling for +Vim's |'tags'| option. + +------------------------------------------------------------------------------- +The *xolox#misc#option#eval_tags()* function + +Evaluate Vim's |'tags'| option without looking at the file system, i.e. this +will report tags files that don't exist yet. Expects the value of the |'tags'| +option as the first argument. If the optional second argument is 1 (true) only +the first match is returned, otherwise (so by default) a list with all matches +is returned. + +------------------------------------------------------------------------------- + *misc-operating-system-interfaces* +Operating system interfaces ~ + +------------------------------------------------------------------------------- +The *xolox#misc#os#is_mac()* function + +Returns 1 (true) when on Mac OS X, 0 (false) otherwise. You would expect this +to simply check the Vim feature list, but for some obscure reason the +'/usr/bin/vim' included in Mac OS X (verified on version 10.7.5) returns 0 +(false) in response to "has('mac')", so we check the output of 'uname' to avoid +false negatives. + +------------------------------------------------------------------------------- +The *xolox#misc#os#is_win()* function + +Returns 1 (true) when on Microsoft Windows, 0 (false) otherwise. + +------------------------------------------------------------------------------- +The *xolox#misc#os#find_vim()* function + +Returns the program name of Vim as a string. On Windows and UNIX this just +|v:progname| as an absolute pathname while on Mac OS X there is some special +magic to find MacVim's executable even though it's usually not on the +executable search path. If you want, you can override the value returned from +this function by setting the global variable 'g:xolox#misc#os#vim_progname'. + +By default the choice of console Vim vs graphical Vim is made based on the +value of |v:progname|, but if you have a preference you can pass the string +'vim' or 'gvim' as the first and only argument. + +------------------------------------------------------------------------------- +The *xolox#misc#os#exec()* function + +Execute an external command (hiding the console on Microsoft Windows when my +vim-shell plug-in [13] is installed). + +Expects a dictionary with the following key/value pairs as the first argument: + +- **command** (required): The command line to execute + +- **async** (optional): set this to 1 (true) to execute the command in the + background (asynchronously) + +- **stdin** (optional): a string or list of strings with the input for the + external command + +- **check** (optional): set this to 0 (false) to disable checking of the exit + code of the external command (by default an exception will be raised when + the command fails) + +Returns a dictionary with one or more of the following key/value pairs: + +- **command** (always available): the generated command line that was used to + run the external command + +- **exit_code** (only in synchronous mode): the exit status of the external + command (an integer, zero on success) + +- **stdout** (only in synchronous mode): the output of the command on the + standard output stream (a list of strings, one for each line) + +- **stderr** (only in synchronous mode): the output of the command on the + standard error stream (as a list of strings, one for each line) + +------------------------------------------------------------------------------- +The *xolox#misc#os#can_use_dll()* function + +If a) we're on Microsoft Windows, b) the vim-shell plug-in is installed and c) +the compiled DLL included in vim-shell works, we can use the vim-shell plug-in +to execute external commands! Returns 1 (true) if we can use the DLL, 0 (false) +otherwise. + +------------------------------------------------------------------------------- + *misc-pathname-manipulation-functions* +Pathname manipulation functions ~ + +------------------------------------------------------------------------------- +The *xolox#misc#path#which()* function + +Scan the executable search path ('$PATH') for one or more external programs. +Expects one or more string arguments with program names. Returns a list with +the absolute pathnames of all found programs. Here's an example: +> + :echo xolox#misc#path#which('gvim', 'vim') + ['/usr/local/bin/gvim', + '/usr/bin/gvim', + '/usr/local/bin/vim', + '/usr/bin/vim'] +< +------------------------------------------------------------------------------- +The *xolox#misc#path#split()* function + +Split a pathname (the first and only argument) into a list of pathname +components. + +On Windows, pathnames starting with two slashes or backslashes are UNC paths +where the leading slashes are significant... In this case we split like this: + +- Input: "'//server/share/directory'" +- Result: "['//server', 'share', 'directory']" + +Everything except Windows is treated like UNIX until someone has a better +suggestion :-). In this case we split like this: + +- Input: "'/foo/bar/baz'" +- Result: "['/', 'foo', 'bar', 'baz']" + +To join a list of pathname components back into a single pathname string, use +the |xolox#misc#path#join()| function. + +------------------------------------------------------------------------------- +The *xolox#misc#path#join()* function + +Join a list of pathname components (the first and only argument) into a single +pathname string. This is the counterpart to the |xolox#misc#path#split()| +function and it expects a list of pathname components as returned by +|xolox#misc#path#split()|. + +------------------------------------------------------------------------------- +The *xolox#misc#path#directory_separator()* function + +Find the preferred directory separator for the platform and settings. + +------------------------------------------------------------------------------- +The *xolox#misc#path#absolute()* function + +Canonicalize and resolve a pathname, _regardless of whether it exists_. This is +intended to support string comparison to determine whether two pathnames point +to the same directory or file. + +------------------------------------------------------------------------------- +The *xolox#misc#path#relative()* function + +Make an absolute pathname (the first argument) relative to a directory (the +second argument). + +------------------------------------------------------------------------------- +The *xolox#misc#path#merge()* function + +Join a directory pathname and filename into a single pathname. + +------------------------------------------------------------------------------- +The *xolox#misc#path#commonprefix()* function + +Find the common prefix of path components in a list of pathnames. + +------------------------------------------------------------------------------- +The *xolox#misc#path#starts_with()* function + +Check whether the first pathname starts with the second pathname (expected to +be a directory). This does not perform a regular string comparison; first it +normalizes both pathnames, then it splits them into their pathname segments and +then it compares the segments. + +------------------------------------------------------------------------------- +The *xolox#misc#path#encode()* function + +Encode a pathname so it can be used as a filename. This uses URL encoding to +encode special characters. + +------------------------------------------------------------------------------- +The *xolox#misc#path#decode()* function + +Decode a pathname previously encoded with |xolox#misc#path#encode()|. + +------------------------------------------------------------------------------- +The *xolox#misc#path#is_relative()* function + +Returns true (1) when the pathname given as the first argument is relative, +false (0) otherwise. + +------------------------------------------------------------------------------- +The *xolox#misc#path#tempdir()* function + +Create a temporary directory and return the pathname of the directory. + +------------------------------------------------------------------------------- + *misc-manipulation-of-unix-file-permissions* +Manipulation of UNIX file permissions ~ + +Vim's |writefile()| function cannot set file permissions for newly created +files and although Vim script has a function to get file permissions (see +|getfperm()|) there is no equivalent for changing a file's permissions. + +This omission breaks the otherwise very useful idiom of updating a file by +writing its new contents to a temporary file and then renaming the temporary +file into place (which is as close as you're going to get to atomically +updating a file's contents on UNIX) because the file's permissions will not be +preserved! + +**Here's a practical example:** My vim-easytags [6] plug-in writes tags file +updates to a temporary file and renames the temporary file into place. When I +use 'sudo -s' on Ubuntu Linux it preserves my environment variables so my +'~/.vimrc' and the vim-easytags [6] plug-in are still loaded. Now when a tags +file is written the file becomes owned by root (my effective user id in the +'sudo' session). Once I leave the 'sudo' session I can no longer update my tags +file because it's now owned by root … ಠ_ಠ + +------------------------------------------------------------------------------- +The *xolox#misc#perm#update()* function + +Atomically update a file's contents while preserving the owner, group and mode. +The first argument is the pathname of the file to update (a string). The second +argument is the list of lines to be written to the file. Writes the new +contents to a temporary file and renames the temporary file into place, thereby +preventing readers from reading a partially written file. Returns 1 if the file +is successfully updated, 0 otherwise. + +Note that if |xolox#misc#perm#get()| and |xolox#misc#perm#set()| cannot be used +to preserve the file owner/group/mode the file is still updated using a rename +(for compatibility with non-UNIX systems and incompatible '/usr/bin/stat' +implementations) so in that case you can still lose the file's +owner/group/mode. + +------------------------------------------------------------------------------- +The *xolox#misc#perm#get()* function + +Get the owner, group and permissions of the pathname given as the first +argument. Returns an opaque value which you can later pass to +|xolox#misc#perm#set()|. + +------------------------------------------------------------------------------- +The *xolox#misc#perm#set()* function + +Set the permissions (the second argument) of the pathname given as the first +argument. Expects a permissions value created by |xolox#misc#perm#get()|. + +------------------------------------------------------------------------------- + *misc-persist-recall-vim-values-from-to-files* +Persist/recall Vim values from/to files ~ + +Vim's |string()| function can be used to serialize Vim script values like +numbers, strings, lists, dictionaries and composites of them to a string which +can later be evaluated using the |eval()| function to turn it back into the +original value. This Vim script provides functions to use these functions to +persist and recall Vim values from/to files. This is very useful for +communication between (possibly concurrent) Vim processes. + +------------------------------------------------------------------------------- +The *xolox#misc#persist#load()* function + +Read a Vim value like a number, string, list or dictionary from a file using +|readfile()| and |eval()|. The first argument is the filename of the file to +read (a string). The optional second argument specifies the default value which +is returned when the file can't be loaded. This function returns the loaded +value or the default value (which itself defaults to the integer 0). + +------------------------------------------------------------------------------- +The *xolox#misc#persist#save()* function + +Write a Vim value like a number, string, list or dictionary to a file using +|string()| and |writefile()|. The first argument is the filename of the file to +write (a string) and the second argument is the value to write (any value). + +This function writes the serialized value to an intermediate file which is then +renamed into place atomically. This avoids issues with concurrent processes +where for example a producer has written a partial file which is read by a +consumer before the file is complete. In this case the consumer would read a +corrupt value. The rename trick avoids this problem. + +------------------------------------------------------------------------------- + *misc-string-handling* +String handling ~ + +------------------------------------------------------------------------------- +The *xolox#misc#str#slug()* function + +Convert a string to a "slug" - something that can be safely used in filenames +and URLs without worrying about quoting/escaping of special characters. + +------------------------------------------------------------------------------- +The *xolox#misc#str#ucfirst()* function + +Uppercase the first character in a string (the first argument). + +------------------------------------------------------------------------------- +The *xolox#misc#str#unescape()* function + +Remove back slash escapes from a string (the first argument). + +------------------------------------------------------------------------------- +The *xolox#misc#str#compact()* function + +Compact whitespace in a string (the first argument). + +------------------------------------------------------------------------------- +The *xolox#misc#str#trim()* function + +Trim all whitespace from the start and end of a string (the first argument). + +------------------------------------------------------------------------------- +The *xolox#misc#str#indent()* function + +Indent all lines in a multi-line string (the first argument) with a specific +number of _space characters_ (the second argument, an integer). + +------------------------------------------------------------------------------- +The *xolox#misc#str#dedent()* function + +Remove common whitespace from a multi line string. + +------------------------------------------------------------------------------- + *misc-test-runner-infrastructure-for-vim-plug-ins* +Test runner & infrastructure for Vim plug-ins ~ + +The Vim auto-load script 'autoload/xolox/misc/test.vim' contains infrastructure +that can be used to run an automated Vim plug-in test suite. It provides a +framework for running test functions, keeping track of the test status, making +assertions and reporting test results to the user. + +------------------------------------------------------------------------------- +The *xolox#misc#test#reset()* function + +Reset counters for executed tests and passed/failed assertions. + +------------------------------------------------------------------------------- +The *xolox#misc#test#summarize()* function + +Print a summary of test results, to be interpreted interactively. + +------------------------------------------------------------------------------- +The *xolox#misc#test#wrap()* function + +Call a function in a try/catch block and prevent exceptions from bubbling. The +name of the function should be passed as the first and only argument; it should +be a string containing the name of a Vim auto-load function. + +------------------------------------------------------------------------------- +The *xolox#misc#test#passed()* function + +Record a test which succeeded. + +------------------------------------------------------------------------------- +The *xolox#misc#test#failed()* function + +Record a test which failed. + +------------------------------------------------------------------------------- +The *xolox#misc#test#assert_true()* function + +Check whether an expression is true. + +------------------------------------------------------------------------------- +The *xolox#misc#test#assert_equals()* function + +Check whether two values are the same. + +------------------------------------------------------------------------------- +The *xolox#misc#test#assert_same_type()* function + +Check whether two values are of the same type. + +------------------------------------------------------------------------------- + *tests-for-miscellaneous-vim-scripts* +Tests for the miscellaneous Vim scripts ~ + +The Vim auto-load script 'autoload/xolox/misc/tests.vim' contains the automated +test suite of the miscellaneous Vim scripts. Right now the coverage is not very +high yet, but this will improve over time. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#run()* function + +Run the automated test suite of the miscellaneous Vim scripts. To be used +interactively. Intended to be safe to execute irrespective of context. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#pattern_escaping()* function + +Test escaping of regular expression patterns with +|xolox#misc#escape#pattern()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#substitute_escaping()* function + +Test escaping of substitution strings with |xolox#misc#escape#substitute()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#shell_escaping()* function + +Test escaping of shell arguments with |xolox#misc#escape#shell()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#making_a_list_unique()* function + +Test removing of duplicate values from lists with |xolox#misc#list#unique()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#binary_insertion()* function + +Test the binary insertion algorithm implemented in |xolox#misc#list#binsert()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#getting_configuration_options()* function + +Test getting of scoped plug-in configuration "options" with +|xolox#misc#option#get()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#splitting_of_multi_valued_options()* function + +Test splitting of multi-valued Vim options with |xolox#misc#option#split()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#joining_of_multi_valued_options()* function + +Test joining of multi-valued Vim options with |xolox#misc#option#join()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#finding_vim_on_the_search_path()* function + +Test looking up Vim's executable on the search path using |v:progname| with +|xolox#misc#os#find_vim()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#synchronous_command_execution()* function + +Test basic functionality of synchronous command execution with +|xolox#misc#os#exec()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#synchronous_command_execution_with_stderr()* function + +Test basic functionality of synchronous command execution with +|xolox#misc#os#exec()| including the standard error stream (not available on +Windows when vim-shell is not installed). + +------------------------------------------------------------------------------- +The *xolox#misc#tests#synchronous_command_execution_with_raising_of_errors()* +function + +Test raising of errors during synchronous command execution with +|xolox#misc#os#exec()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#synchronous_command_execution_without_raising_errors()* +function + +Test synchronous command execution without raising of errors with +|xolox#misc#os#exec()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#asynchronous_command_execution()* function + +Test the basic functionality of asynchronous command execution with +|xolox#misc#os#exec()|. This runs the external command 'mkdir' and tests that +the side effect of creating the directory takes place. This might seem like a +peculiar choice, but it's one of the few 100% portable commands (Windows + +UNIX) that doesn't involve input/output streams. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#string_case_transformation()* function + +Test string case transformation with |xolox#misc#str#ucfirst()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#string_whitespace_compaction()* function + +Test compaction of whitespace in strings with |xolox#misc#str#compact()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#string_whitespace_trimming()* function + +Test trimming of whitespace in strings with |xolox#misc#str#trim()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#multiline_string_dedent()* function + +Test dedenting of multi-line strings with |xolox#misc#str#dedent()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#version_string_parsing()* function + +Test parsing of version strings with |xolox#misc#version#parse()|. + +------------------------------------------------------------------------------- +The *xolox#misc#tests#version_string_comparison()* function + +Test comparison of version strings with |xolox#misc#version#at_least()|. + +------------------------------------------------------------------------------- + *misc-timing-of-long-during-operations* +Timing of long during operations ~ + +------------------------------------------------------------------------------- +The *xolox#misc#timer#resumable()* function + +Create a resumable timer object. This returns an object (a dictionary with +functions) with the following "methods": + +- 'start()' instructs the timer object to start counting elapsed time (when a + timer object is created it is not automatically started). + +- 'stop()' instructs the timer object to stop counting elapsed time. This + adds the time elapsed since 'start()' was last called to the total elapsed + time. This method will raise an error if called out of sequence. + +- 'format()' takes the total elapsed time and reports it as a string + containing a formatted floating point number. + +Timer objects are meant to accurately time short running operations so they're +dependent on Vim's |reltime()| and |reltimestr()| functions. In order to make +it possible to use timer objects in my Vim plug-ins unconditionally there's a +fall back to |localtime()| when |reltime()| is not available. In this mode the +timer objects are not very useful but at least they shouldn't raise errors. + +------------------------------------------------------------------------------- +The *xolox#misc#timer#start()* function + +Start a timer. This returns a list which can later be passed to +|xolox#misc#timer#stop()|. + +------------------------------------------------------------------------------- +The *xolox#misc#timer#stop()* function + +Show a formatted debugging message to the user, if the user has enabled +increased verbosity by setting Vim's |'verbose'| option to one (1) or higher. + +This function has the same argument handling as Vim's |printf()| function with +one difference: At the point where you want the elapsed time to be embedded, +you write '%s' and you pass the list returned by |xolox#misc#timer#start()| as +an argument. + +------------------------------------------------------------------------------- +The *xolox#misc#timer#force()* function + +Show a formatted message to the user. This function has the same argument +handling as Vim's |printf()| function with one difference: At the point where +you want the elapsed time to be embedded, you write '%s' and you pass the list +returned by |xolox#misc#timer#start()| as an argument. + +------------------------------------------------------------------------------- +The *xolox#misc#timer#convert()* function + +Convert the value returned by |xolox#misc#timer#start()| to a string +representation of the elapsed time since |xolox#misc#timer#start()| was called. +Other values are returned unmodified (this allows using it with Vim's |map()| +function). + +------------------------------------------------------------------------------- + *misc-version-string-handling* +Version string handling ~ + +------------------------------------------------------------------------------- +The *xolox#misc#version#parse()* function + +Convert a version string to a list of integers. + +------------------------------------------------------------------------------- +The *xolox#misc#version#at_least()* function + +Check whether the second version string is equal to or greater than the first +version string. Returns 1 (true) when it is, 0 (false) otherwise. + +=============================================================================== + *misc-contact* +Contact ~ + +If you have questions, bug reports, suggestions, etc. please open an issue or +pull request on GitHub [14]. Download links and documentation can be found on +the plug-in's homepage [15]. If you like the script please vote for it on Vim +Online [16]. + +=============================================================================== + *misc-license* +License ~ + +This software is licensed under the MIT license [17]. © 2015 Peter Odding +. + +=============================================================================== + *misc-references* +References ~ + +[1] http://peterodding.com/code/vim/ +[2] http://peterodding.com/code/vim/downloads/misc.zip +[3] http://www.vim.org/scripts/script.php?script_id=2332 +[4] https://github.com/gmarik/vundle +[5] http://peterodding.com/code/vim/tools/ +[6] http://peterodding.com/code/vim/easytags/ +[7] http://peterodding.com/code/vim/misc/ +[8] http://peterodding.com/code/vim/notes/ +[9] http://peterodding.com/code/vim/notes/#recentnotes_command +[10] http://peterodding.com/code/vim/notes/#showtaggednotes_command +[11] http://peterodding.com/code/vim/session/ +[12] https://github.com/xolox/vim-misc/pull/16 +[13] http://peterodding.com/code/vim/shell/ +[14] http://github.com/xolox/vim-misc +[15] http://peterodding.com/code/vim/misc +[16] http://www.vim.org/scripts/script.php?script_id=4597 +[17] http://en.wikipedia.org/wiki/MIT_License + +vim: ft=help diff --git a/.vim/ftdetect/c-detect.vim b/.vim/ftdetect/c-detect.vim new file mode 100644 index 0000000..4e04b4b --- /dev/null +++ b/.vim/ftdetect/c-detect.vim @@ -0,0 +1,3 @@ +" place in .vim/ftdetect/ +au BufRead,BufNewFile *.c set filetype=c +au BufRead,BufNewFile *.h set filetype=c diff --git a/.vim/ftdetect/c0-detect.vim b/.vim/ftdetect/c0-detect.vim new file mode 100644 index 0000000..d54c833 --- /dev/null +++ b/.vim/ftdetect/c0-detect.vim @@ -0,0 +1,3 @@ +" place in .vim/ftdetect/ +au BufRead,BufNewFile *.c0 set filetype=c0 +au BufRead,BufNewFile *.h0 set filetype=c0 diff --git a/.vim/ftdetect/jade-detect.vim b/.vim/ftdetect/jade-detect.vim new file mode 100644 index 0000000..28b0eac --- /dev/null +++ b/.vim/ftdetect/jade-detect.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.jade set filetype=jade diff --git a/.vim/ftdetect/javascript.vim b/.vim/ftdetect/javascript.vim new file mode 100644 index 0000000..036b352 --- /dev/null +++ b/.vim/ftdetect/javascript.vim @@ -0,0 +1,10 @@ +au BufNewFile,BufRead *.js setf javascript +au BufNewFile,BufRead *.jsm setf javascript +au BufNewFile,BufRead Jakefile setf javascript + +fun! s:SelectJavascript() + if getline(1) =~# '^#!.*/bin/env\s\+node\>' + set ft=javascript + endif +endfun +au BufNewFile,BufRead * call s:SelectJavascript() diff --git a/.vim/ftdetect/setty-detect.vim b/.vim/ftdetect/setty-detect.vim new file mode 100644 index 0000000..d31af7f --- /dev/null +++ b/.vim/ftdetect/setty-detect.vim @@ -0,0 +1,2 @@ +" place in .vim/ftdetect/ +au BufRead,BufNewFile *.set set filetype=setty diff --git a/.vim/ftplugin/c.vim b/.vim/ftplugin/c.vim new file mode 100644 index 0000000..bcda2dd --- /dev/null +++ b/.vim/ftplugin/c.vim @@ -0,0 +1 @@ +setlocal spell diff --git a/.vim/ftplugin/html.vim b/.vim/ftplugin/html.vim new file mode 100644 index 0000000..0b9c779 --- /dev/null +++ b/.vim/ftplugin/html.vim @@ -0,0 +1,2 @@ +setlocal spell spelllang=en_us +setlocal linebreak diff --git a/.vim/ftplugin/jade.vim b/.vim/ftplugin/jade.vim new file mode 100644 index 0000000..30bb410 --- /dev/null +++ b/.vim/ftplugin/jade.vim @@ -0,0 +1,2 @@ +set textwidth=80 +set wrap linebreak breakat diff --git a/.vim/ftplugin/setty.vim b/.vim/ftplugin/setty.vim new file mode 100644 index 0000000..38b436c --- /dev/null +++ b/.vim/ftplugin/setty.vim @@ -0,0 +1,26 @@ +abbrev forall ∀ +abbrev exists ∃ +abbrev not ¬ +abbrev and ∧ +abbrev or ∨ +abbrev intersect ∩ +abbrev union ∪ +abbrev in ∈ +abbrev notin ∉ +abbrev minus ∖ +abbrev to → +abbrev != ≠ +abbrev <= ≤ +abbrev >= ≥ +abbrev implies ⟹ +abbrev iff ⟺ +abbrev epsilon ε +abbrev powerset ℘ + +" Do the rest of the greek letters +abbrev @ ∅ +abbrev nats ℕ +abbrev ints ℤ +" +" +" Should support subset, subseteq diff --git a/.vim/ftplugin/tex.vim b/.vim/ftplugin/tex.vim new file mode 100644 index 0000000..0b9c779 --- /dev/null +++ b/.vim/ftplugin/tex.vim @@ -0,0 +1,2 @@ +setlocal spell spelllang=en_us +setlocal linebreak diff --git a/.vim/ftplugin/text.vim b/.vim/ftplugin/text.vim new file mode 100644 index 0000000..0b9c779 --- /dev/null +++ b/.vim/ftplugin/text.vim @@ -0,0 +1,2 @@ +setlocal spell spelllang=en_us +setlocal linebreak diff --git a/.vim/indent/c.vim b/.vim/indent/c.vim new file mode 100644 index 0000000..5f61579 --- /dev/null +++ b/.vim/indent/c.vim @@ -0,0 +1,4 @@ +setlocal expandtab +setlocal tabstop=4 +setlocal softtabstop=2 +setlocal shiftwidth=2 diff --git a/.vim/indent/c0.vim b/.vim/indent/c0.vim new file mode 100644 index 0000000..5f61579 --- /dev/null +++ b/.vim/indent/c0.vim @@ -0,0 +1,4 @@ +setlocal expandtab +setlocal tabstop=4 +setlocal softtabstop=2 +setlocal shiftwidth=2 diff --git a/.vim/indent/h.vim b/.vim/indent/h.vim new file mode 100644 index 0000000..5f61579 --- /dev/null +++ b/.vim/indent/h.vim @@ -0,0 +1,4 @@ +setlocal expandtab +setlocal tabstop=4 +setlocal softtabstop=2 +setlocal shiftwidth=2 diff --git a/.vim/indent/html.vim b/.vim/indent/html.vim new file mode 100644 index 0000000..241b1bc --- /dev/null +++ b/.vim/indent/html.vim @@ -0,0 +1,4 @@ +setlocal expandtab +setlocal tabstop=4 +setlocal softtabstop=4 +setlocal shiftwidth=2 diff --git a/.vim/indent/jade.vim b/.vim/indent/jade.vim new file mode 100644 index 0000000..d38e640 --- /dev/null +++ b/.vim/indent/jade.vim @@ -0,0 +1,72 @@ +" Vim indent file +" Language: Jade +" Maintainer: Joshua Borton +" Credits: Tim Pope (vim-jade) +" Last Change: 2010 Sep 22 + +if exists("b:did_indent") + finish +endif + +unlet! b:did_indent +let b:did_indent = 1 + +setlocal autoindent +setlocal indentexpr=GetJadeIndent() +setlocal indentkeys=o,O,*,},],0),!^F + +" Only define the function once. +if exists("*GetJadeIndent") + finish +endif + +let s:attributes = '\%((.\{-\})\)' +let s:tag = '\([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*' + +if !exists('g:jade_self_closing_tags') + let g:jade_self_closing_tags = 'meta|link|img|hr|br|input' +endif + +setlocal formatoptions+=r +setlocal comments+=n:\| + +function! GetJadeIndent() + let lnum = prevnonblank(v:lnum-1) + if lnum == 0 + return 0 + endif + let line = substitute(getline(lnum),'\s\+$','','') + let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','') + let lastcol = strlen(line) + let line = substitute(line,'^\s\+','','') + let indent = indent(lnum) + let cindent = indent(v:lnum) + let increase = indent + &sw + if indent == indent(lnum) + let indent = cindent <= indent ? -1 : increase + endif + + let group = synIDattr(synID(lnum,lastcol,1),'name') + + if line =~ '^!!!' + return indent + elseif line =~ '^/\%(\[[^]]*\]\)\=$' + return increase + elseif line =~ '^\%(if\|else\|unless\|for\|each\|block\|mixin\|append\|case\|when\)' + return increase + elseif line =~ '^'.s:tag.'[&!]\=[=~-].*,\s*$' + return increase + elseif line == '-#' + return increase + elseif line =~? '^\v%('.g:jade_self_closing_tags.')>' + return indent + elseif group =~? '\v^%(jadeAttributesDelimiter|jadeClass|jadeId|htmlTagName|htmlSpecialTagName|jadeFilter|jadeTagBlockChar)$' + return increase + else + return indent + endif +endfunction + +set expandtab +set tabstop=2 +set shiftwidth=2 diff --git a/.vim/indent/javascript.vim b/.vim/indent/javascript.vim new file mode 100644 index 0000000..5f61579 --- /dev/null +++ b/.vim/indent/javascript.vim @@ -0,0 +1,4 @@ +setlocal expandtab +setlocal tabstop=4 +setlocal softtabstop=2 +setlocal shiftwidth=2 diff --git a/.vim/indent/python.vim b/.vim/indent/python.vim new file mode 100644 index 0000000..b9a3757 --- /dev/null +++ b/.vim/indent/python.vim @@ -0,0 +1,199 @@ +" Python indent file +" Language: Python +" Maintainer: Eric Mc Sween +" Original Author: David Bustos +" Last Change: 2004 Jun 07 + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal expandtab +setlocal nolisp +setlocal tabstop=4 +setlocal softtabstop=4 +setlocal shiftwidth=4 +setlocal autoindent +setlocal indentexpr=GetPythonIndent(v:lnum) +setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif,=except + +let s:maxoff = 50 + +" Find backwards the closest open parenthesis/bracket/brace. +function! s:SearchParensPair() + let line = line('.') + let col = col('.') + + " Skip strings and comments and don't look too far + let skip = "line('.') < " . (line - s:maxoff) . " ? dummy :" . + \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? ' . + \ '"string\\|comment"' + + " Search for parentheses + call cursor(line, col) + let parlnum = searchpair('(', '', ')', 'bW', skip) + let parcol = col('.') + + " Search for brackets + call cursor(line, col) + let par2lnum = searchpair('\[', '', '\]', 'bW', skip) + let par2col = col('.') + + " Search for braces + call cursor(line, col) + let par3lnum = searchpair('{', '', '}', 'bW', skip) + let par3col = col('.') + + " Get the closest match + if par2lnum > parlnum || (par2lnum == parlnum && par2col > parcol) + let parlnum = par2lnum + let parcol = par2col + endif + if par3lnum > parlnum || (par3lnum == parlnum && par3col > parcol) + let parlnum = par3lnum + let parcol = par3col + endif + + " Put the cursor on the match + if parlnum > 0 + call cursor(parlnum, parcol) + endif + return parlnum +endfunction + +" Find the start of a multi-line statement +function! s:StatementStart(lnum) + let lnum = a:lnum + while 1 + if getline(lnum - 1) =~ '\\$' + let lnum = lnum - 1 + else + call cursor(lnum, 1) + let maybe_lnum = s:SearchParensPair() + if maybe_lnum < 1 + return lnum + else + let lnum = maybe_lnum + endif + endif + endwhile +endfunction + +" Find the block starter that matches the current line +function! s:BlockStarter(lnum, block_start_re) + let lnum = a:lnum + let maxindent = 10000 " whatever + while lnum > 1 + let lnum = prevnonblank(lnum - 1) + if indent(lnum) < maxindent + if getline(lnum) =~ a:block_start_re + return lnum + else + let maxindent = indent(lnum) + " It's not worth going further if we reached the top level + if maxindent == 0 + return -1 + endif + endif + endif + endwhile + return -1 +endfunction + +function! GetPythonIndent(lnum) + + " First line has indent 0 + if a:lnum == 1 + return 0 + endif + + " If we can find an open parenthesis/bracket/brace, line up with it. + call cursor(a:lnum, 1) + let parlnum = s:SearchParensPair() + if parlnum > 0 + let parcol = col('.') + let closing_paren = match(getline(a:lnum), '^\s*[])}]') != -1 + if match(getline(parlnum), '[([{]\s*$', parcol - 1) != -1 + if closing_paren + return indent(parlnum) + else + return indent(parlnum) + &shiftwidth + endif + else + if closing_paren + return parcol - 1 + else + return parcol + endif + endif + endif + + " Examine this line + let thisline = getline(a:lnum) + let thisindent = indent(a:lnum) + + " If the line starts with 'elif' or 'else', line up with 'if' or 'elif' + if thisline =~ '^\s*\(elif\|else\)\>' + let bslnum = s:BlockStarter(a:lnum, '^\s*\(if\|elif\)\>') + if bslnum > 0 + return indent(bslnum) + else + return -1 + endif + endif + + " If the line starts with 'except' or 'finally', line up with 'try' + " or 'except' + if thisline =~ '^\s*\(except\|finally\)\>' + let bslnum = s:BlockStarter(a:lnum, '^\s*\(try\|except\)\>') + if bslnum > 0 + return indent(bslnum) + else + return -1 + endif + endif + + " Examine previous line + let plnum = a:lnum - 1 + let pline = getline(plnum) + let sslnum = s:StatementStart(plnum) + + " If the previous line is blank, keep the same indentation + if pline =~ '^\s*$' + return -1 + endif + + " If this line is explicitly joined, try to find an indentation that looks + " good. + if pline =~ '\\$' + let compound_statement = '^\s*\(if\|while\|for\s.*\sin\|except\)\s*' + let maybe_indent = matchend(getline(sslnum), compound_statement) + if maybe_indent != -1 + return maybe_indent + else + return indent(sslnum) + &sw * 2 + endif + endif + + " If the previous line ended with a colon, indent relative to + " statement start. + if pline =~ ':\s*$' + return indent(sslnum) + &sw + endif + + " If the previous line was a stop-execution statement or a pass + if getline(sslnum) =~ '^\s*\(break\|continue\|raise\|return\|pass\)\>' + " See if the user has already dedented + if indent(a:lnum) > indent(sslnum) - &sw + " If not, recommend one dedent + return indent(sslnum) - &sw + endif + " Otherwise, trust the user + return -1 + endif + + " In all other cases, line up with the start of the previous statement. + return indent(sslnum) +endfunction diff --git a/.vim/indent/setty.vim b/.vim/indent/setty.vim new file mode 100644 index 0000000..cdb2f6a --- /dev/null +++ b/.vim/indent/setty.vim @@ -0,0 +1,203 @@ +" Python indent file +" Language: Python +" Maintainer: Eric Mc Sween +" Original Author: David Bustos +" Last Change: 2004 Jun 07 + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal expandtab +setlocal nolisp +setlocal tabstop=4 +setlocal softtabstop=4 +setlocal shiftwidth=4 +setlocal autoindent +setlocal indentexpr=GetPythonIndent(v:lnum) +setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif,=except + +let s:maxoff = 50 + +" Find backwards the closest open parenthesis/bracket/brace. +function! s:SearchParensPair() + let line = line('.') + let col = col('.') + + " Skip strings and comments and don't look too far + let skip = "line('.') < " . (line - s:maxoff) . " ? dummy :" . + \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? ' . + \ '"string\\|comment"' + + " Search for parentheses + call cursor(line, col) + let parlnum = searchpair('(', '', ')', 'bW', skip) + let parcol = col('.') + + " Search for brackets + call cursor(line, col) + let par2lnum = searchpair('\[', '', '\]', 'bW', skip) + let par2col = col('.') + + " Search for braces + call cursor(line, col) + let par3lnum = searchpair('{', '', '}', 'bW', skip) + let par3col = col('.') + + " Get the closest match + if par2lnum > parlnum || (par2lnum == parlnum && par2col > parcol) + let parlnum = par2lnum + let parcol = par2col + endif + if par3lnum > parlnum || (par3lnum == parlnum && par3col > parcol) + let parlnum = par3lnum + let parcol = par3col + endif + + " Put the cursor on the match + if parlnum > 0 + call cursor(parlnum, parcol) + endif + return parlnum +endfunction + +" Find the start of a multi-line statement +function! s:StatementStart(lnum) + let lnum = a:lnum + while 1 + if getline(lnum - 1) =~ '\\$' + let lnum = lnum - 1 + else + call cursor(lnum, 1) + let maybe_lnum = s:SearchParensPair() + if maybe_lnum < 1 + return lnum + else + let lnum = maybe_lnum + endif + endif + endwhile +endfunction + +" Find the block starter that matches the current line +function! s:BlockStarter(lnum, block_start_re) + let lnum = a:lnum + let maxindent = 10000 " whatever + while lnum > 1 + let lnum = prevnonblank(lnum - 1) + if indent(lnum) < maxindent + if getline(lnum) =~ a:block_start_re + return lnum + else + let maxindent = indent(lnum) + " It's not worth going further if we reached the top level + if maxindent == 0 + return -1 + endif + endif + endif + endwhile + return -1 +endfunction + +function! GetPythonIndent(lnum) + + " First line has indent 0 + if a:lnum == 1 + return 0 + endif + + " If we can find an open parenthesis/bracket/brace, line up with it. + call cursor(a:lnum, 1) + let parlnum = s:SearchParensPair() + if parlnum > 0 + let parcol = col('.') + let closing_paren = match(getline(a:lnum), '^\s*[])}]') != -1 + if match(getline(parlnum), '[([{]\s*$', parcol - 1) != -1 + if closing_paren + return indent(parlnum) + else + return indent(parlnum) + &shiftwidth + endif + else + if closing_paren + return parcol - 1 + else + return parcol + endif + endif + endif + + " Examine this line + let thisline = getline(a:lnum) + let thisindent = indent(a:lnum) + + " If the line starts with 'elif' or 'else', line up with 'if' or 'elif' + if thisline =~ '^\s*\(elif\|else\)\>' + let bslnum = s:BlockStarter(a:lnum, '^\s*\(if\|elif\)\>') + if bslnum > 0 + return indent(bslnum) + else + return -1 + endif + endif + + " If the line starts with 'except' or 'finally', line up with 'try' + " or 'except' + if thisline =~ '^\s*\(except\|finally\)\>' + let bslnum = s:BlockStarter(a:lnum, '^\s*\(try\|except\)\>') + if bslnum > 0 + return indent(bslnum) + else + return -1 + endif + endif + + " Examine previous line + let plnum = a:lnum - 1 + let pline = getline(plnum) + let sslnum = s:StatementStart(plnum) + + " If the previous line is blank, keep the same indentation + if pline =~ '^\s*$' + return -1 + endif + + " If this line is explicitly joined, try to find an indentation that looks + " good. + if pline =~ '\\$' + let compound_statement = '^\s*\(if\|while\|for\s.*\sin\|except\)\s*' + let maybe_indent = matchend(getline(sslnum), compound_statement) + if maybe_indent != -1 + return maybe_indent + else + return indent(sslnum) + &sw * 2 + endif + endif + + " If the previous line ended with a colon, indent relative to + " statement start. + if pline =~ ':\s*$' + return indent(sslnum) + &sw + endif + if pline =~ ':=\s*$' + return indent(sslnum) + &sw + endif + + + " If the previous line was a stop-execution statement or a pass + if getline(sslnum) =~ '^\s*\(break\|continue\|raise\|return\|pass\)\>' + " See if the user has already dedented + if indent(a:lnum) > indent(sslnum) - &sw + " If not, recommend one dedent + return indent(sslnum) - &sw + endif + " Otherwise, trust the user + return -1 + endif + + " In all other cases, line up with the start of the previous statement. + return indent(sslnum) +endfunction diff --git a/.vim/indent/tex.vim b/.vim/indent/tex.vim new file mode 100644 index 0000000..5f61579 --- /dev/null +++ b/.vim/indent/tex.vim @@ -0,0 +1,4 @@ +setlocal expandtab +setlocal tabstop=4 +setlocal softtabstop=2 +setlocal shiftwidth=2 diff --git a/.vim/misc/easytags/highlight.py b/.vim/misc/easytags/highlight.py new file mode 100644 index 0000000..1c391a3 --- /dev/null +++ b/.vim/misc/easytags/highlight.py @@ -0,0 +1,55 @@ +''' +This Python script is part of the easytags plug-in for the Vim text editor. The +Python Interface to Vim is used to load this script which accelerates dynamic +syntax highlighting by reimplementing tag file reading and :syntax command +generation in Python with a focus on doing the least amount of work. + +Author: Peter Odding +Last Change: March 8, 2014 +URL: http://peterodding.com/code/vim/easytags +''' + +# TODO Cache the contents of tags files to further improve performance? + +import re +import vim +import sys + +def easytags_ping(): + print 'it works!' + +def easytags_gensyncmd(tagsfiles, filetype, tagkinds, syntaxgroup, prefix, suffix, filters, ignoresyntax): + # Get arguments from Vim. + if filters: + tagkinds = filters['kind'] + # Shallow parse tags files for matching identifiers. + pattern = '^([^\t]+)\t[^\t]+\t[^\t]+\t' + tagkinds + '\tlanguage:' + re.escape(filetype) + compiled_pattern = re.compile(pattern, re.IGNORECASE) + matches = {} + for fname in tagsfiles: + handle = open(fname) + for line in handle: + m = compiled_pattern.match(line) + if m and ('match' not in filters or re.search(filters['match'], line)) \ + and ('nomatch' not in filters or not re.search(filters['nomatch'], line)): + matches[m.group(1)] = True + handle.close() + # Generate Vim :syntax command to highlight identifiers. + patterns, commands = [], [] + counter, limit = 0, 1024 * 20 + to_escape = re.compile(r'[.*^$/\\~\[\]]') + for ident in matches.keys(): + escaped = to_escape.sub(r'\\\g<0>', ident) + patterns.append(escaped) + counter += len(escaped) + if counter > limit: + commands.append(_easytags_makecmd(syntaxgroup, prefix, suffix, patterns, ignoresyntax)) + patterns = [] + counter = 0 + if patterns: + commands.append(_easytags_makecmd(syntaxgroup, prefix, suffix, patterns, ignoresyntax)) + return ' | '.join(commands) + +def _easytags_makecmd(syntaxgroup, prefix, suffix, patterns, ignoresyntax): + template = r'syntax match %s /%s\%%(%s\)%s/ containedin=ALLBUT,%s' + return template % (syntaxgroup, prefix, r'\|'.join(patterns), suffix, ignoresyntax) diff --git a/.vim/misc/easytags/normalize-tags.py b/.vim/misc/easytags/normalize-tags.py new file mode 100755 index 0000000..a96ed3f --- /dev/null +++ b/.vim/misc/easytags/normalize-tags.py @@ -0,0 +1,80 @@ +#!/usr/bin/python + +''' +Resolve symbolic links in tags files and remove duplicate entries from the +resulting list of tags. If your tags files contain symbolic links as well as +canonical filenames this can significantly reduce the size of your tags file. +This script makes a backup of the tags file in case something goes wrong. + +Author: Peter Odding +Last Change: September 4, 2011 +URL: https://github.com/xolox/vim-easytags/blob/master/normalize-tags.py +''' + +import os, sys, time + +def main(arguments): + for tagsfile in arguments or [os.path.expanduser('~/.vimtags')]: + normalize(tagsfile) + print "Done!" + +def normalize(tagsfile): + + # Setup. + tempname = '%s-new-%d' % (tagsfile, time.time()) + results, cache = {}, {} + infile = open(tagsfile) + outfile = open(tempname, 'w') + nprocessed = 0 + fold_case = False + + # Read tags file. + for line in infile: + line = line.rstrip() + fields = line.split('\t') + if line.startswith('!_TAG_'): + results[line] = True + if line.startswith('!_TAG_FILE_SORTED\t2'): + fold_case = True + else: + pathname = fields[1] + if pathname not in cache: + if os.path.exists(pathname): + cache[pathname] = os.path.realpath(pathname) + else: + cache[pathname] = '' + if cache[pathname]: + fields[1] = cache[pathname] + results['\t'.join(fields)] = True + nprocessed += 1 + infile.close() + + # Sort tags. + lines = results.keys() + if fold_case: + lines.sort(key=str.lower) + else: + lines.sort() + + # Write tags file. + outfile.write('\n'.join(lines)) + outfile.write('\n') + outfile.close() + + # Backup old tags file. + backup = '%s-backup-%d' % (tagsfile, time.time()) + print "Making a backup of %s as %s" % (tagsfile, backup) + os.rename(tagsfile, backup) + + # Replace tags file. + print "Replacing old", tagsfile, "with new one" + os.rename(tempname, tagsfile) + + # Report results. + nfiltered = nprocessed - len(lines) + print "Filtered %d out of %d entries" % (nfiltered, nprocessed) + +if __name__ == '__main__': + main(sys.argv[1:]) + +# vim: ts=2 sw=2 et diff --git a/.vim/misc/easytags/why-so-slow.py b/.vim/misc/easytags/why-so-slow.py new file mode 100755 index 0000000..ead62f2 --- /dev/null +++ b/.vim/misc/easytags/why-so-slow.py @@ -0,0 +1,39 @@ +#!/usr/bin/python + +''' +Determine which files are contributing the most to the size of a tags file. You +can specify the location of the tags file as a command line argument. If you +pass a numeric argument, no more than that many files will be reported. + +Author: Peter Odding +Last Change: May 11, 2011 +URL: https://github.com/xolox/vim-easytags/blob/master/why-so-slow.py +''' + +import os, sys + +tagsfile = '~/.vimtags' +topfiles = 10 + +for arg in sys.argv[1:]: + if os.path.isfile(arg): + tagsfile = arg + else: + topfiles = int(arg) + +infile = open(os.path.expanduser(tagsfile)) +counters = {} + +for line in infile: + fields = line.split('\t') + filename = fields[1] + counters[filename] = counters.get(filename, 0) + len(line) +infile.close() + +sortedfiles = sorted([(s, n) for (n, s) in counters.iteritems()], reverse=True) +for filesize, filename in sortedfiles[:topfiles]: + if filename.startswith(os.environ['HOME']): + filename = filename.replace(os.environ['HOME'], '~') + print '%i KB - %s' % (filesize / 1024, filename) + +# vim: ts=2 sw=2 et diff --git a/.vim/plugin/airline.vim b/.vim/plugin/airline.vim new file mode 100644 index 0000000..d53c492 --- /dev/null +++ b/.vim/plugin/airline.vim @@ -0,0 +1,109 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if &cp || v:version < 702 || (exists('g:loaded_airline') && g:loaded_airline) + finish +endif +let g:loaded_airline = 1 + +" autocmd VimEnter * call airline#deprecation#check() + +let s:airline_initialized = 0 +let s:airline_theme_defined = 0 +function! s:init() + if !s:airline_initialized + let s:airline_initialized = 1 + + call airline#init#bootstrap() + call airline#extensions#load() + call airline#init#sections() + + let s:airline_theme_defined = exists('g:airline_theme') + if s:airline_theme_defined || !airline#switch_matching_theme() + let g:airline_theme = get(g:, 'airline_theme', 'dark') + call airline#switch_theme(g:airline_theme) + endif + endif +endfunction + +function! s:on_window_changed() + if pumvisible() + return + endif + call init() + call airline#update_statusline() +endfunction + +function! s:on_colorscheme_changed() + call init() + if !s:airline_theme_defined + if airline#switch_matching_theme() + return + endif + endif + + " couldn't find a match, or theme was defined, just refresh + call airline#load_theme() +endfunction + +function airline#cmdwinenter(...) + call airline#extensions#apply_left_override('Command Line', '') +endfunction + +function! s:airline_toggle() + if exists("#airline") + augroup airline + au! + augroup END + augroup! airline + + if exists("s:stl") + let &stl = s:stl + endif + + silent doautocmd User AirlineToggledOff + else + let s:stl = &statusline + augroup airline + autocmd! + + autocmd CmdwinEnter * + \ call airline#add_statusline_func('airline#cmdwinenter') + \ | call on_window_changed() + autocmd CmdwinLeave * call airline#remove_statusline_func('airline#cmdwinenter') + + autocmd ColorScheme * call on_colorscheme_changed() + autocmd VimEnter,WinEnter,BufWinEnter,FileType,BufUnload,VimResized * + \ call on_window_changed() + + autocmd BufWritePost */autoload/airline/themes/*.vim + \ exec 'source '.split(globpath(&rtp, 'autoload/airline/themes/'.g:airline_theme.'.vim', 1), "\n")[0] + \ | call airline#load_theme() + augroup END + + silent doautocmd User AirlineToggledOn + + if s:airline_initialized + call on_window_changed() + endif + endif +endfunction + +function! s:get_airline_themes(a, l, p) + let files = split(globpath(&rtp, 'autoload/airline/themes/'.a:a.'*'), "\n") + return map(files, 'fnamemodify(v:val, ":t:r")') +endfunction +function! s:airline_theme(...) + if a:0 + call airline#switch_theme(a:1) + else + echo g:airline_theme + endif +endfunction +command! -nargs=? -complete=customlist,get_airline_themes AirlineTheme call airline_theme() +command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle() +command! AirlineToggle call airline_toggle() +command! AirlineRefresh call airline#load_theme() | call airline#update_statusline() + +call airline_toggle() + diff --git a/.vim/plugin/easytags.vim b/.vim/plugin/easytags.vim new file mode 100644 index 0000000..324fa81 --- /dev/null +++ b/.vim/plugin/easytags.vim @@ -0,0 +1,144 @@ +" Vim plug-in +" Author: Peter Odding +" Last Change: June 29, 2014 +" URL: http://peterodding.com/code/vim/easytags/ +" Requires: Exuberant Ctags (http://ctags.sf.net) + +" Support for automatic update using the GLVS plug-in. +" GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip + +" Don't source the plug-in when it's already been loaded or &compatible is set. +if &cp || exists('g:loaded_easytags') + finish +endif + +" Make sure vim-misc is installed. {{{1 + +try + " The point of this code is to do something completely innocent while making + " sure the vim-misc plug-in is installed. We specifically don't use Vim's + " exists() function because it doesn't load auto-load scripts that haven't + " already been loaded yet (last tested on Vim 7.3). + call type(g:xolox#misc#version) +catch + echomsg "Warning: The vim-easytags plug-in requires the vim-misc plug-in which seems not to be installed! For more information please review the installation instructions in the readme (also available on the homepage and on GitHub). The vim-easytags plug-in will now be disabled." + let g:loaded_easytags = 1 + finish +endtry + +" Configuration defaults and initialization. {{{1 + +if !exists('g:easytags_file') + if xolox#misc#os#is_win() + let g:easytags_file = '~\_vimtags' + else + let g:easytags_file = '~/.vimtags' + endif +endif + +if !exists('g:easytags_by_filetype') + let g:easytags_by_filetype = '' +endif + +if !exists('g:easytags_events') + let g:easytags_events = ['BufWritePost'] + if !exists('g:easytags_on_cursorhold') || g:easytags_on_cursorhold + call extend(g:easytags_events, ['CursorHold', 'CursorHoldI']) + endif + if exists('g:easytags_always_enabled') && g:easytags_always_enabled + call extend(g:easytags_events, ['BufReadPost', 'FocusGained', 'ShellCmdPost', 'ShellFilterPost']) + endif +endif + +if !exists('g:easytags_ignored_filetypes') + let g:easytags_ignored_filetypes = '^tex$' +endif + +if exists('g:easytags_ignored_syntax_groups') + call xolox#misc#msg#warn("easytags.vim %s: The 'g:easytags_ignored_syntax_groups' option is no longer supported. It has been moved back into the code base for more flexible handling at runtime.", g:xolox#easytags#version) +endif + +if !exists('g:easytags_python_script') + let g:easytags_python_script = expand(':p:h') . '/../misc/easytags/highlight.py' +endif + +" Make sure Exuberant Ctags >= 5.5 is installed. +if !xolox#easytags#initialize('5.5') + " Did the user configure the plug-in to suppress the regular warning message? + if !(exists('g:easytags_suppress_ctags_warning') && g:easytags_suppress_ctags_warning) + " Explain to the user what went wrong: + if !exists('g:easytags_ctags_version') || empty(g:easytags_ctags_version) + " Exuberant Ctags is not installed / could not be found. + let s:msg = "easytags.vim %s: Plug-in not loaded because Exuberant Ctags isn't installed!" + if executable('apt-get') + let s:msg .= " On Ubuntu & Debian you can install Exuberant Ctags by" + let s:msg .= " installing the package named `exuberant-ctags':" + let s:msg .= " sudo apt-get install exuberant-ctags" + else + let s:msg .= " Please download & install Exuberant Ctags from http://ctags.sf.net" + endif + call xolox#misc#msg#warn(s:msg, g:xolox#easytags#version) + else + " The installed version is too old. + let s:msg = "easytags.vim %s: Plug-in not loaded because Exuberant Ctags 5.5" + let s:msg .= " or newer is required while you have version %s installed!" + call xolox#misc#msg#warn(s:msg, g:xolox#easytags#version, g:easytags_ctags_version) + endif + unlet s:msg + endif + " Stop loading the plug-in; don't define the (automatic) commands. + finish +endif + +" The plug-in initializes the &tags option as soon as possible so that the +" global tags file is available when using "vim -t some_tag". If &tags is +" reset, we'll try again on the "VimEnter" automatic command event (below). +call xolox#easytags#register(1) + +" The :UpdateTags and :HighlightTags commands. {{{1 + +command! -bar -bang -nargs=* -complete=file UpdateTags call xolox#easytags#update(0, == '!', []) +command! -bar HighlightTags call xolox#easytags#highlight() +command! -bang TagsByFileType call xolox#easytags#update#convert_by_filetype( == '!') + +" Automatic commands. {{{1 + +augroup PluginEasyTags + autocmd! + " This is the alternative way of registering the global tags file using + " the automatic command event "VimEnter". Apparently this makes the + " plug-in behave better when used together with tplugin? + autocmd VimEnter * call xolox#easytags#register(1) + " Define the automatic commands to perform updating/highlighting. + for s:eventname in g:easytags_events + if s:eventname !~? 'cursorhold' + execute 'autocmd' s:eventname '* call xolox#easytags#autoload(' string(s:eventname) ')' + endif + endfor + " Define an automatic command to register file type specific tags files? + if !empty(g:easytags_by_filetype) + autocmd FileType * call xolox#easytags#register(0) + endif + " After reloading a buffer the dynamic syntax highlighting is lost. The + " following code makes sure the highlighting is refreshed afterwards. + autocmd BufReadPost * unlet! b:easytags_last_highlighted + " During :vimgrep each searched buffer triggers an asynchronous tags file + " update resulting in races for the tags file. To avoid this we temporarily + " disable automatic tags file updates during :vimgrep. + autocmd QuickFixCmdPre *vimgrep* call xolox#easytags#disable_automatic_updates() + autocmd QuickFixCmdPost *vimgrep* call xolox#easytags#restore_automatic_updates() +augroup END + +" Use vim-misc to register an event handler for Vim's CursorHold and +" CursorHoldI events which is rate limited so that our event handler is never +" called more than once every interval. +if index(g:easytags_events, 'CursorHold') >= 0 + call xolox#misc#cursorhold#register({'function': 'xolox#easytags#autoload', 'arguments': ['CursorHold'], 'interval': xolox#misc#option#get('easytags_updatetime_min', 4000)/1000}) +endif + +" }}}1 + +" Make sure the plug-in is only loaded once. +let g:loaded_easytags = 1 + +" vim: ts=2 sw=2 et diff --git a/.vim/plugin/xolox/misc.vim b/.vim/plugin/xolox/misc.vim new file mode 100644 index 0000000..af65d55 --- /dev/null +++ b/.vim/plugin/xolox/misc.vim @@ -0,0 +1,19 @@ +" Vim plug-in +" Author: Peter Odding +" Last Change: June 21, 2014 +" URL: http://peterodding.com/code/vim/misc/ + +" Don't source the plug-in when it's already been loaded or &compatible is set. +if &cp || exists('g:loaded_xolox_misc') + finish +endif + +" Automatic commands used by the vim-misc plug-in. +augroup PluginXoloxMisc + autocmd! CursorHold,CursorHoldI * call xolox#misc#cursorhold#autocmd() +augroup END + +" Make sure the plug-in is only loaded once. +let g:loaded_xolox_misc = 1 + +" vim: ts=2 sw=2 et diff --git a/.vim/syntax/c.vim b/.vim/syntax/c.vim new file mode 100644 index 0000000..628e484 --- /dev/null +++ b/.vim/syntax/c.vim @@ -0,0 +1,3 @@ +syn keyword cAssert ASSERT REQUIRES ENSURES + +hi def link cAssert Keyword diff --git a/.vim/syntax/c0.vim b/.vim/syntax/c0.vim new file mode 100644 index 0000000..54d6adb --- /dev/null +++ b/.vim/syntax/c0.vim @@ -0,0 +1,217 @@ +" Vim syntax file +" Language: C0 +" Maintainer: Josiah Boning (jboning) +" Last Change: 2010 Sep 7 +" A modification of the standard vim C syntax file by Bram. +" +" place in .vim/syntax/ + +" Quit when a (custom) syntax file was already loaded +if exists("b:current_syntax") + finish +endif + +" A bunch of useful C keywords +syn keyword cStatement break return continue +syn keyword cConditional if else +syn keyword cRepeat while for +syn keyword cMemory alloc alloc_array +syn keyword cAssert assert + +syn keyword cTodo contained TODO FIXME XXX + +" It's easy to accidentally add a space after a backslash that was intended +" for line continuation. Some compilers allow it, which makes it +" unpredicatable and should be avoided. +syn match cBadContinuation contained "\\\s\+$" + +" cCommentGroup allows adding matches for special things in comments +syn cluster cCommentGroup contains=cTodo,cBadContinuation + +" String and Character constants +" Highlight special characters (those which have a backslash) differently +syn match cSpecialError display contained "\\[^0'\"?\\abfnrtv]" +syn match cSpecial display contained "\\[0'\"?\\abfnrtv]" +if exists("c_no_cformat") + syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cSpecialError,@Spell +else + if !exists("c_no_c99") " ISO C99 + syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained + else + syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained + endif + syn match cFormat display "%%" contained + syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cSpecialError,cFormat,@Spell +endif + +syn match cCharacter "L\='[^\\]'" +"syn match cCharacter "L\='[^']*'" contains=cSpecial,cSpecialError +syn match cSpecialCharErr "L\='\\[^0'\"?\\abfnrtv]'" +syn match cSpecialCharacter "L\='\\[0'\"?\\abfnrtv]'" + +"when wanted, highlight trailing white space +if exists("c_space_errors") + if !exists("c_no_trail_space_error") + syn match cSpaceError display excludenl "\s\+$" + endif + if !exists("c_no_tab_space_error") + syn match cSpaceError display " \+\t"me=e-1 + endif +endif + +" This should be before cErrInParen to avoid problems with #define ({ xxx }) +if exists("c_curly_error") + syntax match cCurlyError "}" + syntax region cBlock start="{" end="}" contains=ALLBUT,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,@Spell fold +else + syntax region cBlock start="{" end="}" transparent fold +endif + +"catch errors caused by wrong parenthesis and brackets +syn cluster cParenGroup contains=cParenError,cUse,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cBitField,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cNumbersCom +if exists("c_no_curly_error") + syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@Spell + " cCppParen: same as cParen but ends at end-of-line; used in cDefine + syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell + syn match cParenError display ")" + syn match cErrInParen display contained "^[{}]" +elseif exists("c_no_bracket_error") + syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@Spell + " cCppParen: same as cParen but ends at end-of-line; used in cDefine + syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell + syn match cParenError display ")" + syn match cErrInParen display contained "[{}]" +else + syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@Spell + " cCppParen: same as cParen but ends at end-of-line; used in cDefine + syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell + syn match cParenError display "[\])]" + syn match cErrInParen display contained "[\]{}]" + syn region cBracket transparent start='\[' end=']' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@Spell + " cCppBracket: same as cParen but ends at end-of-line; used in cDefine + syn region cCppBracket transparent start='\[' skip='\\$' excludenl end=']' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell + syn match cErrInBracket display contained "[);{}]" +endif + +"integer number +syn case ignore +syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber +syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" +"hex number +syn match cNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" + +syn case match + +" c0 annotations +syntax keyword cAnnoSpec contained requires ensures loop_invariant assert +syntax match cAnnoVal contained "\\\(result\|length\|old\)" + +if exists("c_comment_strings") + " A comment can contain cString, cCharacter and cNumber. + " But a "*/" inside a cString in a cComment DOES end the comment! So we + " need to use a special type of cString: cCommentString, which also ends on + " "*/", and sees a "*" at the start of the line as comment again. + " Unfortunately this doesn't very well work for // type of comments :-( + syntax match cCommentSkip contained "^\s*\*\($\|\s\+\)" + syntax region cCommentString contained start=+L\=\\\@c and the like don't trigger #use highlighting +syn match cUsed display contained "^.*use.*<[^>]*>" +syn match cUse display "^\s*#\s*use\>\s*["<]" contains=cUsed + +if exists("c_minlines") + let b:c_minlines = c_minlines +else + if !exists("c_no_if0") + let b:c_minlines = 50 " #if 0 constructs can be long + else + let b:c_minlines = 15 " mostly for () constructs + endif +endif +if exists("c_curly_error") + syn sync fromstart +else + exec "syn sync ccomment cComment minlines=" . b:c_minlines +endif + +" Define the default highlighting. +" Only used when an item doesn't have highlighting yet +hi def link cFormat cSpecial +hi def link cCommentL cComment +hi def link cAnnoL cAnno +hi def link cCommentStart cComment +hi def link cConditional Conditional +hi def link cRepeat Repeat +hi def link cMemory Keyword +hi def link cAssert Keyword +hi def link cCharacter Character +hi def link cSpecialCharacter cSpecial +hi def link cNumber Number +hi def link cParenError cError +hi def link cErrInParen cError +hi def link cErrInBracket cError +hi def link cCommentError cError +hi def link cCommentStartError cError +hi def link cSpaceError cError +hi def link cSpecialCharErr cError +hi def link cSpecialError cError +hi def link cCurlyError cError +hi def link cStructure Structure +hi def link cUse Include +hi def link cUsed cString +hi def link cError Error +hi def link cStatement Statement +hi def link cPreCondit PreCondit +hi def link cType Type +hi def link cConstant Constant +hi def link cCommentString cString +hi def link cComment2String cString +hi def link cCommentSkip cComment +hi def link cString String +hi def link cComment Comment +hi def link cAnno Comment +hi def link cAnnoSpec Keyword +hi def link cAnnoVal Keyword +hi def link cSpecial SpecialChar +hi def link cTodo Todo +hi def link cBadContinuation Error +hi def link cCppSkip cCppOut +hi def link cCppOut2 cCppOut +hi def link cCppOut Comment + +let b:current_syntax = "c0" + +" vim: ts=8 diff --git a/.vim/syntax/jade.vim b/.vim/syntax/jade.vim new file mode 100644 index 0000000..d61e4f0 --- /dev/null +++ b/.vim/syntax/jade.vim @@ -0,0 +1,89 @@ +" Vim syntax file +" Language: Jade +" Maintainer: Joshua Borton +" Credits: Tim Pope +" Filenames: *.jade + +if exists("b:current_syntax") + finish +endif + +if !exists("main_syntax") + let main_syntax = 'jade' +endif + +runtime! syntax/html.vim +runtime! syntax/html/html5.vim +silent! syntax include @htmlCoffeescript syntax/coffee.vim +unlet! b:current_syntax +silent! syntax include @htmlStylus syntax/stylus.vim +unlet! b:current_syntax +silent! syntax include @htmlMarkdown syntax/markdown.vim +unlet! b:current_syntax + +syn case match + +syn region javascriptParenthesisBlock start="(" end=")" contains=@htmlJavascript contained keepend +syn cluster htmlJavascript add=javascriptParenthesisBlock + +syn region jadeJavascript matchgroup=jadeJavascriptOutputChar start="[!&]\==\|\~" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend +syn region jadeJavascript matchgroup=jadeJavascriptChar start="-" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend +syn cluster jadeTop contains=jadeBegin,jadeComment,jadeHtmlComment,jadeJavascript +syn match jadeBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=jadeTag,jadeClassChar,jadeIdChar,jadePlainChar,jadeJavascript,jadeScriptConditional,jadeScriptStatement +syn match jadeTag "+\?\w\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@jadeComponent +syn cluster jadeComponent contains=jadeAttributes,jadeIdChar,jadeBlockExpansionChar,jadeClassChar,jadePlainChar,jadeJavascript +syn match jadeComment '\s*\/\/.*$' +syn region jadeHtmlComment start="^\z(\s*\)/" end="^\%(\z1\s\|\s*$\)\@!" +syn region jadeAttributes matchgroup=jadeAttributesDelimiter start="(" end=")" contained contains=@htmlJavascript,jadeHtmlArg,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@jadeComponent +syn match jadeClassChar "\." contained nextgroup=jadeClass +syn match jadeBlockExpansionChar ":\s" contained nextgroup=jadeTag +syn match jadeIdChar "#{\@!" contained nextgroup=jadeId +syn match jadeClass "\%(\w\|-\)\+" contained nextgroup=@jadeComponent +syn match jadeId "\%(\w\|-\)\+" contained nextgroup=@jadeComponent +syn region jadeDocType start="^\s*\(!!!\|doctype\)" end="$" +" Unless I'm mistaken, syntax/html.vim requires +" that the = sign be present for these matches. +" This adds the matches back for jade. +syn keyword jadeHtmlArg contained href title + +syn match jadePlainChar "\\" contained +syn region jadeInterpolation matchgroup=jadeInterpolationDelimiter start="#{" end="}" contains=@htmlJavascript +syn match jadeInterpolationEscape "\\\@[?!]\@!" +syn match jadeScriptStatement "\<\%(each\|block\|prepend\|append\|mixin\|extends\|include\)\>[?!]\@!" + +syn region jadeJavascript start="^\z(\s*\)script\%(:\w\+\)\=" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript,jadeJavascriptTag keepend +syn region jadeJavascriptTag contained start="^\z(\s*\)script\%(:\w\+\)\=" end="$" contains=jadeBegin,jadeTag +syn region jadeCssBlock start="^\z(\s*\)style" nextgroup=@jadeComponent,jadeError end="^\%(\z1\s\|\s*$\)\@!" contains=@jadeTop,@htmlCss keepend + +syn match jadeError "\$" contained + +hi def link jadePlainChar Special +hi def link jadeScriptConditional PreProc +hi def link jadeScriptStatement PreProc +hi def link jadeHtmlArg htmlArg +hi def link jadeAttributeString String +hi def link jadeAttributesDelimiter Identifier +hi def link jadeIdChar Special +hi def link jadeClassChar Special +hi def link jadeBlockExpansionChar Special +hi def link jadeId Identifier +hi def link jadeClass Type +hi def link jadeInterpolationDelimiter Delimiter +hi def link jadeFilter PreProc +hi def link jadeDocType PreProc +hi def link jadeComment Comment +hi def link jadeHtmlComment jadeComment + +let b:current_syntax = "jade" + +if main_syntax == "jade" + unlet main_syntax +endif diff --git a/.vim/syntax/javascript.vim b/.vim/syntax/javascript.vim new file mode 100644 index 0000000..e72c63a --- /dev/null +++ b/.vim/syntax/javascript.vim @@ -0,0 +1,312 @@ +" Vim syntax file +" Language: JavaScript +" Maintainer: vim-javascript community +" URL: https://github.com/pangloss/vim-javascript + +if !exists("main_syntax") + if version < 600 + syntax clear + elseif exists("b:current_syntax") + finish + endif + let main_syntax = 'javascript' +endif + +if !exists('g:javascript_conceal') + let g:javascript_conceal = 0 +endif + +"" Drop fold if it is set but VIM doesn't support it. +let b:javascript_fold='true' +if version < 600 " Don't support the old version + unlet! b:javascript_fold +endif + +"" dollar sign is permittd anywhere in an identifier +setlocal iskeyword+=$ + +syntax sync fromstart + +syntax match jsNoise /\%(:\|,\|\;\|\.\)/ + +"" Program Keywords +syntax keyword jsStorageClass const var let +syntax keyword jsOperator delete instanceof typeof void new in +syntax match jsOperator /\(!\||\|&\|+\|-\|<\|>\|=\|%\|\/\|*\|\~\|\^\)/ +syntax keyword jsBooleanTrue true +syntax keyword jsBooleanFalse false + +"" JavaScript comments +syntax keyword jsCommentTodo TODO FIXME XXX TBD contained +syntax region jsLineComment start=+\/\/+ end=+$+ keepend contains=jsCommentTodo,@Spell +syntax region jsEnvComment start="\%^#!" end="$" display +syntax region jsLineComment start=+^\s*\/\/+ skip=+\n\s*\/\/+ end=+$+ keepend contains=jsCommentTodo,@Spell fold +syntax region jsCvsTag start="\$\cid:" end="\$" oneline contained +syntax region jsComment start="/\*" end="\*/" contains=jsCommentTodo,jsCvsTag,@Spell fold + +"" JSDoc / JSDoc Toolkit +if !exists("javascript_ignore_javaScriptdoc") + syntax case ignore + + "" syntax coloring for javadoc comments (HTML) + "syntax include @javaHtml :p:h/html.vim + "unlet b:current_syntax + + syntax region jsDocComment matchgroup=jsComment start="/\*\*\s*" end="\*/" contains=jsDocTags,jsCommentTodo,jsCvsTag,@jsHtml,@Spell fold + + " tags containing a param + syntax match jsDocTags contained "@\(alias\|augments\|borrows\|class\|constructs\|default\|defaultvalue\|emits\|exception\|exports\|extends\|file\|fires\|kind\|listens\|member\|memberOf\|mixes\|module\|name\|namespace\|requires\|throws\|var\|variation\|version\)\>" nextgroup=jsDocParam skipwhite + " tags containing type and param + syntax match jsDocTags contained "@\(arg\|argument\|param\|property\)\>" nextgroup=jsDocType skipwhite + " tags containing type but no param + syntax match jsDocTags contained "@\(callback\|enum\|external\|this\|type\|typedef\|return\|returns\)\>" nextgroup=jsDocTypeNoParam skipwhite + " tags containing references + syntax match jsDocTags contained "@\(lends\|see\)\>" nextgroup=jsDocSeeTag skipwhite + " other tags (no extra syntax) + syntax match jsDocTags contained "@\(abstract\|access\|author\|classdesc\|constant\|const\|constructor\|copyright\|deprecated\|desc\|description\|event\|example\|fileOverview\|function\|global\|ignore\|inner\|instance\|license\|method\|mixin\|overview\|private\|protected\|public\|readonly\|since\|static\|todo\|summary\|undocumented\|virtual\)\>" + + syntax region jsDocType start="{" end="}" oneline contained nextgroup=jsDocParam skipwhite + syntax match jsDocType contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" nextgroup=jsDocParam skipwhite + syntax region jsDocTypeNoParam start="{" end="}" oneline contained + syntax match jsDocTypeNoParam contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" + syntax match jsDocParam contained "\%(#\|\"\|{\|}\|\w\|\.\|:\|\/\)\+" + syntax region jsDocSeeTag contained matchgroup=jsDocSeeTag start="{" end="}" contains=jsDocTags + + syntax case match +endif "" JSDoc end + +syntax case match + +"" Syntax in the JavaScript code +syntax match jsFuncCall /\k\+\%(\s*(\)\@=/ +syntax match jsSpecial "\v\\%(0|\\x\x\{2\}\|\\u\x\{4\}\|\c[A-Z]|.)" +syntax region jsStringD start=+"+ skip=+\\\\\|\\$"+ end=+"+ contains=jsSpecial,@htmlPreproc +syntax region jsStringS start=+'+ skip=+\\\\\|\\$'+ end=+'+ contains=jsSpecial,@htmlPreproc +syntax region jsRegexpCharClass start=+\[+ end=+\]+ contained +syntax match jsRegexpBoundary "\v%(\<@![\^$]|\\[bB])" contained +syntax match jsRegexpBackRef "\v\\[1-9][0-9]*" contained +syntax match jsRegexpQuantifier "\v\\@]" contained +syntax cluster jsRegexpSpecial contains=jsRegexpBoundary,jsRegexpBackRef,jsRegexpQuantifier,jsRegexpOr,jsRegexpMod +syntax region jsRegexpGroup start="\\\@\|\<0[xX]\x\+\>/ +syntax keyword jsNumber Infinity +syntax match jsFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/ +syntax match jsObjectKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\(\s*:\)\@=/ contains=jsFunctionKey +syntax match jsFunctionKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\(\s*:\s*function\s*\)\@=/ contained + +"" JavaScript Prototype +syntax keyword jsPrototype prototype + +if g:javascript_conceal == 1 + syntax keyword jsNull null conceal cchar=ø + syntax keyword jsThis this conceal cchar=@ + syntax keyword jsReturn return conceal cchar=⇚ + syntax keyword jsUndefined undefined conceal cchar=¿ + syntax keyword jsNan NaN conceal cchar=ℕ +else + syntax keyword jsNull null + syntax keyword jsThis this + syntax keyword jsReturn return + syntax keyword jsUndefined undefined + syntax keyword jsNan NaN +endif + +"" Statement Keywords +syntax keyword jsStatement break continue with +syntax keyword jsConditional if else switch +syntax keyword jsRepeat do while for +syntax keyword jsLabel case default +syntax keyword jsKeyword yield +syntax keyword jsException try catch throw finally + +syntax keyword jsGlobalObjects Array Boolean Date Function Iterator Number Object RegExp String Proxy ParallelArray ArrayBuffer DataView Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray Intl JSON Math console document window +syntax match jsGlobalObjects /\%(Intl\.\)\@<=\(Collator\|DateTimeFormat\|NumberFormat\)/ + +syntax keyword jsExceptions Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError + +syntax keyword jsBuiltins decodeURI decodeURIComponent encodeURI encodeURIComponent eval isFinite isNaN parseFloat parseInt uneval + +syntax keyword jsFutureKeys abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws goto private transient debugger implements protected volatile double import public + +"" DOM/HTML/CSS specified things + + " DOM2 Objects + syntax keyword jsGlobalObjects DOMImplementation DocumentFragment Document Node NodeList NamedNodeMap CharacterData Attr Element Text Comment CDATASection DocumentType Notation Entity EntityReference ProcessingInstruction + syntax keyword jsExceptions DOMException + + " DOM2 CONSTANT + syntax keyword jsDomErrNo INDEX_SIZE_ERR DOMSTRING_SIZE_ERR HIERARCHY_REQUEST_ERR WRONG_DOCUMENT_ERR INVALID_CHARACTER_ERR NO_DATA_ALLOWED_ERR NO_MODIFICATION_ALLOWED_ERR NOT_FOUND_ERR NOT_SUPPORTED_ERR INUSE_ATTRIBUTE_ERR INVALID_STATE_ERR SYNTAX_ERR INVALID_MODIFICATION_ERR NAMESPACE_ERR INVALID_ACCESS_ERR + syntax keyword jsDomNodeConsts ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECTION_NODE ENTITY_REFERENCE_NODE ENTITY_NODE PROCESSING_INSTRUCTION_NODE COMMENT_NODE DOCUMENT_NODE DOCUMENT_TYPE_NODE DOCUMENT_FRAGMENT_NODE NOTATION_NODE + + " HTML events and internal variables + syntax case ignore + syntax keyword jsHtmlEvents onblur onclick oncontextmenu ondblclick onfocus onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup onresize + syntax case match + +" Follow stuff should be highligh within a special context +" While it can't be handled with context depended with Regex based highlight +" So, turn it off by default +if exists("javascript_enable_domhtmlcss") + + " DOM2 things + syntax match jsDomElemAttrs contained /\%(nodeName\|nodeValue\|nodeType\|parentNode\|childNodes\|firstChild\|lastChild\|previousSibling\|nextSibling\|attributes\|ownerDocument\|namespaceURI\|prefix\|localName\|tagName\)\>/ + syntax match jsDomElemFuncs contained /\%(insertBefore\|replaceChild\|removeChild\|appendChild\|hasChildNodes\|cloneNode\|normalize\|isSupported\|hasAttributes\|getAttribute\|setAttribute\|removeAttribute\|getAttributeNode\|setAttributeNode\|removeAttributeNode\|getElementsByTagName\|getAttributeNS\|setAttributeNS\|removeAttributeNS\|getAttributeNodeNS\|setAttributeNodeNS\|getElementsByTagNameNS\|hasAttribute\|hasAttributeNS\)\>/ nextgroup=jsParen skipwhite + " HTML things + syntax match jsHtmlElemAttrs contained /\%(className\|clientHeight\|clientLeft\|clientTop\|clientWidth\|dir\|id\|innerHTML\|lang\|length\|offsetHeight\|offsetLeft\|offsetParent\|offsetTop\|offsetWidth\|scrollHeight\|scrollLeft\|scrollTop\|scrollWidth\|style\|tabIndex\|title\)\>/ + syntax match jsHtmlElemFuncs contained /\%(blur\|click\|focus\|scrollIntoView\|addEventListener\|dispatchEvent\|removeEventListener\|item\)\>/ nextgroup=jsParen skipwhite + + " CSS Styles in JavaScript + syntax keyword jsCssStyles contained color font fontFamily fontSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight letterSpacing lineBreak lineHeight quotes rubyAlign rubyOverhang rubyPosition + syntax keyword jsCssStyles contained textAlign textAlignLast textAutospace textDecoration textIndent textJustify textJustifyTrim textKashidaSpace textOverflowW6 textShadow textTransform textUnderlinePosition + syntax keyword jsCssStyles contained unicodeBidi whiteSpace wordBreak wordSpacing wordWrap writingMode + syntax keyword jsCssStyles contained bottom height left position right top width zIndex + syntax keyword jsCssStyles contained border borderBottom borderLeft borderRight borderTop borderBottomColor borderLeftColor borderTopColor borderBottomStyle borderLeftStyle borderRightStyle borderTopStyle borderBottomWidth borderLeftWidth borderRightWidth borderTopWidth borderColor borderStyle borderWidth borderCollapse borderSpacing captionSide emptyCells tableLayout + syntax keyword jsCssStyles contained margin marginBottom marginLeft marginRight marginTop outline outlineColor outlineStyle outlineWidth padding paddingBottom paddingLeft paddingRight paddingTop + syntax keyword jsCssStyles contained listStyle listStyleImage listStylePosition listStyleType + syntax keyword jsCssStyles contained background backgroundAttachment backgroundColor backgroundImage gackgroundPosition backgroundPositionX backgroundPositionY backgroundRepeat + syntax keyword jsCssStyles contained clear clip clipBottom clipLeft clipRight clipTop content counterIncrement counterReset cssFloat cursor direction display filter layoutGrid layoutGridChar layoutGridLine layoutGridMode layoutGridType + syntax keyword jsCssStyles contained marks maxHeight maxWidth minHeight minWidth opacity MozOpacity overflow overflowX overflowY verticalAlign visibility zoom cssText + syntax keyword jsCssStyles contained scrollbar3dLightColor scrollbarArrowColor scrollbarBaseColor scrollbarDarkShadowColor scrollbarFaceColor scrollbarHighlightColor scrollbarShadowColor scrollbarTrackColor + + " Highlight ways + syntax match jsDotNotation "\." nextgroup=jsPrototype,jsDomElemAttrs,jsDomElemFuncs,jsHtmlElemAttrs,jsHtmlElemFuncs + syntax match jsDotNotation "\.style\." nextgroup=jsCssStyles + +endif "DOM/HTML/CSS + +"" end DOM/HTML/CSS specified things + + +"" Code blocks +syntax cluster jsExpression contains=jsComment,jsLineComment,jsDocComment,jsStringD,jsStringS,jsRegexpString,jsNumber,jsFloat,jsThis,jsOperator,jsBooleanTrue,jsBooleanFalse,jsNull,jsFunction,jsGlobalObjects,jsExceptions,jsFutureKeys,jsDomErrNo,jsDomNodeConsts,jsHtmlEvents,jsDotNotation,jsBracket,jsParen,jsBlock,jsFuncCall,jsUndefined,jsNan,jsKeyword,jsStorageClass,jsPrototype,jsBuiltins,jsNoise +syntax cluster jsAll contains=@jsExpression,jsLabel,jsConditional,jsRepeat,jsReturn,jsStatement,jsTernaryIf,jsException +syntax region jsBracket matchgroup=jsBrackets start="\[" end="\]" contains=@jsAll,jsParensErrB,jsParensErrC,jsBracket,jsParen,jsBlock,@htmlPreproc fold +syntax region jsParen matchgroup=jsParens start="(" end=")" contains=@jsAll,jsParensErrA,jsParensErrC,jsParen,jsBracket,jsBlock,@htmlPreproc fold +syntax region jsBlock matchgroup=jsBraces start="{" end="}" contains=@jsAll,jsParensErrA,jsParensErrB,jsParen,jsBracket,jsBlock,jsObjectKey,@htmlPreproc fold +syntax region jsFuncBlock matchgroup=jsFuncBraces start="{" end="}" contains=@jsAll,jsParensErrA,jsParensErrB,jsParen,jsBracket,jsBlock,@htmlPreproc contained fold +syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=+?+ end=+:+ contains=@jsExpression,jsTernaryIf + +"" catch errors caused by wrong parenthesis +syntax match jsParensError ")\|}\|\]" +syntax match jsParensErrA contained "\]" +syntax match jsParensErrB contained ")" +syntax match jsParensErrC contained "}" + +if main_syntax == "javascript" + syntax sync clear + syntax sync ccomment jsComment minlines=200 + syntax sync match jsHighlight grouphere jsBlock /{/ +endif + +if g:javascript_conceal == 1 + syntax match jsFunction /\/ nextgroup=jsFuncName,jsFuncArgs skipwhite conceal cchar=ƒ +else + syntax match jsFunction /\/ nextgroup=jsFuncName,jsFuncArgs skipwhite +endif + +syntax match jsFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgroup=jsFuncArgs skipwhite +syntax region jsFuncArgs contained matchgroup=jsFuncParens start='(' end=')' contains=jsFuncArgCommas nextgroup=jsFuncBlock keepend skipwhite skipempty +syntax match jsFuncArgCommas contained ',' +syntax keyword jsArgsObj arguments contained containedin=jsFuncBlock + +" Define the default highlighting. +" For version 5.7 and earlier: only when not done already +" For version 5.8 and later: only when an item doesn't have highlighting yet +if version >= 508 || !exists("did_javascript_syn_inits") + if version < 508 + let did_javascript_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + HiLink jsComment Comment + HiLink jsLineComment Comment + HiLink jsEnvComment PreProc + HiLink jsDocComment Comment + HiLink jsCommentTodo Todo + HiLink jsCvsTag Function + HiLink jsDocTags Special + HiLink jsDocSeeTag Function + HiLink jsDocType Type + HiLink jsDocTypeNoParam Type + HiLink jsDocParam Label + HiLink jsStringS String + HiLink jsStringD String + HiLink jsTernaryIfOperator Conditional + HiLink jsRegexpString String + HiLink jsRegexpBoundary SpecialChar + HiLink jsRegexpQuantifier SpecialChar + HiLink jsRegexpOr Conditional + HiLink jsRegexpMod SpecialChar + HiLink jsRegexpBackRef SpecialChar + HiLink jsRegexpGroup jsRegexpString + HiLink jsRegexpCharClass Character + HiLink jsCharacter Character + HiLink jsPrototype Special + HiLink jsConditional Conditional + HiLink jsBranch Conditional + HiLink jsLabel Label + HiLink jsReturn Statement + HiLink jsRepeat Repeat + HiLink jsStatement Statement + HiLink jsException Exception + HiLink jsKeyword Keyword + HiLink jsFunction Type + HiLink jsFuncName Function + HiLink jsArgsObj Special + HiLink jsError Error + HiLink jsParensError Error + HiLink jsParensErrA Error + HiLink jsParensErrB Error + HiLink jsParensErrC Error + HiLink jsOperator Operator + HiLink jsStorageClass StorageClass + HiLink jsThis Special + HiLink jsNan Number + HiLink jsNull Type + HiLink jsUndefined Type + HiLink jsNumber Number + HiLink jsFloat Float + HiLink jsBooleanTrue Boolean + HiLink jsBooleanFalse Boolean + HiLink jsNoise Noise + HiLink jsBrackets Noise + HiLink jsParens Noise + HiLink jsBraces Noise + HiLink jsFuncBraces Noise + HiLink jsFuncParens Noise + HiLink jsSpecial Special + HiLink jsGlobalObjects Special + HiLink jsExceptions Special + HiLink jsFutureKeys Special + HiLink jsBuiltins Special + + HiLink jsDomErrNo Constant + HiLink jsDomNodeConsts Constant + HiLink jsDomElemAttrs Label + HiLink jsDomElemFuncs PreProc + + HiLink jsHtmlEvents Special + HiLink jsHtmlElemAttrs Label + HiLink jsHtmlElemFuncs PreProc + + HiLink jsCssStyles Label + + delcommand HiLink +endif + +" Define the htmlJavaScript for HTML syntax html.vim +"syntax clear htmlJavaScript +"syntax clear jsExpression +syntax cluster htmlJavaScript contains=@jsAll,jsBracket,jsParen,jsBlock +syntax cluster javaScriptExpression contains=@jsAll,jsBracket,jsParen,jsBlock,@htmlPreproc +" Vim's default html.vim highlights all javascript as 'Special' +hi! def link javaScript NONE + +let b:current_syntax = "javascript" +if main_syntax == 'javascript' + unlet main_syntax +endif diff --git a/.vim/syntax/python.vim b/.vim/syntax/python.vim new file mode 100644 index 0000000..0f31f77 --- /dev/null +++ b/.vim/syntax/python.vim @@ -0,0 +1,3 @@ +syn keyword Bool True False + +hi def link Bool Keyword diff --git a/.vim/syntax/sal.vim b/.vim/syntax/sal.vim new file mode 100644 index 0000000..6c2ebe1 --- /dev/null +++ b/.vim/syntax/sal.vim @@ -0,0 +1,112 @@ +" Vim syntax file +" Language: Symbolic Analysis Library (SAL) +" http://sal.csl.sri.com/ +" Maintainer: Brandon Borkholder +" Filenames: *.sal +" Last Change: 08 March 2007 + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" By convention, keywords are uppercase, but SAL seems to allow both cases +syn case match + +" SAL keywords +syn keyword SALbasicType NATURAL REAL BOOLEAN NZINTEGER INTEGER NZREAL +syn keyword SALtypeKeyword TYPE DATATYPE END STATE +syn keyword SALarrayExpr ARRAY OF +syn keyword SALconditional IF THEN ELSIF ELSE ENDIF +syn keyword SALquantifier FORALL EXISTS +syn keyword SALupdateExpr WITH +syn keyword SALlambdaExpr LAMBDA +syn keyword SALletExpr LET +syn keyword SALinExpr IN +syn keyword SALlogicalOp AND OR NOT XOR +syn keyword SALarithmeticOp DIV MOD +syn keyword SALbaseModule MODULE BEGIN END +syn keyword SALmoduleDecl INPUT OUTPUT GLOBAL LOCAL DEFINITION INITIALIZATION TRANSITION +syn keyword SALmoduleOp RENAME OBSERVE +syn keyword SALcontext CONTEXT +syn keyword SALassertion OBLIGATION CLAIM LEMMA THEOREM +syn keyword SALconstant TRUE FALSE +syn keyword SALtemporalOp AX AG AF EX EG EF X G F + +syn cluster SALtype add=SALbasicType,SALrangeType,SALrecordType,SALsetType,SALfunctionType,SALconstant,SALnumber +syn cluster SALexpression add=SALlogicalOp,SALarithmeticOp,SALarithmetic,@SALtype,SALrelation,SALarrayExpr,SALquantifier +syn cluster SALrange add=SALrangeType,SALrangeDelimiter + +" A TODO setting is always in every syntax file +syn keyword SALTodo contained TODO FIXME XXX + +" SAL comments +syn region SALcomment start=/%/ end=/$/ contains=SALTodo + +" SAL structures and types +syn region SALrecordType start=/\[#/ end=/#\]/ contains=@SALtype +syn region SALrangeType start=/\[[^#].*\.\./ end=/[^#]\]/ contains=@SALexpression +syn region SALfunctionType start=/\[[^#].*->/ end=/[^#]\]/ contains=@SALtype +syn region SALsetType start=/{/ end=/}/ contains=@SALexpression +syn region SALrecordLiteral start=/(#/ end=/#)/ + +" SAL operators and relations +syn match SALrelation /\(=\|\/=\|=>\|<\|[^-]>\|<=\|>=\)/ +syn match SALmoduleCompos /||\|\[\]/ +syn match SALtransition /\(:=\|-->\)/ + +" Numbers +syn match SALnumber /\<\d*\>/ + +" Arithmetic operations +syn match SALarithmetic /\(*\|+\|\/[^=]\|-[^->]\)/ + +" next' variables +syn match SALnextVariable /\<\w\+\>'/ + +" Theorem declarations +syn match SALtheoremDeclaration /\w\+ *: *\(OBLIGATION\|CLAIM\|THEOREM\|LEMMA\)/ contains=theoremName,assertion +syn match SALtheoremName /\w\+/ contained nextgroup=assertion + +" Define new highlight groups +hi SALRelationSyntax guifg=Red ctermfg=Red + +" Now set the colors +hi link SALbasicType Type +hi link SALarrayExpr Type +hi link SALtypeKeyword Define +hi link SALconditional Conditional +hi link SALquantifier Keyword +hi link SALupdateExpr Keyword +hi link SALlambdaExpr Macro +hi link SALletExpr Keyword +hi link SALinExpr Keyword +hi link SALlogicalOp Operator +hi link SALarithmeticOp Operator +hi link SALbaseModule Define +hi link SALmoduleDecl Define +hi link SALmoduleOp Operator +hi link SALcontext Define +hi link SALassertion Underlined +hi link SALconstant Boolean +hi link SALtemporalOp Operator +hi link SALcomment Comment +hi link SALrecordType Structure +hi link SALrangeType Constant +hi link SALfunctionType Function +hi link SALsetType Constant +hi link SALrecordLiteral Constant +hi link SALrelation Statement +hi link SALmoduleCompos Operator +hi link SALtransition SALRelationSyntax +hi link SALnumber Number +hi link SALnextVariable Identifier +hi link SALtheoremDeclaration Underlined +hi link SALtheoremName Underlined + +" Set the current syntax +let b:current_syntax = "sal" + diff --git a/.vim/syntax/setty.vim b/.vim/syntax/setty.vim new file mode 100644 index 0000000..dfaddc2 --- /dev/null +++ b/.vim/syntax/setty.vim @@ -0,0 +1,148 @@ +" Vim syntax file +" Language: Setty +" Maintainer: Adam Blank +" Last Change: 2013 Jun 17 +" Credits: This is based on setty.vim by +" Zvezdan Petkovic +" Neil Schemenauer +" Dmitry Vasiliev +" +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Keep setty keywords in alphabetical order inside groups for easy +" comparison with the table in the 'setty Language Reference' +" +syn keyword settyStatement T, F +syn keyword settyStatement print printx +syn keyword settyStatement return requires recurse +syn keyword settyConditional else if +syn keyword settyRepeat for +syn keyword settyOperator and in not or union intersect minus +syn keyword settyInclude use + +" The zero-length non-grouping match before the function name is +" extremely important in settyFunction. Without it, everything is +" interpreted as a function inside the contained environment of +" doctests. +syn match settyFunction + \ "\%(\%(def\s\|class\s\|@\)\s*\)\@<=\h\%(\w\|\.\)*" contained + +syn match settyComment "#.*$" contains=settyTodo,@Spell +syn keyword settyTodo FIXME NOTE NOTES TODO XXX contained + +" Triple-quoted strings can contain doctests. +syn region settyString + \ start=+[uU]\=\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1" + \ contains=settyEscape,@Spell +syn region settyString + \ start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend + \ contains=settyEscape,settySpaceError,settyDoctest,@Spell +syn region settyRawString + \ start=+[uU]\=[rR]\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1" + \ contains=@Spell +syn region settyRawString + \ start=+[uU]\=[rR]\z('''\|"""\)+ end="\z1" keepend + \ contains=settySpaceError,settyDoctest,@Spell + +syn match settyEscape +\\[abfnrtv'"\\]+ contained +syn match settyEscape "\\\o\{1,3}" contained +syn match settyEscape "\\x\x\{2}" contained +syn match settyEscape "\%(\\u\x\{4}\|\\U\x\{8}\)" contained +" setty allows case-insensitive Unicode IDs: http://www.unicode.org/charts/ +syn match settyEscape "\\N{\a\+\%(\s\a\+\)*}" contained +syn match settyEscape "\\$" + +if exists("setty_highlight_all") + if exists("setty_no_builtin_highlight") + unlet setty_no_builtin_highlight + endif + if exists("setty_no_number_highlight") + unlet setty_no_number_highlight + endif + let setty_space_error_highlight = 1 +endif + +" It is very important to understand all details before changing the +" regular expressions below or their order. +" The word boundaries are *not* the floating-point number boundaries +" because of a possible leading or trailing decimal point. +" The expressions below ensure that all valid number literals are +" highlighted, and invalid number literals are not. For example, +" +" - a decimal point in '4.' at the end of a line is highlighted, +" - a second dot in 1.0.0 is not highlighted, +" - 08 is not highlighted, +" - 08e0 or 08j are highlighted, +" +" and so on, as specified in the 'setty Language Reference'. +if !exists("setty_no_number_highlight") + " numbers (including longs and complex) + syn match settyNumber "\<\%([1-9]\d*\|0\)\=\>" +endif + +" Group the built-ins in the order in the 'setty Library Reference' for +" easier comparison. +" http://docs.setty.org/library/constants.html +" http://docs.setty.org/library/functions.html +" http://docs.setty.org/library/functions.html#non-essential-built-in-functions +" setty built-in functions are in alphabetical order. +if !exists("setty_no_builtin_highlight") + " built-in constants + syn keyword settyBuiltin F T + " built-in functions + syn keyword settyBuiltin pi1 pi2 cardinality lt leq gt geq implies iff unimplemented +endif + +if exists("setty_space_error_highlight") + " trailing whitespace + syn match settySpaceError display excludenl "\s\+$" + " mixed tabs and spaces + syn match settySpaceError display " \+\t" + syn match settySpaceError display "\t\+ " +endif + +if version >= 508 || !exists("did_setty_syn_inits") + if version <= 508 + let did_setty_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + + " The default highlight links. Can be overridden later. + HiLink settyStatement Statement + HiLink settyConditional Conditional + HiLink settyRepeat Repeat + HiLink settyOperator Operator + HiLink settyInclude Include + HiLink settyDecorator Define + HiLink settyFunction Function + HiLink settyComment Comment + HiLink settyTodo Todo + HiLink settyString String + HiLink settyRawString String + HiLink settyEscape Special + if !exists("setty_no_number_highlight") + HiLink settyNumber Number + endif + if !exists("setty_no_builtin_highlight") + HiLink settyBuiltin Function + endif + if exists("setty_space_error_highlight") + HiLink settySpaceError Error + endif + if !exists("setty_no_doctest_highlight") + HiLink settyDoctest Special + HiLink settyDoctestValue Define + endif + + delcommand HiLink +endif + +let b:current_syntax = "setty" + +" vim:set sw=2 sts=2 ts=8 noet: diff --git a/.vim/t/airline.vim b/.vim/t/airline.vim new file mode 100644 index 0000000..78ab6d7 --- /dev/null +++ b/.vim/t/airline.vim @@ -0,0 +1,87 @@ +let g:airline_theme = 'dark' +call airline#init#bootstrap() +call airline#init#sections() +source plugin/airline.vim + +function! MyFuncref(...) + call a:1.add_raw('hello world') + return 1 +endfunction + +function! MyIgnoreFuncref(...) + return -1 +endfunction + +function! MyAppend1(...) + call a:1.add_raw('hello') +endfunction + +function! MyAppend2(...) + call a:1.add_raw('world') +endfunction + +describe 'airline' + before + let g:airline_statusline_funcrefs = [] + end + + it 'should run user funcrefs first' + call airline#add_statusline_func('MyFuncref') + let &statusline = '' + call airline#update_statusline() + Expect airline#statusline(1) =~ 'hello world' + end + + it 'should not change the statusline with -1' + call airline#add_statusline_funcref(function('MyIgnoreFuncref')) + let &statusline = 'foo' + call airline#update_statusline() + Expect &statusline == 'foo' + end + + it 'should support multiple chained funcrefs' + call airline#add_statusline_func('MyAppend1') + call airline#add_statusline_func('MyAppend2') + call airline#update_statusline() + Expect airline#statusline(1) =~ 'helloworld' + end + + it 'should allow users to redefine sections' + let g:airline_section_a = airline#section#create(['mode', 'mode']) + call airline#update_statusline() + Expect airline#statusline(1) =~ '%{airline#util#wrap(airline#parts#mode(),0)}%#airline_a#%#airline_a_bold#%{airline#util#wrap(airline#parts#mode(),0)}%#airline_a#' + end + + it 'should remove funcrefs properly' + let c = len(g:airline_statusline_funcrefs) + call airline#add_statusline_func('MyIgnoreFuncref') + call airline#remove_statusline_func('MyIgnoreFuncref') + Expect len(g:airline_statusline_funcrefs) == c + end + + it 'should overwrite the statusline with active and inactive splits' + wincmd s + Expect airline#statusline(1) !~ 'inactive' + Expect airline#statusline(2) =~ 'inactive' + wincmd c + end + + it 'should collapse the inactive split if the variable is set true' + let g:airline_inactive_collapse = 1 + wincmd s + Expect getwinvar(2, '&statusline') !~ 'airline#parts#mode' + wincmd c + end + + it 'should not collapse the inactive split if the variable is set false' + let g:airline_inactive_collapse = 0 + wincmd s + Expect getwinvar(2, '&statusline') != 'airline#parts#mode' + wincmd c + end + + it 'should include check_mode' + Expect airline#statusline(1) =~ 'airline#check_mode' + end +end + diff --git a/.vim/t/builder.vim b/.vim/t/builder.vim new file mode 100644 index 0000000..57feb14 --- /dev/null +++ b/.vim/t/builder.vim @@ -0,0 +1,106 @@ +let g:airline_theme = 'dark' +call airline#init#bootstrap() + +describe 'active builder' + before + let s:builder = airline#builder#new({'active': 1}) + end + + it 'should start with an empty statusline' + let stl = s:builder.build() + Expect stl == '' + end + + it 'should transition colors from one to the next' + call s:builder.add_section('Normal', 'hello') + call s:builder.add_section('Search', 'world') + let stl = s:builder.build() + Expect stl =~ '%#Normal#hello%#Normal_to_Search#>%#Search#world' + end + + it 'should reuse highlight group if background colors match' + highlight Foo1 ctermfg=1 ctermbg=2 + highlight Foo2 ctermfg=1 ctermbg=2 + call s:builder.add_section('Foo1', 'hello') + call s:builder.add_section('Foo2', 'world') + let stl = s:builder.build() + Expect stl =~ '%#Foo1#hello>world' + end + + it 'should switch highlight groups if foreground colors differ' + highlight Foo1 ctermfg=1 ctermbg=2 + highlight Foo2 ctermfg=2 ctermbg=2 + call s:builder.add_section('Foo1', 'hello') + call s:builder.add_section('Foo2', 'world') + let stl = s:builder.build() + Expect stl =~ '%#Foo1#hello%#Foo1_to_Foo2#>%#Foo2#world' + end + + it 'should split left/right sections' + call s:builder.split() + let stl = s:builder.build() + Expect stl =~ '%=' + end + + it 'after split, sections use the right separator' + call s:builder.split() + call s:builder.add_section('Normal', 'hello') + call s:builder.add_section('Search', 'world') + let stl = s:builder.build() + Expect stl =~ 'hello%#Normal_to_Search#<%#Search#world' + end + + it 'should not repeat the same highlight group' + call s:builder.add_section('Normal', 'hello') + call s:builder.add_section('Normal', 'hello') + let stl = s:builder.build() + Expect stl == '%#Normal#hello>hello' + end + + it 'should replace accent groups with the specified group' + call s:builder.add_section('Normal', '%#__accent_foo#hello') + let stl = s:builder.build() + Expect stl == '%#Normal#%#Normal_foo#hello' + end + + it 'should replace two accent groups with correct groups' + call s:builder.add_section('Normal', '%#__accent_foo#hello%#__accent_bar#world') + let stl = s:builder.build() + Expect stl =~ '%#Normal_foo#hello%#Normal_bar#world' + end + + it 'should special restore group should go back to previous group' + call s:builder.add_section('Normal', '%#__restore__#') + let stl = s:builder.build() + Expect stl !~ '%#__restore__#' + Expect stl =~ '%#Normal#' + end + + it 'should blend colors from the left through the split to the right' + call s:builder.add_section('Normal', 'hello') + call s:builder.split() + call s:builder.add_section('Search', 'world') + let stl = s:builder.build() + Expect stl =~ 'Normal_to_Search' + end +end + +describe 'inactive builder' + before + let s:builder = airline#builder#new({'active': 0}) + end + + it 'should transition colors from one to the next' + call s:builder.add_section('Normal', 'hello') + call s:builder.add_section('Search', 'world') + let stl = s:builder.build() + Expect stl =~ '%#Normal_inactive#hello%#Normal_to_Search_inactive#>%#Search_inactive#world' + end + + it 'should not render accents' + call s:builder.add_section('Normal', '%#__accent_foo#hello%#foo#foo%#__accent_bar#world') + let stl = s:builder.build() + Expect stl == '%#Normal_inactive#hello%#foo_inactive#fooworld' + end +end + diff --git a/.vim/t/commands.vim b/.vim/t/commands.vim new file mode 100644 index 0000000..b56b881 --- /dev/null +++ b/.vim/t/commands.vim @@ -0,0 +1,33 @@ +call airline#init#bootstrap() +call airline#init#sections() + +source plugin/airline.vim + +describe 'commands' + it 'should toggle off and on' + execute 'AirlineToggle' + Expect exists('#airline') to_be_false + execute 'AirlineToggle' + Expect exists('#airline') to_be_true + end + + it 'should toggle whitespace off and on' + call airline#extensions#load() + execute 'AirlineToggleWhitespace' + Expect exists('#airline_whitespace') to_be_false + execute 'AirlineToggleWhitespace' + Expect exists('#airline_whitespace') to_be_true + end + + it 'should display theme name with no args' + execute 'AirlineTheme simple' + Expect g:airline_theme == 'simple' + execute 'AirlineTheme dark' + Expect g:airline_theme == 'dark' + end + + it 'should have a refresh command' + Expect exists(':AirlineRefresh') to_be_true + end +end + diff --git a/.vim/t/extensions_default.vim b/.vim/t/extensions_default.vim new file mode 100644 index 0000000..d6fc572 --- /dev/null +++ b/.vim/t/extensions_default.vim @@ -0,0 +1,33 @@ +let g:airline_theme = 'dark' +call airline#init#bootstrap() +call airline#init#sections() +source plugin/airline.vim +call airline#load_theme() + +describe 'default' + before + let s:builder = airline#builder#new({'active': 1}) + end + + it 'should use the layout' + let g:airline#extensions#default#layout = [ + \ [ 'c', 'a', 'b', 'warning' ], + \ [ 'x', 'z', 'y' ] + \ ] + call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 }) + let stl = s:builder.build() + Expect stl =~ 'airline_c_to_airline_a' + Expect stl =~ 'airline_a_to_airline_b' + Expect stl =~ 'airline_b_to_airline_warning' + Expect stl =~ 'airline_x_to_airline_z' + Expect stl =~ 'airline_z_to_airline_y' + end + + it 'should only render warning section in active splits' + wincmd s + Expect airline#statusline(1) =~ 'warning' + Expect airline#statusline(2) !~ 'warning' + wincmd c + end +end + diff --git a/.vim/t/highlighter.vim b/.vim/t/highlighter.vim new file mode 100644 index 0000000..a1ed490 --- /dev/null +++ b/.vim/t/highlighter.vim @@ -0,0 +1,21 @@ +let g:airline_theme = 'dark' + +describe 'highlighter' + it 'should create separator highlight groups' + hi Foo1 ctermfg=1 ctermbg=2 + hi Foo2 ctermfg=3 ctermbg=4 + call airline#highlighter#add_separator('Foo1', 'Foo2', 0) + let hl = airline#highlighter#get_highlight('Foo1_to_Foo2') + Expect hl == [ '', '', '4', '2', '' ] + end + + it 'should populate accent colors' + Expect exists('g:airline#themes#dark#palette.normal.airline_c_red') to_be_false + Expect hlID('airline_c_red') == 0 + call airline#themes#patch(g:airline#themes#dark#palette) + call airline#highlighter#add_accent('red') + call airline#highlighter#highlight(['normal']) + Expect hlID('airline_c_red') != 0 + end +end + diff --git a/.vim/t/init.vim b/.vim/t/init.vim new file mode 100644 index 0000000..86efe58 --- /dev/null +++ b/.vim/t/init.vim @@ -0,0 +1,77 @@ +let s:sections = ['a', 'b', 'c', 'gutter', 'x', 'y', 'z', 'warning'] + +function! s:clear() + for key in s:sections + unlet! g:airline_section_{key} + endfor +endfunction + +call airline#init#bootstrap() + +describe 'init sections' + before + call s:clear() + call airline#init#sections() + end + + after + call s:clear() + end + + it 'section a should have mode, paste, iminsert' + Expect g:airline_section_a =~ 'mode' + Expect g:airline_section_a =~ 'paste' + Expect g:airline_section_a =~ 'iminsert' + end + + it 'section b should be blank because no extensions are installed' + Expect g:airline_section_b == '' + end + + it 'section c should be file' + Expect g:airline_section_c == '%<%f%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#' + end + + it 'section x should be filetype' + Expect g:airline_section_x == '%{airline#util#wrap(airline#parts#filetype(),0)}' + end + + it 'section y should be fenc and ff' + Expect g:airline_section_y =~ 'ff' + Expect g:airline_section_y =~ 'fenc' + end + + it 'section z should be line numbers' + Expect g:airline_section_z =~ '%3p%%' + Expect g:airline_section_z =~ '%4l' + Expect g:airline_section_z =~ '%3c' + end + + it 'should not redefine sections already defined' + for s in s:sections + let g:airline_section_{s} = s + endfor + call airline#init#bootstrap() + for s in s:sections + Expect g:airline_section_{s} == s + endfor + end + + it 'all default statusline extensions should be blank' + Expect airline#parts#get('hunks').raw == '' + Expect airline#parts#get('branch').raw == '' + Expect airline#parts#get('tagbar').raw == '' + Expect airline#parts#get('syntastic').raw == '' + Expect airline#parts#get('eclim').raw == '' + Expect airline#parts#get('whitespace').raw == '' + end +end + +describe 'init parts' + it 'should not redefine parts already defined' + call airline#parts#define_raw('linenr', 'bar') + call airline#init#sections() + Expect g:airline_section_z =~ 'bar' + end +end + diff --git a/.vim/t/parts.vim b/.vim/t/parts.vim new file mode 100644 index 0000000..ee7c92e --- /dev/null +++ b/.vim/t/parts.vim @@ -0,0 +1,39 @@ +describe 'parts' + it 'overwrites existing values' + call airline#parts#define('foo', { 'test': '123' }) + Expect airline#parts#get('foo').test == '123' + call airline#parts#define('foo', { 'test': '321' }) + Expect airline#parts#get('foo').test == '321' + end + + it 'can define a function part' + call airline#parts#define_function('func', 'bar') + Expect airline#parts#get('func').function == 'bar' + end + + it 'can define a text part' + call airline#parts#define_text('text', 'bar') + Expect airline#parts#get('text').text == 'bar' + end + + it 'can define a raw part' + call airline#parts#define_raw('raw', 'bar') + Expect airline#parts#get('raw').raw == 'bar' + end + + it 'can define a minwidth' + call airline#parts#define_minwidth('mw', 123) + Expect airline#parts#get('mw').minwidth == 123 + end + + it 'can define a condition' + call airline#parts#define_condition('part', '1') + Expect airline#parts#get('part').condition == '1' + end + + it 'can define a accent' + call airline#parts#define_accent('part', 'red') + Expect airline#parts#get('part').accent == 'red' + end +end + diff --git a/.vim/t/section.vim b/.vim/t/section.vim new file mode 100644 index 0000000..034440c --- /dev/null +++ b/.vim/t/section.vim @@ -0,0 +1,76 @@ +function! SectionSpec() +endfunction + +describe 'section' + before + call airline#parts#define_text('text', 'text') + call airline#parts#define_raw('raw', 'raw') + call airline#parts#define_function('func', 'SectionSpec') + end + + it 'should be able to reference default parts' + let s = airline#section#create(['paste']) + Expect s == '%{airline#util#wrap(airline#parts#paste(),0)}' + end + + it 'should create sections with no separators' + let s = airline#section#create(['text', 'raw', 'func']) + Expect s == '%{airline#util#wrap("text",0)}raw%{airline#util#wrap(SectionSpec(),0)}' + end + + it 'should create left sections with separators' + let s = airline#section#create_left(['text', 'text']) + Expect s == '%{airline#util#wrap("text",0)}%{airline#util#append("text",0)}' + end + + it 'should create right sections with separators' + let s = airline#section#create_right(['text', 'text']) + Expect s == '%{airline#util#prepend("text",0)}%{airline#util#wrap("text",0)}' + end + + it 'should prefix with accent group if provided and restore afterwards' + call airline#parts#define('hi', { + \ 'raw': 'hello', + \ 'accent': 'red', + \ }) + let s = airline#section#create(['hi']) + Expect s == '%#__accent_red#hello%#__restore__#' + end + + it 'should accent functions' + call airline#parts#define_function('hi', 'Hello') + call airline#parts#define_accent('hi', 'bold') + let s = airline#section#create(['hi']) + Expect s == '%#__accent_bold#%{airline#util#wrap(Hello(),0)}%#__restore__#' + end + + it 'should parse out a section from the distro' + call airline#extensions#load() + let s = airline#section#create(['whitespace']) + Expect s =~ 'airline#extensions#whitespace#check' + end + + it 'should use parts as is if they are not found' + let s = airline#section#create(['asdf', 'func']) + Expect s == 'asdf%{airline#util#wrap(SectionSpec(),0)}' + end + + it 'should force add separators for raw and missing keys' + let s = airline#section#create_left(['asdf', 'raw']) + Expect s == 'asdf > raw' + let s = airline#section#create_left(['asdf', 'aaaa', 'raw']) + Expect s == 'asdf > aaaa > raw' + let s = airline#section#create_right(['raw', '%f']) + Expect s == 'raw < %f' + let s = airline#section#create_right(['%t', 'asdf', '%{getcwd()}']) + Expect s == '%t < asdf < %{getcwd()}' + end + + it 'should empty out parts that do not pass their condition' + call airline#parts#define_text('conditional', 'conditional') + call airline#parts#define_condition('conditional', '0') + let s = airline#section#create(['conditional']) + Expect s == '%{0 ? airline#util#wrap("conditional",0) : ""}' + end +end + diff --git a/.vim/t/themes.vim b/.vim/t/themes.vim new file mode 100644 index 0000000..d735229 --- /dev/null +++ b/.vim/t/themes.vim @@ -0,0 +1,68 @@ +describe 'themes' + after + highlight clear Foo + highlight clear Normal + end + + it 'should extract correct colors' + highlight Foo ctermfg=1 ctermbg=2 + let colors = airline#themes#get_highlight('Foo') + Expect colors[2] == '1' + Expect colors[3] == '2' + end + + it 'should extract from normal if colors unavailable' + highlight Normal ctermfg=100 ctermbg=200 + highlight Foo ctermbg=2 + let colors = airline#themes#get_highlight('Foo') + Expect colors[2] == '100' + Expect colors[3] == '2' + end + + it 'should flip target group if it is reversed' + highlight Foo ctermbg=222 ctermfg=103 term=reverse + let colors = airline#themes#get_highlight('Foo') + Expect colors[2] == '222' + Expect colors[3] == '103' + end + + it 'should pass args through correctly' + let hl = airline#themes#get_highlight('Foo', 'bold', 'italic') + Expect hl == ['', '', 0, 1, 'bold,italic'] + + let hl = airline#themes#get_highlight2(['Foo','bg'], ['Foo','fg'], 'italic', 'bold') + Expect hl == ['', '', 1, 0, 'italic,bold'] + end + + it 'should generate color map with mirroring' + let map = airline#themes#generate_color_map( + \ [ 1, 1, 1, 1, '1' ], + \ [ 2, 2, 2, 2, '2' ], + \ [ 3, 3, 3, 3, '3' ], + \ ) + Expect map.airline_a[0] == 1 + Expect map.airline_b[0] == 2 + Expect map.airline_c[0] == 3 + Expect map.airline_x[0] == 3 + Expect map.airline_y[0] == 2 + Expect map.airline_z[0] == 1 + end + + it 'should generate color map with full set of colors' + let map = airline#themes#generate_color_map( + \ [ 1, 1, 1, 1, '1' ], + \ [ 2, 2, 2, 2, '2' ], + \ [ 3, 3, 3, 3, '3' ], + \ [ 4, 4, 4, 4, '4' ], + \ [ 5, 5, 5, 5, '5' ], + \ [ 6, 6, 6, 6, '6' ], + \ ) + Expect map.airline_a[0] == 1 + Expect map.airline_b[0] == 2 + Expect map.airline_c[0] == 3 + Expect map.airline_x[0] == 4 + Expect map.airline_y[0] == 5 + Expect map.airline_z[0] == 6 + end +end + diff --git a/.vim/t/util.vim b/.vim/t/util.vim new file mode 100644 index 0000000..913de9d --- /dev/null +++ b/.vim/t/util.vim @@ -0,0 +1,54 @@ +call airline#init#bootstrap() + +function! Util1() + let g:count += 1 +endfunction +function! Util2() + let g:count += 2 +endfunction +function! Util3(...) + let g:count = a:0 +endfunction + +describe 'util' + before + let g:count = 0 + end + + it 'has append wrapper function' + Expect airline#util#append('', 0) == '' + Expect airline#util#append('1', 0) == ' > 1' + end + + it 'has prepend wrapper function' + Expect airline#util#prepend('', 0) == '' + Expect airline#util#prepend('1', 0) == '1 < ' + end + + it 'has getwinvar function' + Expect airline#util#getwinvar(1, 'asdf', '123') == '123' + call setwinvar(1, 'vspec', 'is cool') + Expect airline#util#getwinvar(1, 'vspec', '') == 'is cool' + end + + it 'has exec funcrefs helper functions' + call airline#util#exec_funcrefs([function('Util1'), function('Util2')]) + Expect g:count == 3 + + call airline#util#exec_funcrefs([function('Util3')], 1, 2, 3, 4) + Expect g:count == 4 + end + + it 'should ignore minwidth if less than 0' + Expect airline#util#append('foo', -1) == ' > foo' + Expect airline#util#prepend('foo', -1) == 'foo < ' + Expect airline#util#wrap('foo', -1) == 'foo' + end + + it 'should return empty if winwidth() > minwidth' + Expect airline#util#append('foo', 99999) == '' + Expect airline#util#prepend('foo', 99999) == '' + Expect airline#util#wrap('foo', 99999) == '' + end +end +