--- /dev/null
+[submodule "vim/vim/bundle/ctrlp"]
+ path = vim/vim/bundle/ctrlp
+ url = https://github.com/kien/ctrlp.vim.git
+[submodule "vim/vim/bundle/fswitch"]
+ path = vim/vim/bundle/fswitch
+ url = https://github.com/derekwyatt/vim-fswitch.git
+[submodule "vim/vim/bundle/gundo"]
+ path = vim/vim/bundle/gundo
+ url = https://github.com/sjl/gundo.vim.git
+[submodule "vim/vim/bundle/nerdcommenter"]
+ path = vim/vim/bundle/nerdcommenter
+ url = https://github.com/scrooloose/nerdcommenter.git
+[submodule "vim/vim/bundle/surround"]
+ path = vim/vim/bundle/surround
+ url = https://github.com/tpope/vim-surround.git
+[submodule "vim/vim/bundle/repeat"]
+ path = vim/vim/bundle/repeat
+ url = https://github.com/tpope/vim-repeat.git
+[submodule "vim/vim/bundle/xptemplate"]
+ path = vim/vim/bundle/xptemplate
+ url = https://github.com/drmingdrmer/xptemplate
--- /dev/null
+# Ignore unnecessary Vim files.
+/vim/bundle/*/doc/tags
+/vim/cache/
+/vim/doc/tags
+/vim/spell/
--- /dev/null
+all:
+ @./setup.sh
+
+.PHONY: all
--- /dev/null
+# Vim crontab entry.
+
+# Copyright (C) 2012 Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Delete CtrlP cache files older than one day to force CtrlP to repopulate the
+# cache with current directory content.
+36 */8 * * * D="$HOME/.vim/cache/ctrlp"; test -d "$D" && find "$D" -name '\%*' -type f -mtime +1 -delete; true
--- /dev/null
+" GVim configuration file.
+
+" Copyright (C) 2011-2012 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Stop the cursor from blinking.
+set guicursor+=a:blinkon0
+
+" Don't display the menu.
+set guioptions-=m
+" Don't display the toolbar.
+set guioptions-=T
+" Don't display any scrollbars, they just waste space.
+set guioptions-=r
+set guioptions-=R
+set guioptions-=l
+set guioptions-=L
+
+" Increase window size to 110x25 if no tiling window manager is used.
+set columns=110
+set lines=25
+
+" Don't use the mouse.
+set mouse=
+" And don't use the mouse wheel.
+map <ScrollWheelUp> <Nop>
+map <S-ScrollWheelUp> <Nop>
+map <C-ScrollWheelUp> <Nop>
+map <ScrollWheelDown> <Nop>
+map <S-ScrollWheelDown> <Nop>
+map <C-ScrollWheelDown> <Nop>
+map <ScrollWheelLeft> <Nop>
+map <S-ScrollWheelLeft> <Nop>
+map <C-ScrollWheelLeft> <Nop>
+map <ScrollWheelRight> <Nop>
+map <S-ScrollWheelRight> <Nop>
+map <C-ScrollWheelRight> <Nop>
--- /dev/null
+#!/bin/sh
+
+# Setup script for Vim configuration files.
+
+# Copyright (C) 2011-2012 Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+. ../lib.sh
+
+
+# Create directories.
+mkdir -p vim/cache
+
+# Create documentation tags for pathogen plugins. `vim -e` always exists with
+# 1 for unknown reasons.
+vim -e -c ':call pathogen#helptags()' -c ':q' || true
+
+# Link setup.
+link vim ~/.vim
+link vimrc ~/.vimrc
+if installed gvim; then
+ link gvimrc ~/.gvimrc
+fi
+
+# Create/Update custom spell checking files.
+if test -f vim/spell/Makefile; then
+ make -C vim/spell
+fi
+
+if test -d ~/.crontab.d; then
+ link crontab ~/.crontab.d/crontab.dotfiles-vim
+fi
--- /dev/null
+#!/usr/bin/perl
+
+# Convert a terminal color scheme for 256 color terminals to a GUI color
+# scheme by adding the appropriate gui* options.
+
+# Copyright (C) 2012-2014 Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+use strict;
+use warnings;
+
+
+sub xterm2rgb {
+ my ($color) = @_;
+
+ # Taken from the urxvt-8.2-256color.patch in Debian's urxvt-unicode
+ # package 9.07-2.
+ my @colors = (
+ 'rgb:00/00/00',
+ 'rgb:00/00/5f',
+ 'rgb:00/00/87',
+ 'rgb:00/00/af',
+ 'rgb:00/00/d7',
+ 'rgb:00/00/ff',
+ 'rgb:00/5f/00',
+ 'rgb:00/5f/5f',
+ 'rgb:00/5f/87',
+ 'rgb:00/5f/af',
+ 'rgb:00/5f/d7',
+ 'rgb:00/5f/ff',
+ 'rgb:00/87/00',
+ 'rgb:00/87/5f',
+ 'rgb:00/87/87',
+ 'rgb:00/87/af',
+ 'rgb:00/87/d7',
+ 'rgb:00/87/ff',
+ 'rgb:00/af/00',
+ 'rgb:00/af/5f',
+ 'rgb:00/af/87',
+ 'rgb:00/af/af',
+ 'rgb:00/af/d7',
+ 'rgb:00/af/ff',
+ 'rgb:00/d7/00',
+ 'rgb:00/d7/5f',
+ 'rgb:00/d7/87',
+ 'rgb:00/d7/af',
+ 'rgb:00/d7/d7',
+ 'rgb:00/d7/ff',
+ 'rgb:00/ff/00',
+ 'rgb:00/ff/5f',
+ 'rgb:00/ff/87',
+ 'rgb:00/ff/af',
+ 'rgb:00/ff/d7',
+ 'rgb:00/ff/ff',
+ 'rgb:5f/00/00',
+ 'rgb:5f/00/5f',
+ 'rgb:5f/00/87',
+ 'rgb:5f/00/af',
+ 'rgb:5f/00/d7',
+ 'rgb:5f/00/ff',
+ 'rgb:5f/5f/00',
+ 'rgb:5f/5f/5f',
+ 'rgb:5f/5f/87',
+ 'rgb:5f/5f/af',
+ 'rgb:5f/5f/d7',
+ 'rgb:5f/5f/ff',
+ 'rgb:5f/87/00',
+ 'rgb:5f/87/5f',
+ 'rgb:5f/87/87',
+ 'rgb:5f/87/af',
+ 'rgb:5f/87/d7',
+ 'rgb:5f/87/ff',
+ 'rgb:5f/af/00',
+ 'rgb:5f/af/5f',
+ 'rgb:5f/af/87',
+ 'rgb:5f/af/af',
+ 'rgb:5f/af/d7',
+ 'rgb:5f/af/ff',
+ 'rgb:5f/d7/00',
+ 'rgb:5f/d7/5f',
+ 'rgb:5f/d7/87',
+ 'rgb:5f/d7/af',
+ 'rgb:5f/d7/d7',
+ 'rgb:5f/d7/ff',
+ 'rgb:5f/ff/00',
+ 'rgb:5f/ff/5f',
+ 'rgb:5f/ff/87',
+ 'rgb:5f/ff/af',
+ 'rgb:5f/ff/d7',
+ 'rgb:5f/ff/ff',
+ 'rgb:87/00/00',
+ 'rgb:87/00/5f',
+ 'rgb:87/00/87',
+ 'rgb:87/00/af',
+ 'rgb:87/00/d7',
+ 'rgb:87/00/ff',
+ 'rgb:87/5f/00',
+ 'rgb:87/5f/5f',
+ 'rgb:87/5f/87',
+ 'rgb:87/5f/af',
+ 'rgb:87/5f/d7',
+ 'rgb:87/5f/ff',
+ 'rgb:87/87/00',
+ 'rgb:87/87/5f',
+ 'rgb:87/87/87',
+ 'rgb:87/87/af',
+ 'rgb:87/87/d7',
+ 'rgb:87/87/ff',
+ 'rgb:87/af/00',
+ 'rgb:87/af/5f',
+ 'rgb:87/af/87',
+ 'rgb:87/af/af',
+ 'rgb:87/af/d7',
+ 'rgb:87/af/ff',
+ 'rgb:87/d7/00',
+ 'rgb:87/d7/5f',
+ 'rgb:87/d7/87',
+ 'rgb:87/d7/af',
+ 'rgb:87/d7/d7',
+ 'rgb:87/d7/ff',
+ 'rgb:87/ff/00',
+ 'rgb:87/ff/5f',
+ 'rgb:87/ff/87',
+ 'rgb:87/ff/af',
+ 'rgb:87/ff/d7',
+ 'rgb:87/ff/ff',
+ 'rgb:af/00/00',
+ 'rgb:af/00/5f',
+ 'rgb:af/00/87',
+ 'rgb:af/00/af',
+ 'rgb:af/00/d7',
+ 'rgb:af/00/ff',
+ 'rgb:af/5f/00',
+ 'rgb:af/5f/5f',
+ 'rgb:af/5f/87',
+ 'rgb:af/5f/af',
+ 'rgb:af/5f/d7',
+ 'rgb:af/5f/ff',
+ 'rgb:af/87/00',
+ 'rgb:af/87/5f',
+ 'rgb:af/87/87',
+ 'rgb:af/87/af',
+ 'rgb:af/87/d7',
+ 'rgb:af/87/ff',
+ 'rgb:af/af/00',
+ 'rgb:af/af/5f',
+ 'rgb:af/af/87',
+ 'rgb:af/af/af',
+ 'rgb:af/af/d7',
+ 'rgb:af/af/ff',
+ 'rgb:af/d7/00',
+ 'rgb:af/d7/5f',
+ 'rgb:af/d7/87',
+ 'rgb:af/d7/af',
+ 'rgb:af/d7/d7',
+ 'rgb:af/d7/ff',
+ 'rgb:af/ff/00',
+ 'rgb:af/ff/5f',
+ 'rgb:af/ff/87',
+ 'rgb:af/ff/af',
+ 'rgb:af/ff/d7',
+ 'rgb:af/ff/ff',
+ 'rgb:d7/00/00',
+ 'rgb:d7/00/5f',
+ 'rgb:d7/00/87',
+ 'rgb:d7/00/af',
+ 'rgb:d7/00/d7',
+ 'rgb:d7/00/ff',
+ 'rgb:d7/5f/00',
+ 'rgb:d7/5f/5f',
+ 'rgb:d7/5f/87',
+ 'rgb:d7/5f/af',
+ 'rgb:d7/5f/d7',
+ 'rgb:d7/5f/ff',
+ 'rgb:d7/87/00',
+ 'rgb:d7/87/5f',
+ 'rgb:d7/87/87',
+ 'rgb:d7/87/af',
+ 'rgb:d7/87/d7',
+ 'rgb:d7/87/ff',
+ 'rgb:d7/af/00',
+ 'rgb:d7/af/5f',
+ 'rgb:d7/af/87',
+ 'rgb:d7/af/af',
+ 'rgb:d7/af/d7',
+ 'rgb:d7/af/ff',
+ 'rgb:d7/d7/00',
+ 'rgb:d7/d7/5f',
+ 'rgb:d7/d7/87',
+ 'rgb:d7/d7/af',
+ 'rgb:d7/d7/d7',
+ 'rgb:d7/d7/ff',
+ 'rgb:d7/ff/00',
+ 'rgb:d7/ff/5f',
+ 'rgb:d7/ff/87',
+ 'rgb:d7/ff/af',
+ 'rgb:d7/ff/d7',
+ 'rgb:d7/ff/ff',
+ 'rgb:ff/00/00',
+ 'rgb:ff/00/5f',
+ 'rgb:ff/00/87',
+ 'rgb:ff/00/af',
+ 'rgb:ff/00/d7',
+ 'rgb:ff/00/ff',
+ 'rgb:ff/5f/00',
+ 'rgb:ff/5f/5f',
+ 'rgb:ff/5f/87',
+ 'rgb:ff/5f/af',
+ 'rgb:ff/5f/d7',
+ 'rgb:ff/5f/ff',
+ 'rgb:ff/87/00',
+ 'rgb:ff/87/5f',
+ 'rgb:ff/87/87',
+ 'rgb:ff/87/af',
+ 'rgb:ff/87/d7',
+ 'rgb:ff/87/ff',
+ 'rgb:ff/af/00',
+ 'rgb:ff/af/5f',
+ 'rgb:ff/af/87',
+ 'rgb:ff/af/af',
+ 'rgb:ff/af/d7',
+ 'rgb:ff/af/ff',
+ 'rgb:ff/d7/00',
+ 'rgb:ff/d7/5f',
+ 'rgb:ff/d7/87',
+ 'rgb:ff/d7/af',
+ 'rgb:ff/d7/d7',
+ 'rgb:ff/d7/ff',
+ 'rgb:ff/ff/00',
+ 'rgb:ff/ff/5f',
+ 'rgb:ff/ff/87',
+ 'rgb:ff/ff/af',
+ 'rgb:ff/ff/d7',
+ 'rgb:ff/ff/ff',
+ 'rgb:08/08/08',
+ 'rgb:12/12/12',
+ 'rgb:1c/1c/1c',
+ 'rgb:26/26/26',
+ 'rgb:30/30/30',
+ 'rgb:3a/3a/3a',
+ 'rgb:44/44/44',
+ 'rgb:4e/4e/4e',
+ 'rgb:58/58/58',
+ 'rgb:62/62/62',
+ 'rgb:6c/6c/6c',
+ 'rgb:76/76/76',
+ 'rgb:80/80/80',
+ 'rgb:8a/8a/8a',
+ 'rgb:94/94/94',
+ 'rgb:9e/9e/9e',
+ 'rgb:a8/a8/a8',
+ 'rgb:b2/b2/b2',
+ 'rgb:bc/bc/bc',
+ 'rgb:c6/c6/c6',
+ 'rgb:d0/d0/d0',
+ 'rgb:da/da/da',
+ 'rgb:e4/e4/e4',
+ 'rgb:ee/ee/ee',
+ );
+
+ return if $color < 16 or $color > 255; # undef
+
+ my $value = $colors[$color - 16];
+ $value =~ s{^rgb:}{};
+ $value =~ s{/}{}g;
+
+ return '#' . $value;
+}
+
+
+while (<STDIN>) {
+ # Only handle lines with highlight commands.
+ if (/^\s*\bhi(?:ghlight)?\b/) {
+ foreach my $setting (m/\bcterm(?:fg|bg)?=\S+/g) {
+ my ($name, $value) = split /=/, $setting;
+
+ my $gui_name = $name;
+ $gui_name =~ s/cterm/gui/;
+
+ my $new_value;
+ if ($name eq 'cterm') {
+ $new_value = $value;
+ } elsif ($value eq 'NONE') {
+ $new_value = 'NONE';
+ } else {
+ $new_value = xterm2rgb($value);
+ }
+
+ # Update existing value.
+ if (/\b\Q$gui_name\E=/) {
+ s/\Q$gui_name\E=\S+/$gui_name=$new_value/;
+ # Append at the end of the line.
+ } else {
+ s/\n/ $gui_name=$new_value\n/;
+ }
+ }
+ }
+
+ print;
+}
--- /dev/null
+" Vim filetype plugin file
+"
+" Language: Mail
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2009-2013 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Use only 65 characters per line as given in rfc1855.
+setlocal textwidth=65
+
+" Remove trailing whitespace after quotes.
+silent! %s/^>.\{-}\zs\s\+$//
+" Remove spaces between quotes (> > to >>).
+silent! %s/^>\+\zs >/>/g
+silent! %s/^>\+\zs >/>/g
+silent! %s/^>\+\zs >/>/g
+
+" Move directly after the headers.
+normal! gg
+normal! }
+" And if the mail contains a reply move the cursor after the quote.
+if search('^On .\+ wrote:$', 'n')
+ normal! }
+endif
+
+" Fold quotes. Thanks to Teemu Likonen <tlikonen@iki.fi>
+" (http://permalink.gmane.org/gmane.editors.vim.devel/20890,
+" <20080809190407.GA7584@mithlond.arda.local>) and danielsh_ in #mutt on
+" Freenode (2010-07-10 13:01 CEST) for letting me know.
+setlocal foldmethod=expr foldminlines=2
+setlocal foldexpr=strlen(substitute(substitute(getline(v:lnum),'\\s','','g'),'[^>].*','',''))
--- /dev/null
+" Vim filetype plugin file
+"
+" Language: PHP
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2008-2012 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Automatically fix my wrong usage of kdb tags in phpdoc comments which don't
+" exist and should be kbd tags. I make this typo all the time.
+abbreviate <buffer> kdb kbd
--- /dev/null
+" Vim syntax file
+"
+" Language: Apache files
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2008-2012 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Only check spelling in comments.
+syn match apacheComment "^\s*#.*$" contains=apacheFixme,@Spell
--- /dev/null
+" Vim syntax file
+"
+" Language: C
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2012 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Highlight statement control keywords differently when my color scheme is
+" used.
+if exists('g:colors_name') && g:colors_name == 'simon'
+ syntax keyword statementControl continue break return goto
+endif
--- /dev/null
+" Vim syntax file
+"
+" Language: Crontab files
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2008-2012 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Don't check spelling in variables.
+syntax match crontabVar "^\s*\k\w*\s*="me=e-1 contains=@NoSpell
--- /dev/null
+" Vim syntax file
+"
+" Language: Diff
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2012 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Color added/removed lines in the diff header the same color as added/removed
+" lines.
+syntax match diffAdded /^+++ .*$/
+syntax match diffRemoved /^--- .*$/
+" Dedicated group for hunks.
+syntax match diffHunk /^@.*$/ contains=diffSubname
+
+" Special colors for filename and hunk.
+highlight diffFile ctermfg=yellow cterm=bold guifg=yellow gui=bold
+highlight diffHunk ctermfg=magenta cterm=bold guifg=magenta gui=bold
+" Added lines in green, removed lines in red.
+highlight diffAdded ctermfg=green cterm=bold guifg=green gui=bold
+highlight diffRemoved ctermfg=red cterm=bold guifg=red gui=bold
--- /dev/null
+" Vim syntax file
+"
+" Language: Git commit messages
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2012 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Don't fold diffs in Git commit messages. I want to fold the list of
+" committed files, but take a closer look at the diffs.
+syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ contains=@gitcommitDiff
--- /dev/null
+" Vim syntax file
+"
+" Language: Perl
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2012-2014 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Use SpecialComment to highlight shebangs.
+highlight link perlSharpBang SpecialComment
+
+" I never use continue and break, and always confuse them with next and last.
+syntax match Error "\<\(continue\|break\)\>"
+
+" Highlight statement control keywords differently when my color scheme is
+" used.
+if exists('g:colors_name') && g:colors_name == 'simon'
+ highlight link perlStatementControl statementControl
+endif
+
+" Highlight for Inline::C in __DATA__/__END__ section
+unlet b:current_syntax
+syntax include @InlineC syntax/c.vim
+syntax region perlInlineC start='^__C__$' skip='.' end='.' contains=@InlineC
+syntax cluster perlDATA add=perlInlineC
--- /dev/null
+" Vim syntax file
+"
+" Language: Vim .vim files
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2008-2012 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Fix for the default .vim syntax to also recognize "syntax default" instead
+" of "syntax def".
+syn region vimHiLink contained oneline matchgroup=vimCommand start="\<\(def\(ault\)\?\s\+\)\=link\>\|\<def\>" end="$" contains=vimHiGroup,vimGroup,vimHLGroup,vimNotation
--- /dev/null
+" pathogen.vim - path option manipulation
+" Maintainer: Tim Pope <http://tpo.pe/>
+" Version: 2.2
+
+" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
+"
+" For management of individually installed plugins in ~/.vim/bundle (or
+" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your
+" .vimrc is the only other setup necessary.
+"
+" The API is documented inline below. For maximum ease of reading,
+" :set foldmethod=marker
+
+if exists("g:loaded_pathogen") || &cp
+ finish
+endif
+let g:loaded_pathogen = 1
+
+function! s:warn(msg)
+ echohl WarningMsg
+ echomsg a:msg
+ echohl NONE
+endfunction
+
+" Point of entry for basic default usage. Give a relative path to invoke
+" pathogen#incubate() (defaults to "bundle/{}"), or an absolute path to invoke
+" pathogen#surround(). For backwards compatibility purposes, a full path that
+" does not end in {} or * is given to pathogen#runtime_prepend_subdirectories()
+" instead.
+function! pathogen#infect(...) abort " {{{1
+ for path in a:0 ? reverse(copy(a:000)) : ['bundle/{}']
+ if path =~# '^[^\\/]\+$'
+ call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
+ call pathogen#incubate(path . '/{}')
+ elseif path =~# '^[^\\/]\+[\\/]\%({}\|\*\)$'
+ call pathogen#incubate(path)
+ elseif path =~# '[\\/]\%({}\|\*\)$'
+ call pathogen#surround(path)
+ else
+ call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
+ call pathogen#surround(path . '/{}')
+ endif
+ endfor
+ call pathogen#cycle_filetype()
+ return ''
+endfunction " }}}1
+
+" Split a path into a list.
+function! pathogen#split(path) abort " {{{1
+ if type(a:path) == type([]) | return a:path | endif
+ let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
+ return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
+endfunction " }}}1
+
+" Convert a list to a path.
+function! pathogen#join(...) abort " {{{1
+ if type(a:1) == type(1) && a:1
+ let i = 1
+ let space = ' '
+ else
+ let i = 0
+ let space = ''
+ endif
+ let path = ""
+ while i < a:0
+ if type(a:000[i]) == type([])
+ let list = a:000[i]
+ let j = 0
+ while j < len(list)
+ let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
+ let path .= ',' . escaped
+ let j += 1
+ endwhile
+ else
+ let path .= "," . a:000[i]
+ endif
+ let i += 1
+ endwhile
+ return substitute(path,'^,','','')
+endfunction " }}}1
+
+" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
+function! pathogen#legacyjoin(...) abort " {{{1
+ return call('pathogen#join',[1] + a:000)
+endfunction " }}}1
+
+" Remove duplicates from a list.
+function! pathogen#uniq(list) abort " {{{1
+ let i = 0
+ let seen = {}
+ while i < len(a:list)
+ if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
+ call remove(a:list,i)
+ elseif a:list[i] ==# ''
+ let i += 1
+ let empty = 1
+ else
+ let seen[a:list[i]] = 1
+ let i += 1
+ endif
+ endwhile
+ return a:list
+endfunction " }}}1
+
+" \ on Windows unless shellslash is set, / everywhere else.
+function! pathogen#separator() abort " {{{1
+ return !exists("+shellslash") || &shellslash ? '/' : '\'
+endfunction " }}}1
+
+" Convenience wrapper around glob() which returns a list.
+function! pathogen#glob(pattern) abort " {{{1
+ let files = split(glob(a:pattern),"\n")
+ return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
+endfunction "}}}1
+
+" Like pathogen#glob(), only limit the results to directories.
+function! pathogen#glob_directories(pattern) abort " {{{1
+ return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
+endfunction "}}}1
+
+" Turn filetype detection off and back on again if it was already enabled.
+function! pathogen#cycle_filetype() " {{{1
+ if exists('g:did_load_filetypes')
+ filetype off
+ filetype on
+ endif
+endfunction " }}}1
+
+" Check if a bundle is disabled. A bundle is considered disabled if it ends
+" in a tilde or its basename or full name is included in the list
+" g:pathogen_disabled.
+function! pathogen#is_disabled(path) " {{{1
+ if a:path =~# '\~$'
+ return 1
+ elseif !exists("g:pathogen_disabled")
+ return 0
+ endif
+ let sep = pathogen#separator()
+ let blacklist = g:pathogen_disabled
+ return index(blacklist, strpart(a:path, strridx(a:path, sep)+1)) != -1 && index(blacklist, a:path) != 1
+endfunction "}}}1
+
+" Prepend the given directory to the runtime path and append its corresponding
+" after directory. If the directory is already included, move it to the
+" outermost position. Wildcards are added as is. Ending a path in /{} causes
+" all subdirectories to be added (except those in g:pathogen_disabled).
+function! pathogen#surround(path) abort " {{{1
+ let sep = pathogen#separator()
+ let rtp = pathogen#split(&rtp)
+ if a:path =~# '[\\/]{}$'
+ let path = fnamemodify(a:path[0:-4], ':p:s?[\\/]\=$??')
+ let before = filter(pathogen#glob_directories(path.sep.'*'), '!pathogen#is_disabled(v:val)')
+ let after = filter(reverse(pathogen#glob_directories(path.sep."*".sep."after")), '!pathogen#is_disabled(v:val[0:-7])')
+ call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
+ else
+ let path = fnamemodify(a:path, ':p:s?[\\/]\=$??')
+ let before = [path]
+ let after = [path . sep . 'after']
+ call filter(rtp, 'index(before + after, v:val) == -1')
+ endif
+ let &rtp = pathogen#join(before, rtp, after)
+ return &rtp
+endfunction " }}}1
+
+" Prepend all subdirectories of path to the rtp, and append all 'after'
+" directories in those subdirectories. Deprecated.
+function! pathogen#runtime_prepend_subdirectories(path) " {{{1
+ call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#surround('.string(a:path.'/{}').')')
+ return pathogen#surround(a:path . pathogen#separator() . '{}')
+endfunction " }}}1
+
+" For each directory in the runtime path, add a second entry with the given
+" argument appended. If the argument ends in '/{}', add a separate entry for
+" each subdirectory. The default argument is 'bundle/{}', which means that
+" .vim/bundle/*, $VIM/vimfiles/bundle/*, $VIMRUNTIME/bundle/*,
+" $VIM/vim/files/bundle/*/after, and .vim/bundle/*/after will be added (on
+" UNIX).
+function! pathogen#incubate(...) abort " {{{1
+ let sep = pathogen#separator()
+ let name = a:0 ? a:1 : 'bundle/{}'
+ if "\n".s:done_bundles =~# "\\M\n".name."\n"
+ return ""
+ endif
+ let s:done_bundles .= name . "\n"
+ let list = []
+ for dir in pathogen#split(&rtp)
+ if dir =~# '\<after$'
+ if name =~# '{}$'
+ let list += filter(pathogen#glob_directories(substitute(dir,'after$',name[0:-3],'').'*'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
+ else
+ let list += [dir, substitute(dir, 'after$', '', '') . name . sep . 'after']
+ endif
+ else
+ if name =~# '{}$'
+ let list += [dir] + filter(pathogen#glob_directories(dir.sep.name[0:-3].'*'), '!pathogen#is_disabled(v:val)')
+ else
+ let list += [dir . sep . name, dir]
+ endif
+ endif
+ endfor
+ let &rtp = pathogen#join(pathogen#uniq(list))
+ return 1
+endfunction " }}}1
+
+" Deprecated alias for pathogen#incubate().
+function! pathogen#runtime_append_all_bundles(...) abort " {{{1
+ if a:0
+ call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#incubate('.string(a:1.'/{}').')')
+ else
+ call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#incubate()')
+ endif
+ return call('pathogen#incubate', map(copy(a:000),'v:val . "/{}"'))
+endfunction
+
+let s:done_bundles = ''
+" }}}1
+
+" Invoke :helptags on all non-$VIM doc directories in runtimepath.
+function! pathogen#helptags() abort " {{{1
+ let sep = pathogen#separator()
+ for glob in pathogen#split(&rtp)
+ for dir in split(glob(glob), "\n")
+ if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.sep.'doc') == 2 && !empty(filter(split(glob(dir.sep.'doc'.sep.'*'),"\n>"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags'))
+ silent! execute 'helptags' pathogen#fnameescape(dir.'/doc')
+ endif
+ endfor
+ endfor
+endfunction " }}}1
+
+command! -bar Helptags :call pathogen#helptags()
+
+" Execute the given command. This is basically a backdoor for --remote-expr.
+function! pathogen#execute(...) abort " {{{1
+ for command in a:000
+ execute command
+ endfor
+ return ''
+endfunction " }}}1
+
+" Like findfile(), but hardcoded to use the runtimepath.
+function! pathogen#runtime_findfile(file,count) abort "{{{1
+ let rtp = pathogen#join(1,pathogen#split(&rtp))
+ let file = findfile(a:file,rtp,a:count)
+ if file ==# ''
+ return ''
+ else
+ return fnamemodify(file,':p')
+ endif
+endfunction " }}}1
+
+" Backport of fnameescape().
+function! pathogen#fnameescape(string) abort " {{{1
+ if exists('*fnameescape')
+ return fnameescape(a:string)
+ elseif a:string ==# '-'
+ return '\-'
+ else
+ return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
+ endif
+endfunction " }}}1
+
+if exists(':Vedit')
+ finish
+endif
+
+let s:vopen_warning = 0
+
+function! s:find(count,cmd,file,lcd) " {{{1
+ let rtp = pathogen#join(1,pathogen#split(&runtimepath))
+ let file = pathogen#runtime_findfile(a:file,a:count)
+ if file ==# ''
+ return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
+ endif
+ if !s:vopen_warning
+ let s:vopen_warning = 1
+ let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE'
+ else
+ let warning = ''
+ endif
+ if a:lcd
+ let path = file[0:-strlen(a:file)-2]
+ execute 'lcd `=path`'
+ return a:cmd.' '.pathogen#fnameescape(a:file) . warning
+ else
+ return a:cmd.' '.pathogen#fnameescape(file) . warning
+ endif
+endfunction " }}}1
+
+function! s:Findcomplete(A,L,P) " {{{1
+ let sep = pathogen#separator()
+ let cheats = {
+ \'a': 'autoload',
+ \'d': 'doc',
+ \'f': 'ftplugin',
+ \'i': 'indent',
+ \'p': 'plugin',
+ \'s': 'syntax'}
+ if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
+ let request = cheats[a:A[0]].a:A[1:-1]
+ else
+ let request = a:A
+ endif
+ let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*'
+ let found = {}
+ for path in pathogen#split(&runtimepath)
+ let path = expand(path, ':p')
+ let matches = split(glob(path.sep.pattern),"\n")
+ call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
+ call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
+ for match in matches
+ let found[match] = 1
+ endfor
+ endfor
+ return sort(keys(found))
+endfunction " }}}1
+
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>,0)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>,0)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split',<q-args>,<bang>1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit',<q-args>,<bang>1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit',<q-args>,<bang>1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read',<q-args>,<bang>1)
+
+" vim:set et sw=2:
--- /dev/null
+Subproject commit b5d3fe66a58a13d2ff8b6391f4387608496a030f
--- /dev/null
+" Vim autoload file for browsing debian package.
+" copyright (C) 2007-2008, arno renevier <arenevier@fdn.fr>
+" Distributed under the GNU General Public License (version 2 or above)
+" Last Change: 2008 april 1
+"
+" Inspired by autoload/tar.vim by Charles E Campbell
+"
+" Latest version of that file can be found at
+" http://www.fdn.fr/~arenevier/vim/autoload/deb.vim
+" It should also be available at
+" http://www.vim.org/scripts/script.php?script_id=1970
+
+if &cp || exists("g:loaded_deb") || v:version < 700
+ finish
+endif
+let g:loaded_deb= "v1.4"
+
+fun! deb#read(debfile, member)
+
+ " checks if ar and tar are installed
+ if !s:hascmd("ar") || !s:hascmd("tar")
+ return
+ endif
+
+ let l:target = a:member
+
+ let l:archmember = s:dataFileName(a:debfile) " default archive member to extract
+ if l:archmember == ""
+ echohl WarningMsg | echo "***error*** (deb#read) no valid data file found in debian archive"
+ return
+ elseif l:archmember == "data.tar.gz"
+ let l:unpcmp = "tar zxfO "
+ elseif l:archmember == "data.tar.bz2"
+ let l:unpcmp = "tar jxfO "
+ elseif l:archmember == "data.tar.lzma"
+ if !s:hascmd("lzma")
+ return
+ endif
+ let l:unpcmp = "lzma -d | tar xfO "
+ elseif l:archmember == "data.tar"
+ let l:unpcmp = "tar xfO "
+ endif
+
+ if a:member =~ '^\* ' " information control file
+ let l:archmember = "control.tar.gz"
+ let l:target = substitute(l:target, "^\* ", "", "")
+ let l:unpcmp = "tar zxfO "
+ elseif a:member =~ ' -> ' " symbolic link
+ let l:target = split(a:member,' -> ')[0]
+ let l:linkname = split(a:member,' -> ')[1]
+
+ if l:linkname =~ "^\/" " direct symlink: path is already absolute
+ let l:target = ".".l:linkname
+
+ else
+ " transform relative path to absolute path
+
+ " first, get basename for target
+ let l:target = substitute(l:target, "\/[^/]*$", "", "")
+
+ " while it begins with ../
+ while l:linkname =~ "^\.\.\/"
+
+ " removes one level of ../ in linkname
+ let l:linkname = substitute(l:linkname, "^\.\.\/", "", "")
+
+ " go one directory up in target
+ let l:target = substitute(l:target, "\/[^/]*$", "", "")
+ endwhile
+
+ let l:target = l:target."/".l:linkname
+ endif
+ endif
+
+ " we may preprocess some files (such as man pages, or changelogs)
+ let l:preproccmd = ""
+
+ "
+ " unzip man pages
+ "
+ if l:target =~ "\.\/usr\/share\/man\/.*\.gz$"
+
+ " try to fail gracefully if a command is not available
+ if !s:hascmd("gzip")
+ return
+ elseif !s:hascmd("nroff")
+ let l:preproccmd = "| gzip -cd"
+ elseif !s:hascmd("col")
+ let l:preproccmd = "| gzip -cd | nroff -mandoc"
+ else
+ let l:preproccmd = "| gzip -cd | nroff -mandoc | col -b"
+ endif
+
+ "
+ " unzip other .gz files
+ "
+ elseif l:target =~ '.*\.gz$'
+ if !s:hascmd("gzip")
+ return
+ endif
+ let l:preproccmd = "| gzip -cd"
+ endif
+
+ " read content
+ exe "silent r! ar p " . s:QuoteFile(a:debfile) . " " . s:QuoteFile(l:archmember) . " | " . l:unpcmp . " - " . s:QuoteFile(l:target) . l:preproccmd
+ " error will be treated in calling function
+ if v:shell_error != 0
+ return
+ endif
+
+ exe "file deb:".l:target
+
+ 0d
+
+ setlocal nomodifiable nomodified readonly
+
+endfun
+
+fun! deb#browse(file)
+
+ " checks if necessary utils are installed
+ if !s:hascmd("dpkg") || !s:hascmd("ar") || !s:hascmd("tar")
+ return
+ endif
+
+ " checks if file is readable
+ if !filereadable(a:file)
+ return
+ endif
+ if a:file =~ "'"
+ echohl WarningMsg | echo "***error*** (deb#Browse) filename cannot contain quote character (" . a:file . ")"
+ return
+ endif
+
+ let keepmagic = &magic
+ set magic
+
+ " set filetype to "deb"
+ set ft=deb
+
+ setlocal modifiable noreadonly
+
+ " set header
+ exe "$put ='".'\"'." deb.vim version ".g:loaded_deb."'"
+ exe "$put ='".'\"'." Browsing debian package ".a:file."'"
+ $put=''
+
+ " package info
+ "exe "silent read! dpkg -I ".a:file
+ "$put=''
+
+ " display information control files
+ let l:infopos = line(".")
+ exe "silent read! ar p " . s:QuoteFile(a:file) . " control.tar.gz | tar zt"
+
+ $put=''
+
+ " display data files
+ let l:listpos = line(".")
+ exe "silent read! dpkg -c ". s:QuoteFile(a:file)
+
+ " format information control list
+ " removes '* ./' line
+ exe (l:infopos + 1). 'd'
+ " add a star before each line
+ exe "silent " . (l:infopos + 1). ',' . (l:listpos - 2) . 's/^/\* /'
+
+ " format data list
+ exe "silent " . l:listpos . ',$s/^.*\s\(\.\/\(\S\|\).*\)$/\1/'
+
+ if v:shell_error != 0
+ echohl WarningMsg | echo "***warning*** (deb#Browse) error when listing content of " . a:file
+ let &magic = keepmagic
+ return
+ endif
+
+ 0d
+
+ setlocal nomodifiable readonly
+ noremap <silent> <buffer> <cr> :call <SID>DebBrowseSelect()<cr>
+ let &magic = keepmagic
+
+endfun
+
+fun! s:DebBrowseSelect()
+ let l:fname= getline(".")
+
+ " sanity check
+ if (l:fname !~ '^\.\/') && (l:fname !~ '^\* \.\/')
+ return
+ endif
+ if l:fname =~ "'"
+ echohl WarningMsg | echo "***error*** (DebBrowseSelect) filename cannot contain quote character (" . l:fname . ")"
+ return
+ endif
+
+ " do nothing on directories
+ " TODO: find a way to detect symlinks to directories, to be able not to
+ " open them
+ if (l:fname =~ '\/$')
+ return
+ endif
+
+ " need to get it now since a new window will open
+ let l:curfile= expand("%")
+
+ " open new window
+ new
+ wincmd _
+
+ call deb#read(l:curfile, l:fname)
+
+ if v:shell_error != 0
+ echohl WarningMsg | echo "***warning*** (DebBrowseSelect) error when reading " . l:fname
+ return
+ endif
+
+ filetype detect
+
+ " zipped files, are unziped in deb#read, but filetype may not
+ " automatically work.
+ if l:fname =~ "\.\/usr\/share\/man\/.*\.gz$"
+ set filetype=man
+ elseif l:fname =~ "\.\/usr\/share\/doc\/.*\/changelog.Debian.gz$"
+ set filetype=debchangelog
+ endif
+
+endfun
+
+" return data file name for debian package. This can be either data.tar.gz,
+" data.tar.bz2 or data.tar.lzma
+fun s:dataFileName(deb)
+ for fn in ["data.tar.gz", "data.tar.bz2", "data.tar.lzma", "data.tar"]
+ " [0:-2] is to remove trailing null character from command output
+ if (system("ar t " . "'" . a:deb . "'" . " " . fn))[0:-2] == fn
+ return fn
+ endif
+ endfor
+ return "" " no debian data format in this archive
+endfun
+
+fun s:QuoteFile(file)
+ " we need to escape %, #, <, and >
+ " see :help cmdline-specialk
+ return "'" . substitute(a:file, '\([%#<>]\)', '\\\1', 'g') . "'"
+endfun
+
+" return 1 if cmd exists
+" display error message and return 0 otherwise
+fun s:hascmd(cmd)
+ if executable(a:cmd)
+ return 1
+ else
+ echohl Error | echo "***error*** " . a:cmd . " not available on your system"
+ return 0
+ else
+endfu
+
--- /dev/null
+" debPlugin.vim -- a Vim plugin for browsing debian packages
+" copyright (C) 2007, arno renevier <arenevier@fdn.fr>
+" Distributed under the GNU General Public License (version 2 or above)
+" Last Change: 2007 December 07
+"
+" This file only sets the autocommands. Functions are in autoload/deb.vim.
+"
+" Latest version of that file can be found at
+" http://www.fdn.fr/~arenevier/vim/plugin/debPlugin.vim
+" It should also be available at
+" http://www.vim.org/scripts/script.php?script_id=1970
+"
+if &cp || exists("g:loaded_debPlugin") || !has("unix") || v:version < 700
+ finish
+endif
+let g:loaded_debPlugin = 1
+
+autocmd BufReadCmd *.deb call deb#browse(expand("<amatch>"))
--- /dev/null
+" Vim syntax file for browsing debian package.
+" copyright (C) 2007, arno renevier <arenevier@fdn.fr>
+" Distributed under the GNU General Public License (version 2 or above)
+" Last Change: 2007 December 07
+"
+" Latest version of that file can be found at
+" http://www.fdn.fr/~arenevier/vim/syntax/deb.vim
+" It should also be available at
+" http://www.vim.org/scripts/script.php?script_id=1970
+
+if exists("b:current_syntax")
+ finish
+endif
+
+syn match debComment '^".*'
+syn match debInfoFilename '^\* \.\/.*'
+syn match debDataFilename '^\.\/.*[^/]$'
+syn match debDirname '^\..*\/$'
+syn match debSymlink '^\.\/.* -> .*$' contains=debSymlinkTarget,debSymlinkArrow,debSymlinkName
+syn match debSymlinkName '^\S*' contained
+syn match debSymlinkTarget '\S*$' contained
+syn match debSymlinkArrow '->' contained
+
+hi def link debComment Comment
+hi def link debInfoFilename Type
+hi def link debDataFilename PreProc
+hi def link debSymlinkName Identifier
+hi def link debSymlinkTarget PreProc
--- /dev/null
+Subproject commit e716da1ee6f80ee859b36083e6d6c3d7617b72e7
--- /dev/null
+Subproject commit 531f996bfec59d0addfe102b16538e54f6a2111b
--- /dev/null
+*matchit.txt* Extended "%" matching
+
+For instructions on installing this file, type
+ :help matchit-install
+inside Vim.
+
+For Vim version 6.3. Last change: 2007 Aug 29
+
+
+ VIM REFERENCE MANUAL by Benji Fisher
+
+*matchit* *matchit.vim*
+
+1. Extended matching with "%" |matchit-intro|
+2. Activation |matchit-activate|
+3. Configuration |matchit-configure|
+4. Supporting a New Language |matchit-newlang|
+5. Known Bugs and Limitations |matchit-bugs|
+
+The functionality mentioned here is a plugin, see |add-plugin|.
+This plugin is only available if 'compatible' is not set.
+You can avoid loading this plugin by setting the "loaded_matchit" variable
+in your |vimrc| file: >
+ :let loaded_matchit = 1
+
+{Vi does not have any of this}
+
+==============================================================================
+1. Extended matching with "%" *matchit-intro*
+
+ *matchit-%*
+% Cycle forward through matching groups, such as "if", "else", "endif",
+ as specified by |b:match_words|.
+
+ *g%* *v_g%* *o_g%*
+g% Cycle backwards through matching groups, as specified by
+ |b:match_words|. For example, go from "if" to "endif" to "else".
+
+ *[%* *v_[%* *o_[%*
+[% Go to [count] previous unmatched group, as specified by
+ |b:match_words|. Similar to |[{|.
+
+ *]%* *v_]%* *o_]%*
+]% Go to [count] next unmatched group, as specified by
+ |b:match_words|. Similar to |]}|.
+
+ *v_a%*
+a% In Visual mode, select the matching group, as specified by
+ |b:match_words|, containing the cursor. Similar to |v_a[|.
+ A [count] is ignored, and only the first character of the closing
+ pattern is selected.
+
+In Vim, as in plain vi, the percent key, |%|, jumps the cursor from a brace,
+bracket, or paren to its match. This can be configured with the 'matchpairs'
+option. The matchit plugin extends this in several ways:
+
+ You can match whole words, such as "if" and "endif", not just
+ single characters. You can also specify a |regular-expression|.
+ You can define groups with more than two words, such as "if",
+ "else", "endif". Banging on the "%" key will cycle from the "if" to
+ the first "else", the next "else", ..., the closing "endif", and back
+ to the opening "if". Nested structures are skipped. Using |g%| goes
+ in the reverse direction.
+ By default, words inside comments and strings are ignored, unless
+ the cursor is inside a comment or string when you type "%". If the
+ only thing you want to do is modify the behavior of "%" so that it
+ behaves this way, you do not have to define |b:match_words|, since the
+ script uses the 'matchpairs' option as well as this variable.
+
+See |matchit-details| for details on what the script does, and |b:match_words|
+for how to specify matching patterns.
+
+MODES: *matchit-modes* *matchit-v_%* *matchit-o_%*
+
+Mostly, % and related motions (|g%| and |[%| and |]%|) work just like built-in
+|motion| commands in |Operator-pending| and |Visual| modes. However, you
+cannot make these motions |linewise| or |characterwise|, since the |:omap|s
+that define them start with "v" in order to make the default behavior
+inclusive. (See |o_v|.) In other words, "dV%" will not work. The
+work-around is to go through Visual mode: "V%d" will work.
+
+LANGUAGES: *matchit-languages*
+
+Currently, the following languages are supported: Ada, ASP with VBS, Csh,
+DTD, Entity, Essbase, Fortran, HTML, JSP (same as HTML), LaTeX, Lua, Pascal,
+SGML, Shell, Tcsh, Vim, XML. Other languages may already have support via
+the default |filetype-plugin|s in the standard vim distribution.
+
+To support a new language, see |matchit-newlang| below.
+
+DETAILS: *matchit-details* *matchit-parse*
+
+Here is an outline of what matchit.vim does each time you hit the "%" key. If
+there are |backref|s in |b:match_words| then the first step is to produce a
+version in which these back references have been eliminated; if there are no
+|backref|s then this step is skipped. This step is called parsing. For
+example, "\(foo\|bar\):end\1" is parsed to yield
+"\(foo\|bar\):end\(foo\|bar\)". This can get tricky, especially if there are
+nested groups. If debugging is turned on, the parsed version is saved as
+|b:match_pat|.
+
+ *matchit-choose*
+Next, the script looks for a word on the current line that matches the pattern
+just constructed. It includes the patterns from the 'matchpairs' option.
+The goal is to do what you expect, which turns out to be a little complicated.
+The script follows these rules:
+
+ Insist on a match that ends on or after the cursor.
+ Prefer a match that includes the cursor position (that is, one that
+ starts on or before the cursor).
+ Prefer a match that starts as close to the cursor as possible.
+ If more than one pattern in |b:match_words| matches, choose the one
+ that is listed first.
+
+Examples:
+
+ Suppose you >
+ :let b:match_words = '<:>,<tag>:</tag>'
+< and hit "%" with the cursor on or before the "<" in "a <tag> is born".
+ The pattern '<' comes first, so it is preferred over '<tag>', which
+ also matches. If the cursor is on the "t", however, then '<tag>' is
+ preferred, because this matches a bit of text containing the cursor.
+ If the two groups of patterns were reversed then '<' would never be
+ preferred.
+
+ Suppose you >
+ :let b:match_words = 'if:end if'
+< (Note the space!) and hit "%" with the cursor at the end of "end if".
+ Then "if" matches, which is probably not what you want, but if the
+ cursor starts on the "end " then "end if" is chosen. (You can avoid
+ this problem by using a more complicated pattern.)
+
+If there is no match, the cursor does not move. (Before version 1.13 of the
+script, it would fall back on the usual behavior of |%|). If debugging is
+turned on, the matched bit of text is saved as |b:match_match| and the cursor
+column of the start of the match is saved as |b:match_col|.
+
+Next, the script looks through |b:match_words| (original and parsed versions)
+for the group and pattern that match. If debugging is turned on, the group is
+saved as |b:match_ini| (the first pattern) and |b:match_tail| (the rest). If
+there are |backref|s then, in addition, the matching pattern is saved as
+|b:match_word| and a table of translations is saved as |b:match_table|. If
+there are |backref|s, these are determined from the matching pattern and
+|b:match_match| and substituted into each pattern in the matching group.
+
+The script decides whether to search forwards or backwards and chooses
+arguments for the |searchpair()| function. Then, the cursor is moved to the
+start of the match, and |searchpair()| is called. By default, matching
+structures inside strings and comments are ignored. This can be changed by
+setting |b:match_skip|.
+
+==============================================================================
+2. Activation *matchit-activate*
+
+You can use this script as a plugin, by copying it to your plugin directory.
+See |add-global-plugin| for instructions. You can also add a line to your
+|vimrc| file, such as >
+ :source $VIMRUNTIME/macros/matchit.vim
+or >
+ :runtime macros/matchit.vim
+Either way, the script should start working the next time you start up Vim.
+
+(Earlier versions of the script did nothing unless a |buffer-variable| named
+|b:match_words| was defined. Even earlier versions contained autocommands
+that set this variable for various file types. Now, |b:match_words| is
+defined in many of the default |filetype-plugin|s instead.)
+
+For a new language, you can add autocommands to the script or to your vimrc
+file, but the recommended method is to add a line such as >
+ let b:match_words = '\<foo\>:\<bar\>'
+to the |filetype-plugin| for your language. See |b:match_words| below for how
+this variable is interpreted.
+
+TROUBLESHOOTING *matchit-troubleshoot*
+
+The script should work in most installations of Vim. It may not work if Vim
+was compiled with a minimal feature set, for example if the |+syntax| option
+was not enabled. If your Vim has support for syntax compiled in, but you do
+not have |syntax| highlighting turned on, matchit.vim should work, but it may
+fail to skip matching groups in comments and strings. If the |filetype|
+mechanism is turned off, the |b:match_words| variable will probably not be
+defined automatically.
+
+==============================================================================
+3. Configuration *matchit-configure*
+
+There are several variables that govern the behavior of matchit.vim. Note
+that these are variables local to the buffer, not options, so use |:let| to
+define them, not |:set|. Some of these variables have values that matter; for
+others, it only matters whether the variable has been defined. All of these
+can be defined in the |filetype-plugin| or autocommand that defines
+|b:match_words| or "on the fly."
+
+The main variable is |b:match_words|. It is described in the section below on
+supporting a new language.
+
+ *MatchError* *matchit-hl* *matchit-highlight*
+MatchError is the highlight group for error messages from the script. By
+default, it is linked to WarningMsg. If you do not want to be bothered by
+error messages, you can define this to be something invisible. For example,
+if you use the GUI version of Vim and your command line is normally white, you
+can do >
+ :hi MatchError guifg=white guibg=white
+<
+ *b:match_ignorecase*
+If you >
+ :let b:match_ignorecase = 1
+then matchit.vim acts as if 'ignorecase' is set: for example, "end" and "END"
+are equivalent. If you >
+ :let b:match_ignorecase = 0
+then matchit.vim treats "end" and "END" differently. (There will be no
+b:match_infercase option unless someone requests it.)
+
+ *b:match_debug*
+Define b:match_debug if you want debugging information to be saved. See
+|matchit-debug|, below.
+
+ *b:match_skip*
+If b:match_skip is defined, it is passed as the skip argument to
+|searchpair()|. This controls when matching structures are skipped, or
+ignored. By default, they are ignored inside comments and strings, as
+determined by the |syntax| mechanism. (If syntax highlighting is turned off,
+nothing is skipped.) You can set b:match_skip to a string, which evaluates to
+a non-zero, numerical value if the match is to be skipped or zero if the match
+should not be skipped. In addition, the following special values are
+supported by matchit.vim:
+ s:foo becomes (current syntax item) =~ foo
+ S:foo becomes (current syntax item) !~ foo
+ r:foo becomes (line before cursor) =~ foo
+ R:foo becomes (line before cursor) !~ foo
+(The "s" is meant to suggest "syntax", and the "r" is meant to suggest
+"regular expression".)
+
+Examples:
+
+ You can get the default behavior with >
+ :let b:match_skip = 's:comment\|string'
+<
+ If you want to skip matching structures unless they are at the start
+ of the line (ignoring whitespace) then you can >
+ :let b:match_skip = 'R:^\s*'
+< Do not do this if strings or comments can span several lines, since
+ the normal syntax checking will not be done if you set b:match_skip.
+
+ In LaTeX, since "%" is used as the comment character, you can >
+ :let b:match_skip = 'r:%'
+< Unfortunately, this will skip anything after "\%", an escaped "%". To
+ allow for this, and also "\\%" (an excaped backslash followed by the
+ comment character) you can >
+ :let b:match_skip = 'r:\(^\|[^\\]\)\(\\\\\)*%'
+<
+ See the $VIMRUNTIME/ftplugin/vim.vim for an example that uses both
+ syntax and a regular expression.
+
+==============================================================================
+4. Supporting a New Language *matchit-newlang*
+ *b:match_words*
+In order for matchit.vim to support a new language, you must define a suitable
+pattern for |b:match_words|. You may also want to set some of the
+|matchit-configure| variables, as described above. If your language has a
+complicated syntax, or many keywords, you will need to know something about
+Vim's |regular-expression|s.
+
+The format for |b:match_words| is similar to that of the 'matchpairs' option:
+it is a comma (,)-separated list of groups; each group is a colon(:)-separated
+list of patterns (regular expressions). Commas and backslashes that are part
+of a pattern should be escaped with backslashes ('\:' and '\,'). It is OK to
+have only one group; the effect is undefined if a group has only one pattern.
+A simple example is >
+ :let b:match_words = '\<if\>:\<endif\>,'
+ \ . '\<while\>:\<continue\>:\<break\>:\<endwhile\>'
+(In Vim regular expressions, |\<| and |\>| denote word boundaries. Thus "if"
+matches the end of "endif" but "\<if\>" does not.) Then banging on the "%"
+key will bounce the cursor between "if" and the matching "endif"; and from
+"while" to any matching "continue" or "break", then to the matching "endwhile"
+and back to the "while". It is almost always easier to use |literal-string|s
+(single quotes) as above: '\<if\>' rather than "\\<if\\>" and so on.
+
+Exception: If the ":" character does not appear in b:match_words, then it is
+treated as an expression to be evaluated. For example, >
+ :let b:match_words = 'GetMatchWords()'
+allows you to define a function. This can return a different string depending
+on the current syntax, for example.
+
+Once you have defined the appropriate value of |b:match_words|, you will
+probably want to have this set automatically each time you edit the
+appropriate file type. The recommended way to do this is by adding the
+definition to a |filetype-plugin| file.
+
+Tips: Be careful that your initial pattern does not match your final pattern.
+See the example above for the use of word-boundary expressions. It is usually
+better to use ".\{-}" (as many as necessary) instead of ".*" (as many as
+possible). See |\{-|. For example, in the string "<tag>label</tag>", "<.*>"
+matches the whole string whereas "<.\{-}>" and "<[^>]*>" match "<tag>" and
+"</tag>".
+
+ *matchit-spaces* *matchit-s:notend*
+If "if" is to be paired with "end if" (Note the space!) then word boundaries
+are not enough. Instead, define a regular expression s:notend that will match
+anything but "end" and use it as follows: >
+ :let s:notend = '\%(\<end\s\+\)\@<!'
+ :let b:match_words = s:notend . '\<if\>:\<end\s\+if\>'
+< *matchit-s:sol*
+This is a simplified version of what is done for Ada. The s:notend is a
+|script-variable|. Similarly, you may want to define a start-of-line regular
+expression >
+ :let s:sol = '\%(^\|;\)\s*'
+if keywords are only recognized after the start of a line or after a
+semicolon (;), with optional white space.
+
+ *matchit-backref* *matchit-\1*
+In any group, the expressions |\1|, |\2|, ..., |\9| refer to parts of the
+INITIAL pattern enclosed in |\(|escaped parentheses|\)|. These are referred
+to as back references, or backrefs. For example, >
+ :let b:match_words = '\<b\(o\+\)\>:\(h\)\1\>'
+means that "bo" pairs with "ho" and "boo" pairs with "hoo" and so on. Note
+that "\1" does not refer to the "\(h\)" in this example. If you have
+"\(nested \(parentheses\)\) then "\d" refers to the d-th "\(" and everything
+up to and including the matching "\)": in "\(nested\(parentheses\)\)", "\1"
+refers to everything and "\2" refers to "\(parentheses\)". If you use a
+variable such as |s:notend| or |s:sol| in the previous paragraph then remember
+to count any "\(" patterns in this variable. You do not have to count groups
+defined by |\%(\)|.
+
+It should be possible to resolve back references from any pattern in the
+group. For example, >
+ :let b:match_words = '\(foo\)\(bar\):more\1:and\2:end\1\2'
+would not work because "\2" cannot be determined from "morefoo" and "\1"
+cannot be determined from "andbar". On the other hand, >
+ :let b:match_words = '\(\(foo\)\(bar\)\):\3\2:end\1'
+should work (and have the same effect as "foobar:barfoo:endfoobar"), although
+this has not been thoroughly tested.
+
+You can use |zero-width| patterns such as |\@<=| and |\zs|. (The latter has
+not been thouroughly tested in matchit.vim.) For example, if the keyword "if"
+must occur at the start of the line, with optional white space, you might use
+the pattern "\(^\s*\)\@<=if" so that the cursor will end on the "i" instead of
+at the start of the line. For another example, if HTML had only one tag then
+one could >
+ :let b:match_words = '<:>,<\@<=tag>:<\@<=/tag>'
+so that "%" can bounce between matching "<" and ">" pairs or (starting on
+"tag" or "/tag") between matching tags. Without the |\@<=|, the script would
+bounce from "tag" to the "<" in "</tag>", and another "%" would not take you
+back to where you started.
+
+DEBUGGING *matchit-debug* *:MatchDebug*
+
+If you are having trouble figuring out the appropriate definition of
+|b:match_words| then you can take advantage of the same information I use when
+debugging the script. This is especially true if you are not sure whether
+your patterns or my script are at fault! To make this more convenient, I have
+made the command :MatchDebug, which defines the variable |b:match_debug| and
+creates a Matchit menu. This menu makes it convenient to check the values of
+the variables described below. You will probably also want to read
+|matchit-details| above.
+
+Defining the variable |b:match_debug| causes the script to set the following
+variables, each time you hit the "%" key. Several of these are only defined
+if |b:match_words| includes |backref|s.
+
+ *b:match_pat*
+The b:match_pat variable is set to |b:match_words| with |backref|s parsed.
+ *b:match_match*
+The b:match_match variable is set to the bit of text that is recognized as a
+match.
+ *b:match_col*
+The b:match_col variable is set to the cursor column of the start of the
+matching text.
+ *b:match_wholeBR*
+The b:match_wholeBR variable is set to the comma-separated group of patterns
+that matches, with |backref|s unparsed.
+ *b:match_iniBR*
+The b:match_iniBR variable is set to the first pattern in |b:match_wholeBR|.
+ *b:match_ini*
+The b:match_ini variable is set to the first pattern in |b:match_wholeBR|,
+with |backref|s resolved from |b:match_match|.
+ *b:match_tail*
+The b:match_tail variable is set to the remaining patterns in
+|b:match_wholeBR|, with |backref|s resolved from |b:match_match|.
+ *b:match_word*
+The b:match_word variable is set to the pattern from |b:match_wholeBR| that
+matches |b:match_match|.
+ *b:match_table*
+The back reference '\'.d refers to the same thing as '\'.b:match_table[d] in
+|b:match_word|.
+
+==============================================================================
+5. Known Bugs and Limitations *matchit-bugs*
+
+Just because I know about a bug does not mean that it is on my todo list. I
+try to respond to reports of bugs that cause real problems. If it does not
+cause serious problems, or if there is a work-around, a bug may sit there for
+a while. Moral: if a bug (known or not) bothers you, let me know.
+
+The various |:vmap|s defined in the script (%, |g%|, |[%|, |]%|, |a%|) may
+have undesired effects in Select mode |Select-mode-mapping|. At least, if you
+want to replace the selection with any character in "ag%[]" there will be a
+pause of |'updatetime'| first.
+
+It would be nice if "\0" were recognized as the entire pattern. That is, it
+would be nice if "foo:\end\0" had the same effect as "\(foo\):\end\1". I may
+try to implement this in a future version. (This is not so easy to arrange as
+you might think!)
+
+==============================================================================
+vim:tw=78:fo=tcq2:
--- /dev/null
+" matchit.vim: (global plugin) Extended "%" matching
+" Last Change: Fri Jan 25 10:00 AM 2008 EST
+" Maintainer: Benji Fisher PhD <benji@member.AMS.org>
+" Version: 1.13.2, for Vim 6.3+
+" URL: http://www.vim.org/script.php?script_id=39
+
+" Documentation:
+" The documentation is in a separate file, matchit.txt .
+
+" Credits:
+" Vim editor by Bram Moolenaar (Thanks, Bram!)
+" Original script and design by Raul Segura Acevedo
+" Support for comments by Douglas Potts
+" Support for back references and other improvements by Benji Fisher
+" Support for many languages by Johannes Zellner
+" Suggestions for improvement, bug reports, and support for additional
+" languages by Jordi-Albert Batalla, Neil Bird, Servatius Brandt, Mark
+" Collett, Stephen Wall, Dany St-Amant, Yuheng Xie, and Johannes Zellner.
+
+" Debugging:
+" If you'd like to try the built-in debugging commands...
+" :MatchDebug to activate debugging for the current buffer
+" This saves the values of several key script variables as buffer-local
+" variables. See the MatchDebug() function, below, for details.
+
+" TODO: I should think about multi-line patterns for b:match_words.
+" This would require an option: how many lines to scan (default 1).
+" This would be useful for Python, maybe also for *ML.
+" TODO: Maybe I should add a menu so that people will actually use some of
+" the features that I have implemented.
+" TODO: Eliminate the MultiMatch function. Add yet another argument to
+" Match_wrapper() instead.
+" TODO: Allow :let b:match_words = '\(\(foo\)\(bar\)\):\3\2:end\1'
+" TODO: Make backrefs safer by using '\V' (very no-magic).
+" TODO: Add a level of indirection, so that custom % scripts can use my
+" work but extend it.
+
+" allow user to prevent loading
+" and prevent duplicate loading
+if exists("loaded_matchit") || &cp
+ finish
+endif
+let loaded_matchit = 1
+let s:last_mps = ""
+let s:last_words = ":"
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+nnoremap <silent> % :<C-U>call <SID>Match_wrapper('',1,'n') <CR>
+nnoremap <silent> g% :<C-U>call <SID>Match_wrapper('',0,'n') <CR>
+vnoremap <silent> % :<C-U>call <SID>Match_wrapper('',1,'v') <CR>m'gv``
+vnoremap <silent> g% :<C-U>call <SID>Match_wrapper('',0,'v') <CR>m'gv``
+onoremap <silent> % v:<C-U>call <SID>Match_wrapper('',1,'o') <CR>
+onoremap <silent> g% v:<C-U>call <SID>Match_wrapper('',0,'o') <CR>
+
+" Analogues of [{ and ]} using matching patterns:
+nnoremap <silent> [% :<C-U>call <SID>MultiMatch("bW", "n") <CR>
+nnoremap <silent> ]% :<C-U>call <SID>MultiMatch("W", "n") <CR>
+vmap [% <Esc>[%m'gv``
+vmap ]% <Esc>]%m'gv``
+" vnoremap <silent> [% :<C-U>call <SID>MultiMatch("bW", "v") <CR>m'gv``
+" vnoremap <silent> ]% :<C-U>call <SID>MultiMatch("W", "v") <CR>m'gv``
+onoremap <silent> [% v:<C-U>call <SID>MultiMatch("bW", "o") <CR>
+onoremap <silent> ]% v:<C-U>call <SID>MultiMatch("W", "o") <CR>
+
+" text object:
+vmap a% <Esc>[%v]%
+
+" Auto-complete mappings: (not yet "ready for prime time")
+" TODO Read :help write-plugin for the "right" way to let the user
+" specify a key binding.
+" let g:match_auto = '<C-]>'
+" let g:match_autoCR = '<C-CR>'
+" if exists("g:match_auto")
+" execute "inoremap " . g:match_auto . ' x<Esc>"=<SID>Autocomplete()<CR>Pls'
+" endif
+" if exists("g:match_autoCR")
+" execute "inoremap " . g:match_autoCR . ' <CR><C-R>=<SID>Autocomplete()<CR>'
+" endif
+" if exists("g:match_gthhoh")
+" execute "inoremap " . g:match_gthhoh . ' <C-O>:call <SID>Gthhoh()<CR>'
+" endif " gthhoh = "Get the heck out of here!"
+
+let s:notslash = '\\\@<!\%(\\\\\)*'
+
+function! s:Match_wrapper(word, forward, mode) range
+ " In s:CleanUp(), :execute "set" restore_options .
+ let restore_options = (&ic ? " " : " no") . "ignorecase"
+ if exists("b:match_ignorecase")
+ let &ignorecase = b:match_ignorecase
+ endif
+ let restore_options = " ve=" . &ve . restore_options
+ set ve=
+ " If this function was called from Visual mode, make sure that the cursor
+ " is at the correct end of the Visual range:
+ if a:mode == "v"
+ execute "normal! gv\<Esc>"
+ endif
+ " In s:CleanUp(), we may need to check whether the cursor moved forward.
+ let startline = line(".")
+ let startcol = col(".")
+ " Use default behavior if called with a count.
+ if v:count
+ exe "normal! " . v:count . "%"
+ return s:CleanUp(restore_options, a:mode, startline, startcol)
+ end
+
+ " First step: if not already done, set the script variables
+ " s:do_BR flag for whether there are backrefs
+ " s:pat parsed version of b:match_words
+ " s:all regexp based on s:pat and the default groups
+ "
+ if !exists("b:match_words") || b:match_words == ""
+ let match_words = ""
+ " Allow b:match_words = "GetVimMatchWords()" .
+ elseif b:match_words =~ ":"
+ let match_words = b:match_words
+ else
+ execute "let match_words =" b:match_words
+ endif
+" Thanks to Preben "Peppe" Guldberg and Bram Moolenaar for this suggestion!
+ if (match_words != s:last_words) || (&mps != s:last_mps) ||
+ \ exists("b:match_debug")
+ let s:last_words = match_words
+ let s:last_mps = &mps
+ " The next several lines were here before
+ " BF started messing with this script.
+ " quote the special chars in 'matchpairs', replace [,:] with \| and then
+ " append the builtin pairs (/*, */, #if, #ifdef, #else, #elif, #endif)
+ " let default = substitute(escape(&mps, '[$^.*~\\/?]'), '[,:]\+',
+ " \ '\\|', 'g').'\|\/\*\|\*\/\|#if\>\|#ifdef\>\|#else\>\|#elif\>\|#endif\>'
+ let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") .
+ \ '\/\*:\*\/,#if\%(def\)\=:#else\>:#elif\>:#endif\>'
+ " s:all = pattern with all the keywords
+ let match_words = match_words . (strlen(match_words) ? "," : "") . default
+ if match_words !~ s:notslash . '\\\d'
+ let s:do_BR = 0
+ let s:pat = match_words
+ else
+ let s:do_BR = 1
+ let s:pat = s:ParseWords(match_words)
+ endif
+ let s:all = substitute(s:pat, s:notslash . '\zs[,:]\+', '\\|', 'g')
+ let s:all = '\%(' . s:all . '\)'
+ " let s:all = '\%(' . substitute(s:all, '\\\ze[,:]', '', 'g') . '\)'
+ if exists("b:match_debug")
+ let b:match_pat = s:pat
+ endif
+ endif
+
+ " Second step: set the following local variables:
+ " matchline = line on which the cursor started
+ " curcol = number of characters before match
+ " prefix = regexp for start of line to start of match
+ " suffix = regexp for end of match to end of line
+ " Require match to end on or after the cursor and prefer it to
+ " start on or before the cursor.
+ let matchline = getline(startline)
+ if a:word != ''
+ " word given
+ if a:word !~ s:all
+ echohl WarningMsg|echo 'Missing rule for word:"'.a:word.'"'|echohl NONE
+ return s:CleanUp(restore_options, a:mode, startline, startcol)
+ endif
+ let matchline = a:word
+ let curcol = 0
+ let prefix = '^\%('
+ let suffix = '\)$'
+ " Now the case when "word" is not given
+ else " Find the match that ends on or after the cursor and set curcol.
+ let regexp = s:Wholematch(matchline, s:all, startcol-1)
+ let curcol = match(matchline, regexp)
+ " If there is no match, give up.
+ if curcol == -1
+ return s:CleanUp(restore_options, a:mode, startline, startcol)
+ endif
+ let endcol = matchend(matchline, regexp)
+ let suf = strlen(matchline) - endcol
+ let prefix = (curcol ? '^.*\%' . (curcol + 1) . 'c\%(' : '^\%(')
+ let suffix = (suf ? '\)\%' . (endcol + 1) . 'c.*$' : '\)$')
+ endif
+ if exists("b:match_debug")
+ let b:match_match = matchstr(matchline, regexp)
+ let b:match_col = curcol+1
+ endif
+
+ " Third step: Find the group and single word that match, and the original
+ " (backref) versions of these. Then, resolve the backrefs.
+ " Set the following local variable:
+ " group = colon-separated list of patterns, one of which matches
+ " = ini:mid:fin or ini:fin
+ "
+ " Reconstruct the version with unresolved backrefs.
+ let patBR = substitute(match_words.',',
+ \ s:notslash.'\zs[,:]*,[,:]*', ',', 'g')
+ let patBR = substitute(patBR, s:notslash.'\zs:\{2,}', ':', 'g')
+ " Now, set group and groupBR to the matching group: 'if:endif' or
+ " 'while:endwhile' or whatever. A bit of a kluge: s:Choose() returns
+ " group . "," . groupBR, and we pick it apart.
+ let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR)
+ let i = matchend(group, s:notslash . ",")
+ let groupBR = strpart(group, i)
+ let group = strpart(group, 0, i-1)
+ " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix
+ if s:do_BR " Do the hard part: resolve those backrefs!
+ let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline)
+ endif
+ if exists("b:match_debug")
+ let b:match_wholeBR = groupBR
+ let i = matchend(groupBR, s:notslash . ":")
+ let b:match_iniBR = strpart(groupBR, 0, i-1)
+ endif
+
+ " Fourth step: Set the arguments for searchpair().
+ let i = matchend(group, s:notslash . ":")
+ let j = matchend(group, '.*' . s:notslash . ":")
+ let ini = strpart(group, 0, i-1)
+ let mid = substitute(strpart(group, i,j-i-1), s:notslash.'\zs:', '\\|', 'g')
+ let fin = strpart(group, j)
+ "Un-escape the remaining , and : characters.
+ let ini = substitute(ini, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
+ let mid = substitute(mid, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
+ let fin = substitute(fin, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
+ " searchpair() requires that these patterns avoid \(\) groups.
+ let ini = substitute(ini, s:notslash . '\zs\\(', '\\%(', 'g')
+ let mid = substitute(mid, s:notslash . '\zs\\(', '\\%(', 'g')
+ let fin = substitute(fin, s:notslash . '\zs\\(', '\\%(', 'g')
+ " Set mid. This is optimized for readability, not micro-efficiency!
+ if a:forward && matchline =~ prefix . fin . suffix
+ \ || !a:forward && matchline =~ prefix . ini . suffix
+ let mid = ""
+ endif
+ " Set flag. This is optimized for readability, not micro-efficiency!
+ if a:forward && matchline =~ prefix . fin . suffix
+ \ || !a:forward && matchline !~ prefix . ini . suffix
+ let flag = "bW"
+ else
+ let flag = "W"
+ endif
+ " Set skip.
+ if exists("b:match_skip")
+ let skip = b:match_skip
+ elseif exists("b:match_comment") " backwards compatibility and testing!
+ let skip = "r:" . b:match_comment
+ else
+ let skip = 's:comment\|string'
+ endif
+ let skip = s:ParseSkip(skip)
+ if exists("b:match_debug")
+ let b:match_ini = ini
+ let b:match_tail = (strlen(mid) ? mid.'\|' : '') . fin
+ endif
+
+ " Fifth step: actually start moving the cursor and call searchpair().
+ " Later, :execute restore_cursor to get to the original screen.
+ let restore_cursor = virtcol(".") . "|"
+ normal! g0
+ let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor
+ normal! H
+ let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
+ execute restore_cursor
+ call cursor(0, curcol + 1)
+ " normal! 0
+ " if curcol
+ " execute "normal!" . curcol . "l"
+ " endif
+ if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
+ let skip = "0"
+ else
+ execute "if " . skip . "| let skip = '0' | endif"
+ endif
+ let sp_return = searchpair(ini, mid, fin, flag, skip)
+ let final_position = "call cursor(" . line(".") . "," . col(".") . ")"
+ " Restore cursor position and original screen.
+ execute restore_cursor
+ normal! m'
+ if sp_return > 0
+ execute final_position
+ endif
+ return s:CleanUp(restore_options, a:mode, startline, startcol, mid.'\|'.fin)
+endfun
+
+" Restore options and do some special handling for Operator-pending mode.
+" The optional argument is the tail of the matching group.
+fun! s:CleanUp(options, mode, startline, startcol, ...)
+ execute "set" a:options
+ " Open folds, if appropriate.
+ if a:mode != "o"
+ if &foldopen =~ "percent"
+ normal! zv
+ endif
+ " In Operator-pending mode, we want to include the whole match
+ " (for example, d%).
+ " This is only a problem if we end up moving in the forward direction.
+ elseif (a:startline < line(".")) ||
+ \ (a:startline == line(".") && a:startcol < col("."))
+ if a:0
+ " Check whether the match is a single character. If not, move to the
+ " end of the match.
+ let matchline = getline(".")
+ let currcol = col(".")
+ let regexp = s:Wholematch(matchline, a:1, currcol-1)
+ let endcol = matchend(matchline, regexp)
+ if endcol > currcol " This is NOT off by one!
+ execute "normal!" . (endcol - currcol) . "l"
+ endif
+ endif " a:0
+ endif " a:mode != "o" && etc.
+ return 0
+endfun
+
+" Example (simplified HTML patterns): if
+" a:groupBR = '<\(\k\+\)>:</\1>'
+" a:prefix = '^.\{3}\('
+" a:group = '<\(\k\+\)>:</\(\k\+\)>'
+" a:suffix = '\).\{2}$'
+" a:matchline = "123<tag>12" or "123</tag>12"
+" then extract "tag" from a:matchline and return "<tag>:</tag>" .
+fun! s:InsertRefs(groupBR, prefix, group, suffix, matchline)
+ if a:matchline !~ a:prefix .
+ \ substitute(a:group, s:notslash . '\zs:', '\\|', 'g') . a:suffix
+ return a:group
+ endif
+ let i = matchend(a:groupBR, s:notslash . ':')
+ let ini = strpart(a:groupBR, 0, i-1)
+ let tailBR = strpart(a:groupBR, i)
+ let word = s:Choose(a:group, a:matchline, ":", "", a:prefix, a:suffix,
+ \ a:groupBR)
+ let i = matchend(word, s:notslash . ":")
+ let wordBR = strpart(word, i)
+ let word = strpart(word, 0, i-1)
+ " Now, a:matchline =~ a:prefix . word . a:suffix
+ if wordBR != ini
+ let table = s:Resolve(ini, wordBR, "table")
+ else
+ " let table = "----------"
+ let table = ""
+ let d = 0
+ while d < 10
+ if tailBR =~ s:notslash . '\\' . d
+ " let table[d] = d
+ let table = table . d
+ else
+ let table = table . "-"
+ endif
+ let d = d + 1
+ endwhile
+ endif
+ let d = 9
+ while d
+ if table[d] != "-"
+ let backref = substitute(a:matchline, a:prefix.word.a:suffix,
+ \ '\'.table[d], "")
+ " Are there any other characters that should be escaped?
+ let backref = escape(backref, '*,:')
+ execute s:Ref(ini, d, "start", "len")
+ let ini = strpart(ini, 0, start) . backref . strpart(ini, start+len)
+ let tailBR = substitute(tailBR, s:notslash . '\zs\\' . d,
+ \ escape(backref, '\\'), 'g')
+ endif
+ let d = d-1
+ endwhile
+ if exists("b:match_debug")
+ if s:do_BR
+ let b:match_table = table
+ let b:match_word = word
+ else
+ let b:match_table = ""
+ let b:match_word = ""
+ endif
+ endif
+ return ini . ":" . tailBR
+endfun
+
+" Input a comma-separated list of groups with backrefs, such as
+" a:groups = '\(foo\):end\1,\(bar\):end\1'
+" and return a comma-separated list of groups with backrefs replaced:
+" return '\(foo\):end\(foo\),\(bar\):end\(bar\)'
+fun! s:ParseWords(groups)
+ let groups = substitute(a:groups.",", s:notslash.'\zs[,:]*,[,:]*', ',', 'g')
+ let groups = substitute(groups, s:notslash . '\zs:\{2,}', ':', 'g')
+ let parsed = ""
+ while groups =~ '[^,:]'
+ let i = matchend(groups, s:notslash . ':')
+ let j = matchend(groups, s:notslash . ',')
+ let ini = strpart(groups, 0, i-1)
+ let tail = strpart(groups, i, j-i-1) . ":"
+ let groups = strpart(groups, j)
+ let parsed = parsed . ini
+ let i = matchend(tail, s:notslash . ':')
+ while i != -1
+ " In 'if:else:endif', ini='if' and word='else' and then word='endif'.
+ let word = strpart(tail, 0, i-1)
+ let tail = strpart(tail, i)
+ let i = matchend(tail, s:notslash . ':')
+ let parsed = parsed . ":" . s:Resolve(ini, word, "word")
+ endwhile " Now, tail has been used up.
+ let parsed = parsed . ","
+ endwhile " groups =~ '[^,:]'
+ let parsed = substitute(parsed, ',$', '', '')
+ return parsed
+endfun
+
+" TODO I think this can be simplified and/or made more efficient.
+" TODO What should I do if a:start is out of range?
+" Return a regexp that matches all of a:string, such that
+" matchstr(a:string, regexp) represents the match for a:pat that starts
+" as close to a:start as possible, before being preferred to after, and
+" ends after a:start .
+" Usage:
+" let regexp = s:Wholematch(getline("."), 'foo\|bar', col(".")-1)
+" let i = match(getline("."), regexp)
+" let j = matchend(getline("."), regexp)
+" let match = matchstr(getline("."), regexp)
+fun! s:Wholematch(string, pat, start)
+ let group = '\%(' . a:pat . '\)'
+ let prefix = (a:start ? '\(^.*\%<' . (a:start + 2) . 'c\)\zs' : '^')
+ let len = strlen(a:string)
+ let suffix = (a:start+1 < len ? '\(\%>'.(a:start+1).'c.*$\)\@=' : '$')
+ if a:string !~ prefix . group . suffix
+ let prefix = ''
+ endif
+ return prefix . group . suffix
+endfun
+
+" No extra arguments: s:Ref(string, d) will
+" find the d'th occurrence of '\(' and return it, along with everything up
+" to and including the matching '\)'.
+" One argument: s:Ref(string, d, "start") returns the index of the start
+" of the d'th '\(' and any other argument returns the length of the group.
+" Two arguments: s:Ref(string, d, "foo", "bar") returns a string to be
+" executed, having the effect of
+" :let foo = s:Ref(string, d, "start")
+" :let bar = s:Ref(string, d, "len")
+fun! s:Ref(string, d, ...)
+ let len = strlen(a:string)
+ if a:d == 0
+ let start = 0
+ else
+ let cnt = a:d
+ let match = a:string
+ while cnt
+ let cnt = cnt - 1
+ let index = matchend(match, s:notslash . '\\(')
+ if index == -1
+ return ""
+ endif
+ let match = strpart(match, index)
+ endwhile
+ let start = len - strlen(match)
+ if a:0 == 1 && a:1 == "start"
+ return start - 2
+ endif
+ let cnt = 1
+ while cnt
+ let index = matchend(match, s:notslash . '\\(\|\\)') - 1
+ if index == -2
+ return ""
+ endif
+ " Increment if an open, decrement if a ')':
+ let cnt = cnt + (match[index]=="(" ? 1 : -1) " ')'
+ " let cnt = stridx('0(', match[index]) + cnt
+ let match = strpart(match, index+1)
+ endwhile
+ let start = start - 2
+ let len = len - start - strlen(match)
+ endif
+ if a:0 == 1
+ return len
+ elseif a:0 == 2
+ return "let " . a:1 . "=" . start . "| let " . a:2 . "=" . len
+ else
+ return strpart(a:string, start, len)
+ endif
+endfun
+
+" Count the number of disjoint copies of pattern in string.
+" If the pattern is a literal string and contains no '0' or '1' characters
+" then s:Count(string, pattern, '0', '1') should be faster than
+" s:Count(string, pattern).
+fun! s:Count(string, pattern, ...)
+ let pat = escape(a:pattern, '\\')
+ if a:0 > 1
+ let foo = substitute(a:string, '[^'.a:pattern.']', "a:1", "g")
+ let foo = substitute(a:string, pat, a:2, "g")
+ let foo = substitute(foo, '[^' . a:2 . ']', "", "g")
+ return strlen(foo)
+ endif
+ let result = 0
+ let foo = a:string
+ let index = matchend(foo, pat)
+ while index != -1
+ let result = result + 1
+ let foo = strpart(foo, index)
+ let index = matchend(foo, pat)
+ endwhile
+ return result
+endfun
+
+" s:Resolve('\(a\)\(b\)', '\(c\)\2\1\1\2') should return table.word, where
+" word = '\(c\)\(b\)\(a\)\3\2' and table = '-32-------'. That is, the first
+" '\1' in target is replaced by '\(a\)' in word, table[1] = 3, and this
+" indicates that all other instances of '\1' in target are to be replaced
+" by '\3'. The hard part is dealing with nesting...
+" Note that ":" is an illegal character for source and target,
+" unless it is preceded by "\".
+fun! s:Resolve(source, target, output)
+ let word = a:target
+ let i = matchend(word, s:notslash . '\\\d') - 1
+ let table = "----------"
+ while i != -2 " There are back references to be replaced.
+ let d = word[i]
+ let backref = s:Ref(a:source, d)
+ " The idea is to replace '\d' with backref. Before we do this,
+ " replace any \(\) groups in backref with :1, :2, ... if they
+ " correspond to the first, second, ... group already inserted
+ " into backref. Later, replace :1 with \1 and so on. The group
+ " number w+b within backref corresponds to the group number
+ " s within a:source.
+ " w = number of '\(' in word before the current one
+ let w = s:Count(
+ \ substitute(strpart(word, 0, i-1), '\\\\', '', 'g'), '\(', '1')
+ let b = 1 " number of the current '\(' in backref
+ let s = d " number of the current '\(' in a:source
+ while b <= s:Count(substitute(backref, '\\\\', '', 'g'), '\(', '1')
+ \ && s < 10
+ if table[s] == "-"
+ if w + b < 10
+ " let table[s] = w + b
+ let table = strpart(table, 0, s) . (w+b) . strpart(table, s+1)
+ endif
+ let b = b + 1
+ let s = s + 1
+ else
+ execute s:Ref(backref, b, "start", "len")
+ let ref = strpart(backref, start, len)
+ let backref = strpart(backref, 0, start) . ":". table[s]
+ \ . strpart(backref, start+len)
+ let s = s + s:Count(substitute(ref, '\\\\', '', 'g'), '\(', '1')
+ endif
+ endwhile
+ let word = strpart(word, 0, i-1) . backref . strpart(word, i+1)
+ let i = matchend(word, s:notslash . '\\\d') - 1
+ endwhile
+ let word = substitute(word, s:notslash . '\zs:', '\\', 'g')
+ if a:output == "table"
+ return table
+ elseif a:output == "word"
+ return word
+ else
+ return table . word
+ endif
+endfun
+
+" Assume a:comma = ",". Then the format for a:patterns and a:1 is
+" a:patterns = "<pat1>,<pat2>,..."
+" a:1 = "<alt1>,<alt2>,..."
+" If <patn> is the first pattern that matches a:string then return <patn>
+" if no optional arguments are given; return <patn>,<altn> if a:1 is given.
+fun! s:Choose(patterns, string, comma, branch, prefix, suffix, ...)
+ let tail = (a:patterns =~ a:comma."$" ? a:patterns : a:patterns . a:comma)
+ let i = matchend(tail, s:notslash . a:comma)
+ if a:0
+ let alttail = (a:1 =~ a:comma."$" ? a:1 : a:1 . a:comma)
+ let j = matchend(alttail, s:notslash . a:comma)
+ endif
+ let current = strpart(tail, 0, i-1)
+ if a:branch == ""
+ let currpat = current
+ else
+ let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g')
+ endif
+ while a:string !~ a:prefix . currpat . a:suffix
+ let tail = strpart(tail, i)
+ let i = matchend(tail, s:notslash . a:comma)
+ if i == -1
+ return -1
+ endif
+ let current = strpart(tail, 0, i-1)
+ if a:branch == ""
+ let currpat = current
+ else
+ let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g')
+ endif
+ if a:0
+ let alttail = strpart(alttail, j)
+ let j = matchend(alttail, s:notslash . a:comma)
+ endif
+ endwhile
+ if a:0
+ let current = current . a:comma . strpart(alttail, 0, j-1)
+ endif
+ return current
+endfun
+
+" Call this function to turn on debugging information. Every time the main
+" script is run, buffer variables will be saved. These can be used directly
+" or viewed using the menu items below.
+if !exists(":MatchDebug")
+ command! -nargs=0 MatchDebug call s:Match_debug()
+endif
+
+fun! s:Match_debug()
+ let b:match_debug = 1 " Save debugging information.
+ " pat = all of b:match_words with backrefs parsed
+ amenu &Matchit.&pat :echo b:match_pat<CR>
+ " match = bit of text that is recognized as a match
+ amenu &Matchit.&match :echo b:match_match<CR>
+ " curcol = cursor column of the start of the matching text
+ amenu &Matchit.&curcol :echo b:match_col<CR>
+ " wholeBR = matching group, original version
+ amenu &Matchit.wh&oleBR :echo b:match_wholeBR<CR>
+ " iniBR = 'if' piece, original version
+ amenu &Matchit.ini&BR :echo b:match_iniBR<CR>
+ " ini = 'if' piece, with all backrefs resolved from match
+ amenu &Matchit.&ini :echo b:match_ini<CR>
+ " tail = 'else\|endif' piece, with all backrefs resolved from match
+ amenu &Matchit.&tail :echo b:match_tail<CR>
+ " fin = 'endif' piece, with all backrefs resolved from match
+ amenu &Matchit.&word :echo b:match_word<CR>
+ " '\'.d in ini refers to the same thing as '\'.table[d] in word.
+ amenu &Matchit.t&able :echo '0:' . b:match_table . ':9'<CR>
+endfun
+
+" Jump to the nearest unmatched "(" or "if" or "<tag>" if a:spflag == "bW"
+" or the nearest unmatched "</tag>" or "endif" or ")" if a:spflag == "W".
+" Return a "mark" for the original position, so that
+" let m = MultiMatch("bW", "n") ... execute m
+" will return to the original position. If there is a problem, do not
+" move the cursor and return "", unless a count is given, in which case
+" go up or down as many levels as possible and again return "".
+" TODO This relies on the same patterns as % matching. It might be a good
+" idea to give it its own matching patterns.
+fun! s:MultiMatch(spflag, mode)
+ if !exists("b:match_words") || b:match_words == ""
+ return ""
+ end
+ let restore_options = (&ic ? "" : "no") . "ignorecase"
+ if exists("b:match_ignorecase")
+ let &ignorecase = b:match_ignorecase
+ endif
+ let startline = line(".")
+ let startcol = col(".")
+
+ " First step: if not already done, set the script variables
+ " s:do_BR flag for whether there are backrefs
+ " s:pat parsed version of b:match_words
+ " s:all regexp based on s:pat and the default groups
+ " This part is copied and slightly modified from s:Match_wrapper().
+ let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") .
+ \ '\/\*:\*\/,#if\%(def\)\=:#else\>:#elif\>:#endif\>'
+ " Allow b:match_words = "GetVimMatchWords()" .
+ if b:match_words =~ ":"
+ let match_words = b:match_words
+ else
+ execute "let match_words =" b:match_words
+ endif
+ if (match_words != s:last_words) || (&mps != s:last_mps) ||
+ \ exists("b:match_debug")
+ let s:last_words = match_words
+ let s:last_mps = &mps
+ if match_words !~ s:notslash . '\\\d'
+ let s:do_BR = 0
+ let s:pat = match_words
+ else
+ let s:do_BR = 1
+ let s:pat = s:ParseWords(match_words)
+ endif
+ let s:all = '\%(' . substitute(s:pat . (strlen(s:pat)?",":"") . default,
+ \ '[,:]\+','\\|','g') . '\)'
+ if exists("b:match_debug")
+ let b:match_pat = s:pat
+ endif
+ endif
+
+ " Second step: figure out the patterns for searchpair()
+ " and save the screen, cursor position, and 'ignorecase'.
+ " - TODO: A lot of this is copied from s:Match_wrapper().
+ " - maybe even more functionality should be split off
+ " - into separate functions!
+ let cdefault = (s:pat =~ '[^,]$' ? "," : "") . default
+ let open = substitute(s:pat . cdefault,
+ \ s:notslash . '\zs:.\{-}' . s:notslash . ',', '\\),\\(', 'g')
+ let open = '\(' . substitute(open, s:notslash . '\zs:.*$', '\\)', '')
+ let close = substitute(s:pat . cdefault,
+ \ s:notslash . '\zs,.\{-}' . s:notslash . ':', '\\),\\(', 'g')
+ let close = substitute(close, '^.\{-}' . s:notslash . ':', '\\(', '') . '\)'
+ if exists("b:match_skip")
+ let skip = b:match_skip
+ elseif exists("b:match_comment") " backwards compatibility and testing!
+ let skip = "r:" . b:match_comment
+ else
+ let skip = 's:comment\|string'
+ endif
+ let skip = s:ParseSkip(skip)
+ " let restore_cursor = line(".") . "G" . virtcol(".") . "|"
+ " normal! H
+ " let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
+ let restore_cursor = virtcol(".") . "|"
+ normal! g0
+ let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor
+ normal! H
+ let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
+ execute restore_cursor
+
+ " Third step: call searchpair().
+ " Replace '\('--but not '\\('--with '\%(' and ',' with '\|'.
+ let openpat = substitute(open, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g')
+ let openpat = substitute(openpat, ',', '\\|', 'g')
+ let closepat = substitute(close, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g')
+ let closepat = substitute(closepat, ',', '\\|', 'g')
+ if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
+ let skip = '0'
+ else
+ execute "if " . skip . "| let skip = '0' | endif"
+ endif
+ mark '
+ let level = v:count1
+ while level
+ if searchpair(openpat, '', closepat, a:spflag, skip) < 1
+ call s:CleanUp(restore_options, a:mode, startline, startcol)
+ return ""
+ endif
+ let level = level - 1
+ endwhile
+
+ " Restore options and return a string to restore the original position.
+ call s:CleanUp(restore_options, a:mode, startline, startcol)
+ return restore_cursor
+endfun
+
+" Search backwards for "if" or "while" or "<tag>" or ...
+" and return "endif" or "endwhile" or "</tag>" or ... .
+" For now, this uses b:match_words and the same script variables
+" as s:Match_wrapper() . Later, it may get its own patterns,
+" either from a buffer variable or passed as arguments.
+" fun! s:Autocomplete()
+" echo "autocomplete not yet implemented :-("
+" if !exists("b:match_words") || b:match_words == ""
+" return ""
+" end
+" let startpos = s:MultiMatch("bW")
+"
+" if startpos == ""
+" return ""
+" endif
+" " - TODO: figure out whether 'if' or '<tag>' matched, and construct
+" " - the appropriate closing.
+" let matchline = getline(".")
+" let curcol = col(".") - 1
+" " - TODO: Change the s:all argument if there is a new set of match pats.
+" let regexp = s:Wholematch(matchline, s:all, curcol)
+" let suf = strlen(matchline) - matchend(matchline, regexp)
+" let prefix = (curcol ? '^.\{' . curcol . '}\%(' : '^\%(')
+" let suffix = (suf ? '\).\{' . suf . '}$' : '\)$')
+" " Reconstruct the version with unresolved backrefs.
+" let patBR = substitute(b:match_words.',', '[,:]*,[,:]*', ',', 'g')
+" let patBR = substitute(patBR, ':\{2,}', ':', "g")
+" " Now, set group and groupBR to the matching group: 'if:endif' or
+" " 'while:endwhile' or whatever.
+" let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR)
+" let i = matchend(group, s:notslash . ",")
+" let groupBR = strpart(group, i)
+" let group = strpart(group, 0, i-1)
+" " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix
+" if s:do_BR
+" let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline)
+" endif
+" " let g:group = group
+"
+" " - TODO: Construct the closing from group.
+" let fake = "end" . expand("<cword>")
+" execute startpos
+" return fake
+" endfun
+
+" Close all open structures. "Get the heck out of here!"
+" fun! s:Gthhoh()
+" let close = s:Autocomplete()
+" while strlen(close)
+" put=close
+" let close = s:Autocomplete()
+" endwhile
+" endfun
+
+" Parse special strings as typical skip arguments for searchpair():
+" s:foo becomes (current syntax item) =~ foo
+" S:foo becomes (current syntax item) !~ foo
+" r:foo becomes (line before cursor) =~ foo
+" R:foo becomes (line before cursor) !~ foo
+fun! s:ParseSkip(str)
+ let skip = a:str
+ if skip[1] == ":"
+ if skip[0] == "s"
+ let skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" .
+ \ strpart(skip,2) . "'"
+ elseif skip[0] == "S"
+ let skip = "synIDattr(synID(line('.'),col('.'),1),'name') !~? '" .
+ \ strpart(skip,2) . "'"
+ elseif skip[0] == "r"
+ let skip = "strpart(getline('.'),0,col('.'))=~'" . strpart(skip,2). "'"
+ elseif skip[0] == "R"
+ let skip = "strpart(getline('.'),0,col('.'))!~'" . strpart(skip,2). "'"
+ endif
+ endif
+ return skip
+endfun
+
+let &cpo = s:save_cpo
+
+" vim:sts=2:sw=2:
--- /dev/null
+Subproject commit 1f4bfd59920c101a30a74a07b824608a6e65f3fe
--- /dev/null
+Subproject commit 7a6675f092842c8f81e71d5345bd7cdbf3759415
--- /dev/null
+Subproject commit 2d05440ad23f97a7874ebd9b5de3a0e65d25d85c
--- /dev/null
+Subproject commit beb1725e57376caeb890df24c259a2e341ec69bd
--- /dev/null
+" Vim color scheme.
+"
+" Designed for dark and partially transparent terminals with 256 colors. It
+" works with GVim - however by default GVim doesn't support transparent
+" backgrounds, thus black is used as background color.
+"
+" Tested with xterm and (u)rxvt (both with -256color) and GVim.
+"
+" Not all available highlight groups are used at the moment.
+"
+" Some new highlight groups are defined which can be used in syntax files, see
+" "GENERAL ADDITIONS" below. They have to be configured to work.
+"
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" Last Change: 2014-10-24
+" License: GPL v3+
+
+" Copyright (C) 2011-2014 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" This color scheme only works with 256 colors and in GVim.
+if &t_Co != 256 && !has('gui_running')
+ echoerr 'Colorscheme "simon" needs 256 colors. Aborting.'
+ finish
+endif
+
+
+" This color scheme is (only) designed for a dark background.
+set background=dark
+highlight clear
+
+" :highlight clear resets this variable, so put it after it.
+let g:colors_name = 'simon'
+
+
+" GENERAL HIGHLIGHT SETTINGS
+
+" Normal text (very light gray on default terminal background). ctermbg=NONE
+" necessary for transparency. GVim doesn't support a transparent background,
+" thus use black.
+highlight Normal ctermfg=252 ctermbg=NONE guifg=#d0d0d0 guibg=#000000
+
+" Comments (violet on default).
+highlight Comment ctermfg=135 guifg=#af5fff
+" Constants (light dark red on default).
+highlight Constant ctermfg=160 guifg=#d70000
+ " Strings, e.g. ".." (dark orange on default).
+ highlight String ctermfg=208 guifg=#ff8700
+ " Characters, e.g. '.' in C (lighter dark orange on default).
+ highlight Character ctermfg=215 guifg=#ffaf5f
+ " Numbers (light magenta on default).
+ highlight Number ctermfg=207 guifg=#ff5fff
+ " Booleans (light dark red on default).
+ highlight Boolean ctermfg=160 guifg=#d70000
+ highlight Float ctermfg=207 guifg=#ff5fff
+" Identifier (cyan on default). cterm=NONE to prevent bold.
+highlight Identifier ctermfg=51 cterm=NONE guifg=#00ffff gui=NONE
+ " Function names, often used for predefined functions (cyan on default).
+ highlight Function ctermfg=51 cterm=NONE guifg=#00ffff gui=NONE
+" Statements, e.g. return, continue, etc. (yellow on default).
+highlight Statement ctermfg=227 cterm=bold guifg=#ffff5f gui=bold
+" Preprocessor commands, e.g. #include in cpp (light blue on default).
+highlight PreProc ctermfg=63 cterm=bold guifg=#5f5fff gui=bold
+" Types of variables, e.g. int, long, etc. (light green on default).
+highlight Type ctermfg=83 cterm=bold guifg=#5fff5f gui=bold
+ " static, volatile, etc. (lighter green on default).
+ highlight StorageClass ctermfg=120 cterm=bold guifg=#87ff87 gui=bold
+" Special characters (red on default).
+highlight Special ctermfg=160 guifg=#d70000
+ " Special characters in a string, e.g. '\n' (red on default).
+ highlight SpecialChar ctermfg=160 guifg=#d70000
+ " Delimiter characters, e.g. braces around function arguments in some
+ " languages (dark red on default).
+ highlight Delimiter ctermfg=52 guifg=#5f0000
+ " Special items inside a comment (light violent on darker violet).
+ highlight SpecialComment ctermfg=135 ctermbg=93 guifg=#af5fff guibg=#8700ff
+" (Syntax) Errors (white on red).
+highlight Error ctermfg=231 ctermbg=196 guifg=#ffffff guibg=#ff0000
+" Todo items and other important stuff (e.g. TODO, XXX, etc.) (black on
+" yellow).
+highlight Todo ctermfg=16 ctermbg=226 guifg=#000000 guibg=#ffff00
+
+
+" Additional highlights used by the "GUI", not directly by syntax
+" highlighting.
+
+" Columns set with 'colorcolumn' (default on bright violet).
+highlight ColorColumn ctermbg=57 guibg=#5f00ff
+" Cursor color (black on light yellow).
+highlight Cursor ctermfg=16 ctermbg=227 guifg=#000000 guibg=#ffff5f
+" Cursor color when IME or XIM is on, :h CursorIM (not used, keep in sync with
+" Cursor).
+highlight CursorIM ctermfg=16 ctermbg=227 guifg=#000000 guibg=#ffff5f
+" Current cursor column/line (current color on dark gray). cterm=NONE to
+" prevent underlining.
+highlight CursorColumn ctermbg=234 cterm=NONE guibg=#1c1c1c gui=NONE
+highlight CursorLine ctermbg=234 cterm=NONE guibg=#1c1c1c gui=NONE
+" Directories in file listings (blue on default).
+highlight Directory ctermfg=27 cterm=bold guifg=#005fff gui=bold
+" Error messages (white on red).
+highlight ErrorMsg ctermfg=231 ctermbg=196 guifg=#ffffff guibg=#ff0000
+" Fold column, left of number column (lighter yellow on default), ctermbg=NONE
+" necessary for transparency.
+highlight FoldColumn ctermfg=228 ctermbg=NONE guifg=#ffff87 guibg=NONE
+" Current search match during incremental search (black on orange).
+highlight IncSearch ctermfg=16 ctermbg=214 guifg=#000000 guibg=#ffaf00
+" Line number in line number column (light yellow on default).
+highlight LineNr ctermfg=227 guifg=#ffff5f
+" Matching brace/bracket when the cursor is currently on the other one
+" (default on light green).
+highlight MatchParen ctermbg=40 guibg=#00d700
+" 'showmode' message, e.g. "-- INSERT --" (light gray on default).
+highlight ModeMsg ctermfg=247 guifg=#9e9e9e
+" More prompt (:h more-prompt) (light green on default).
+highlight MoreMsg ctermfg=119 guifg=#87ff5f
+" Characters which do not really exist in the text (:h NonText) (gray-like
+" blue on default).
+highlight NonText ctermfg=105 guifg=#8787ff
+" Last search pattern for 'hlsearch' (keep in sync with IncSearch).
+highlight Search ctermfg=16 ctermbg=214 guifg=#000000 guibg=#ffaf00
+" Special characters, e.g. tabs, control characters (e.g. ^K), etc. (light
+" blue on default).
+highlight SpecialKey ctermfg=69 guifg=#5f87ff
+" Spelling mistake (default on light violet).
+highlight SpellBad ctermbg=127 guibg=#af00af
+" Wrong capitalization (default on light blue).
+highlight SpellCap ctermbg=27 guibg=#005fff
+" Status line of the currently active window (bold and reverse).
+highlight StatusLine cterm=reverse,bold gui=reverse,bold
+" Status line of inactive windows (reverse).
+highlight StatusLineNC cterm=reverse gui=reverse
+" Tab pages line, parts with no labels on the right (default, cterm=NONE to
+" disable reverse).
+highlight TabLineFill cterm=NONE gui=NONE
+" Titles in output from :set all, :autocmd, etc. (light blue on default). Also
+" used by AsciiDoc.
+highlight Title ctermfg=63 cterm=bold guifg=#5f5fff gui=bold
+" Vertical split column (black on default), black to try to hide it
+" (ctermfg=NONE doesn't work), cterm=NONE is necessary to remove reverse. Also
+" see my vimrc for a way to hide it completely (the column is still there, but
+" empty).
+highlight VertSplit ctermfg=16 cterm=NONE guifg=#000000 gui=NONE
+" Current visual selection (default on light gray).
+highlight Visual ctermbg=246 guibg=#949494
+" Warning messages (white on orange).
+highlight WarningMsg ctermfg=231 ctermbg=166 guifg=#ffffff guibg=#d75f00
+
+" Cursor color when language mappings are used, :h lCursor (not used, keep in
+" sync with Cursor).
+highlight lCursor ctermfg=16 ctermbg=227 guifg=#000000 guibg=#ffff5f
+
+
+" GENERAL ADDITIONS
+
+" Tab characters (if 'list' is enabled) to reduce their visibility in
+" comparison with SpecialKey (darker gray on default).
+"
+" Needs matchadd('specialKeyTab', '\t') in vimrc.
+highlight specialKeyTab ctermfg=239 guifg=#4e4e4e
+
+" Statement control keywords (e.g. continue, break, return, goto, etc.), extra
+" syntax item to make them extra visible (keep in sync with Statement, except
+" underline).
+"
+" Needs a modified syntax file or additional rules in after/syntax/.
+"
+" For example for C:
+"
+" syntax keyword statementControl continue break return goto
+"
+" Or for Perl:
+"
+" highlight link perlStatementControl statementControl
+highlight statementControl ctermfg=227 cterm=bold,underline guifg=#ffff5f gui=bold,underline
--- /dev/null
+" Vim filetype detection file
+" Language: AsciiDoc
+" Author: Stuart Rackham <srackham@gmail.com>
+" Last Change: AsciiDoc 8.2.0
+" URL: http://www.methods.co.nz/asciidoc/
+" Licence: GPL (http://www.gnu.org)
+" Remarks: Vim 6 or greater
+
+" COMMENT OUT ONE OF THE TWO FOLLOWING COMMANDS
+" The first sets asciidoc syntax highlighting on all .txt files, the second
+" only existing files *.txt that appear to be AsciiDoc files.
+
+"au BufNewFile,BufRead *.txt,README,TODO,CHANGELOG,NOTES setfiletype asciidoc
+au BufRead *.txt,README,TODO,CHANGELOG,NOTES call s:FTasciidoc()
+
+" This function checks for a valid AsciiDoc document title after first
+" skipping any leading comments.
+function! s:FTasciidoc()
+ let in_comment_block = 0
+ let n = 1
+ while n < 50
+ let line = getline(n)
+ let n = n + 1
+ if line =~ '^/\{4,}$'
+ if ! in_comment_block
+ let in_comment_block = 1
+ else
+ let in_comment_block = 0
+ endif
+ continue
+ endif
+ if in_comment_block
+ continue
+ endif
+ if line !~ '\(^//\)\|\(^\s*$\)'
+ break
+ endif
+ endwhile
+ if line !~ '.\{3,}'
+ return
+ endif
+ let len = len(line)
+ let line = getline(n)
+ if line !~ '[-=]\{3,}'
+ return
+ endif
+ if len < len(line) - 3 || len > len(line) + 3
+ return
+ endif
+ setfiletype asciidoc
+endfunction
+
+" vim: et sw=2 ts=2 sts=2:
--- /dev/null
+" Vimperator
+au BufNewFile,BufRead *vimperatorrc*,*.vimp set filetype=vimperator
--- /dev/null
+" Custom settings for XPTemplate.
+XPTemplate priority=personal
+
+XPTvar $author Simon Ruderich
+XPTvar $email simon@ruderich.org
+
+
+" Space settings related to brackets.
+
+" if () ** {
+" else ** {
+XPTvar $BRif ' '
+" } ** else {
+XPTvar $BRel ' '
+" for () ** {
+" while () ** {
+" do ** {
+XPTvar $BRloop ' '
+" struct name ** {
+XPTvar $BRstc ' '
+" int fun() ** {
+" class name ** {
+XPTvar $BRfun ' '
+
+
+" General space settings.
+
+" int fun ** (
+" class name ** (
+XPTvar $SPfun ''
+
+" int fun( ** arg ** )
+" if ( ** condition ** )
+" for ( ** statement ** )
+" [ ** a, b ** ]
+" { ** 'k' : 'v' ** }
+XPTvar $SParg ''
+
+" if ** (
+" while ** (
+" for ** (
+XPTvar $SPcmd ' '
+
+" a ** = ** b
+" a = a ** + ** 1
+" (a, ** b, ** )
+XPTvar $SPop ' '
--- /dev/null
+" vim: ft=xpt
+
+" XPTemplate template file.
+"
+" Language: C
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2012-2014 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Prevent errors if XPTemplate is not installed.
+if !exists('g:XPT#ver')
+ finish
+endif
+
+XPTemplate priority=personal
+
+
+XPT f
+XSET description|post=S(V(), '^description$', 'XXX')
+/*
+ * `description^
+ *
+ * Copyright (C) `strftime("%Y")^ Simon Ruderich
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int main(int argc, char **argv) {
+ `cursor^
+
+ return EXIT_SUCCESS;
+}
+
+
+XPT p
+printf("`format^"`cursor^);
+
+XPT pe
+fprintf(stderr, "`format^"`cursor^);
--- /dev/null
+" vim: ft=xpt
+
+" XPTemplate template file.
+"
+" Language: Java
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2012-2014 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Prevent errors if XPTemplate is not installed.
+if !exists('g:XPT#ver')
+ finish
+endif
+
+XPTemplate priority=personal
+
+
+XPT f
+XSET description|post=S(V(), '^description$', 'XXX')
+/*
+ * `description^
+ *
+ * Copyright (C) `strftime("%Y")^ Simon Ruderich
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+public class `E('%:t:r')^ {
+ `cursor^
+}
+
+
+XPT p
+System.out.println(`value^);
+
+XPT pe
+System.err.println(`value^);
--- /dev/null
+" vim: ft=xpt
+
+" XPTemplate template file.
+"
+" Language: Perl
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2012-2014 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Prevent errors if XPTemplate is not installed.
+if !exists('g:XPT#ver')
+ finish
+endif
+
+XPTemplate priority=personal
+
+
+XPT f
+XSET description|post=S(V(), '^description$', 'XXX')
+#!/usr/bin/perl
+
+# `description^
+
+# Copyright (C) `strftime("%Y")^ Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+use strict;
+use warnings;
+
+
+`cursor^
+
+
+XPT p
+print `value^;
+
+XPT pe
+print STDERR `value^;
+
+XPT pd
+print Dumper(`value^);
+
+
+XPT u
+use `package^;
+`cursor^
+
+XPT udd
+use Data::Dumper;
+`cursor^
--- /dev/null
+" vim: ft=xpt
+
+" XPTemplate template file.
+"
+" Language: LaTeX
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2012 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" Prevent errors if XPTemplate is not installed.
+if !exists('g:XPT#ver')
+ finish
+endif
+
+XPTemplate priority=personal
+
+
+" PACKAGES
+
+XPT usepackage " \usepackage{..}
+\usepackage{`package^}
+
+
+" SECTIONS
+
+XPT s synonym=section " \section{..}
+\section`*^{`title^}
+
+XPT ss " \subsection{..}
+\subsection`*^{`title^}
+
+XPT sss " \subsubsection{..}
+\subsubsection`*^{`title^}
+
+
+" ENVIRONMENTS
+
+XPT itemize " \begin{itemize} .. \end{itemize}
+\begin{itemize}
+\item `cursor^
+\end{itemize}
+
+XPT enumerate " \begin{enumerate} .. \end{enumerate}
+\begin{enumerate}
+\item `cursor^
+\end{enumerate}
+
+XPT description " \begin{description} .. \end{description}
+\begin{description}
+\item`[`text?`]^ `cursor^
+\end{description}
+
+XPT i "\item ..
+\item`[`text?`]^ `cursor^
+
+XPT align " \begin{align} .. \end{align}
+\begin{align`*^}
+`cursor^
+\end{align`*^}
+
+XPT listing " \begin{lstlisting} .. \end{lstlisting}
+\begin{lstlisting}`[`attributes?`]^
+`cursor^
+\end{lstlisting}
+
+
+" BEAMER
+
+XPT frame " \begin{frame} .. \end{frame}
+\begin{frame}{`title^}
+`cursor^
+\end{frame}
+
+XPT block " \begin{block} .. \end{block}
+\begin{block}{`title^}
+`cursor^
+\end{block}
+
+XPT exampleblock " \begin{exampleblock} .. \end{exampleblock}
+\begin{exampleblock}{`title^}
+`cursor^
+\end{exampleblock}
--- /dev/null
+" vim: ft=xpt
+
+" XPTemplate template file.
+"
+" Language: VHDL
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" License: GPL v3+
+
+" Copyright (C) 2014 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+XPTemplate priority=lang
+
+let s:f = g:XPTfuncs()
+
+XPTinclude
+ \ _common/common
+
+
+XPT f
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+`cursor^
+
+
+XPT slv
+std_logic_vector(`from^ downto `to^)
+
+
+XPT entity
+entity `name^ is
+ port(
+ `cursor^
+ );
+end entity;
+
+XPT architecture
+architecture `behavioral^ of `entity^ is
+begin
+ `cursor^
+end architecture;
+
+XPT process
+process`list^
+begin
+ `cursor^
+end process;
+
+XPT if
+if `condition^ then
+ `cursor^
+end if;
--- /dev/null
+" Name: gnupg.vim
+" Last Change: 2015 Dec 17
+" Maintainer: James McCoy <vega.james@gmail.com>
+" Original Author: Markus Braun <markus.braun@krawel.de>
+" Summary: Vim plugin for transparent editing of gpg encrypted files.
+" License: This program is free software; you can redistribute it and/or
+" modify it under the terms of the GNU General Public License
+" as published by the Free Software Foundation; either version
+" 2 of the License, or (at your option) any later version.
+" See http://www.gnu.org/copyleft/gpl-2.0.txt
+"
+" Section: Documentation {{{1
+"
+" Description: {{{2
+"
+" This script implements transparent editing of gpg encrypted files. The
+" filename must have a ".gpg", ".pgp" or ".asc" suffix. When opening such
+" a file the content is decrypted, when opening a new file the script will
+" ask for the recipients of the encrypted file. The file content will be
+" encrypted to all recipients before it is written. The script turns off
+" viminfo, swapfile, and undofile to increase security.
+"
+" Installation: {{{2
+"
+" Copy the gnupg.vim file to the $HOME/.vim/plugin directory.
+" Refer to ':help add-plugin', ':help add-global-plugin' and ':help
+" runtimepath' for more details about Vim plugins.
+"
+" From "man 1 gpg-agent":
+"
+" ...
+" You should always add the following lines to your .bashrc or whatever
+" initialization file is used for all shell invocations:
+"
+" GPG_TTY=`tty`
+" export GPG_TTY
+"
+" It is important that this environment variable always reflects the out‐
+" put of the tty command. For W32 systems this option is not required.
+" ...
+"
+" Most distributions provide software to ease handling of gpg and gpg-agent.
+" Examples are keychain or seahorse.
+"
+" If there are specific actions that should take place when editing a
+" GnuPG-managed buffer, an autocmd for the User event and GnuPG pattern can
+" be defined. For example, the following will set 'textwidth' to 72 for all
+" GnuPG-encrypted buffers:
+"
+" autocmd User GnuPG setl textwidth=72
+"
+" This will be triggered before any BufRead or BufNewFile autocmds, and
+" therefore will not take precedence over settings specific to any filetype
+" that may get set.
+"
+" Commands: {{{2
+"
+" :GPGEditRecipients
+" Opens a scratch buffer to change the list of recipients. Recipients that
+" are unknown (not in your public key) are highlighted and have
+" a prepended "!". Closing the buffer makes the changes permanent.
+"
+" :GPGViewRecipients
+" Prints the list of recipients.
+"
+" :GPGEditOptions
+" Opens a scratch buffer to change the options for encryption (symmetric,
+" asymmetric, signing). Closing the buffer makes the changes permanent.
+" WARNING: There is no check of the entered options, so you need to know
+" what you are doing.
+"
+" :GPGViewOptions
+" Prints the list of options.
+"
+" Variables: {{{2
+"
+" g:GPGExecutable
+" If set used as gpg executable. If unset, defaults to
+" "gpg --trust-model always" if "gpg" is available, falling back to
+" "gpg2 --trust-model always" if not.
+"
+" g:GPGUseAgent
+" If set to 0 a possible available gpg-agent won't be used. Defaults to 1.
+"
+" g:GPGPreferSymmetric
+" If set to 1 symmetric encryption is preferred for new files. Defaults to 0.
+"
+" g:GPGPreferArmor
+" If set to 1 armored data is preferred for new files. Defaults to 0
+" unless a "*.asc" file is being edited.
+"
+" g:GPGPreferSign
+" If set to 1 signed data is preferred for new files. Defaults to 0.
+"
+" g:GPGDefaultRecipients
+" If set, these recipients are used as defaults when no other recipient is
+" defined. This variable is a Vim list. Default is unset.
+"
+" g:GPGPossibleRecipients
+" If set, these contents are loaded into the recipients dialog. This
+" allows to add commented lines with possible recipients to the list,
+" which can be uncommented to select the actual recipients. Default is
+" unset. Example:
+"
+" let g:GPGPossibleRecipients=[
+" \"Example User <example@example.com>",
+" \"Other User <otherexample@example.com>"
+" \]
+"
+"
+" g:GPGUsePipes
+" If set to 1, use pipes instead of temporary files when interacting with
+" gnupg. When set to 1, this can cause terminal-based gpg agents to not
+" display correctly when prompting for passwords. Defaults to 0.
+"
+" g:GPGHomedir
+" If set, specifies the directory that will be used for GPG's homedir.
+" This corresponds to gpg's --homedir option. This variable is a Vim
+" string. Default is unset.
+"
+" g:GPGFilePattern
+" If set, overrides the default set of file patterns that determine
+" whether this plugin will be activated. Defaults to
+" '*.\(gpg\|asc\|pgp\)'.
+"
+" Known Issues: {{{2
+"
+" In some cases gvim can't decrypt files
+
+" This is caused by the fact that a running gvim has no TTY and thus gpg is
+" not able to ask for the passphrase by itself. This is a problem for Windows
+" and Linux versions of gvim and could not be solved unless a "terminal
+" emulation" is implemented for gvim. To circumvent this you have to use any
+" combination of gpg-agent and a graphical pinentry program:
+"
+" - gpg-agent only:
+" you need to provide the passphrase for the needed key to gpg-agent
+" in a terminal before you open files with gvim which require this key.
+"
+" - pinentry only:
+" you will get a popup window every time you open a file that needs to
+" be decrypted.
+"
+" - gpgagent and pinentry:
+" you will get a popup window the first time you open a file that
+" needs to be decrypted.
+"
+" If you're using Vim <7.4.959, after the plugin runs any external command,
+" Vim will no longer be able to yank to/paste from the X clipboard or
+" primary selections. This is caused by a workaround for a different bug
+" where Vim no longer recognizes the key codes for keys such as the arrow
+" keys after running GnuPG. See the discussion at
+" https://github.com/jamessan/vim-gnupg/issues/36 for more details.
+"
+" Credits: {{{2
+"
+" - Mathieu Clabaut for inspirations through his vimspell.vim script.
+" - Richard Bronosky for patch to enable ".pgp" suffix.
+" - Erik Remmelzwaal for patch to enable windows support and patient beta
+" testing.
+" - Lars Becker for patch to make gpg2 working.
+" - Thomas Arendsen Hein for patch to convert encoding of gpg output.
+" - Karl-Heinz Ruskowski for patch to fix unknown recipients and trust model
+" and patient beta testing.
+" - Giel van Schijndel for patch to get GPG_TTY dynamically.
+" - Sebastian Luettich for patch to fix issue with symmetric encryption an set
+" recipients.
+" - Tim Swast for patch to generate signed files.
+" - James Vega for patches for better '*.asc' handling, better filename
+" escaping and better handling of multiple keyrings.
+"
+" Section: Plugin header {{{1
+
+" guard against multiple loads {{{2
+if (exists("g:loaded_gnupg") || &cp || exists("#GnuPG"))
+ finish
+endif
+let g:loaded_gnupg = '2.5'
+let s:GPGInitRun = 0
+
+" check for correct vim version {{{2
+if (v:version < 702)
+ echohl ErrorMsg | echo 'plugin gnupg.vim requires Vim version >= 7.2' | echohl None
+ finish
+endif
+
+" Section: Autocmd setup {{{1
+
+if (!exists("g:GPGFilePattern"))
+ let g:GPGFilePattern = '*.\(gpg\|asc\|pgp\)'
+endif
+
+augroup GnuPG
+ autocmd!
+
+ " do the decryption
+ exe "autocmd BufReadCmd " . g:GPGFilePattern . " call s:GPGInit(1) |" .
+ \ " call s:GPGDecrypt(1)"
+ exe "autocmd FileReadCmd " . g:GPGFilePattern . " call s:GPGInit(0) |" .
+ \ " call s:GPGDecrypt(0)"
+
+ " convert all text to encrypted text before writing
+ " We check for GPGCorrespondingTo to avoid triggering on writes in GPG Options/Recipient windows
+ exe "autocmd BufWriteCmd,FileWriteCmd " . g:GPGFilePattern . " if !exists('b:GPGCorrespondingTo') |" .
+ \ " call s:GPGInit(0) |" .
+ \ " call s:GPGEncrypt() |" .
+ \ " endif"
+
+ " cleanup on leaving vim
+ exe "autocmd VimLeave " . g:GPGFilePattern . " call s:GPGCleanup()"
+augroup END
+
+" Section: Constants {{{1
+
+let s:GPGMagicString = "\t \t"
+let s:keyPattern = '\%(0x\)\=[[:xdigit:]]\{8,16}'
+
+" Section: Highlight setup {{{1
+
+highlight default link GPGWarning WarningMsg
+highlight default link GPGError ErrorMsg
+highlight default link GPGHighlightUnknownRecipient ErrorMsg
+
+" Section: Functions {{{1
+
+" Function: s:shellescape(s[, special]) {{{2
+"
+" Calls shellescape(), also taking into account 'shellslash'
+" when on Windows and using $COMSPEC as the shell.
+"
+" Returns: shellescaped string
+"
+function s:shellescape(s, ...)
+ let special = a:0 ? a:1 : 0
+ if exists('+shellslash') && &shell == $COMSPEC
+ let ssl = &shellslash
+ set noshellslash
+
+ let escaped = shellescape(a:s, special)
+
+ let &shellslash = ssl
+ else
+ let escaped = shellescape(a:s, special)
+ endif
+
+ return escaped
+endfunction
+
+" Function: s:GPGInit(bufread) {{{2
+"
+" initialize the plugin
+" The bufread argument specifies whether this was called due to BufReadCmd
+"
+function s:GPGInit(bufread)
+ call s:GPGDebug(3, printf(">>>>>>>> Entering s:GPGInit(%d)", a:bufread))
+
+ " For FileReadCmd, we're reading the contents into another buffer. If that
+ " buffer is also destined to be encrypted, then these settings will have
+ " already been set, otherwise don't set them since it limits the
+ " functionality of the cleartext buffer.
+ if a:bufread
+ " we don't want a swap file, as it writes unencrypted data to disk
+ setl noswapfile
+
+ " if persistent undo is present, disable it for this buffer
+ if exists('+undofile')
+ setl noundofile
+ endif
+
+ " first make sure nothing is written to ~/.viminfo while editing
+ " an encrypted file.
+ set viminfo=
+ endif
+
+ " the rest only has to be run once
+ if s:GPGInitRun
+ return
+ endif
+
+ " check what gpg command to use
+ if (!exists("g:GPGExecutable"))
+ if executable("gpg")
+ let g:GPGExecutable = "gpg --trust-model always"
+ else
+ let g:GPGExecutable = "gpg2 --trust-model always"
+ endif
+ endif
+
+ " check if gpg-agent is allowed
+ if (!exists("g:GPGUseAgent"))
+ let g:GPGUseAgent = 1
+ endif
+
+ " check if symmetric encryption is preferred
+ if (!exists("g:GPGPreferSymmetric"))
+ let g:GPGPreferSymmetric = 0
+ endif
+
+ " check if armored files are preferred
+ if (!exists("g:GPGPreferArmor"))
+ " .asc files should be armored as that's what the extension is used for
+ if expand('<afile>') =~ '\.asc$'
+ let g:GPGPreferArmor = 1
+ else
+ let g:GPGPreferArmor = 0
+ endif
+ endif
+
+ " check if signed files are preferred
+ if (!exists("g:GPGPreferSign"))
+ let g:GPGPreferSign = 0
+ endif
+
+ " start with empty default recipients if none is defined so far
+ if (!exists("g:GPGDefaultRecipients"))
+ let g:GPGDefaultRecipients = []
+ endif
+
+ if (!exists("g:GPGPossibleRecipients"))
+ let g:GPGPossibleRecipients = []
+ endif
+
+
+ " prefer not to use pipes since it can garble gpg agent display
+ if (!exists("g:GPGUsePipes"))
+ let g:GPGUsePipes = 0
+ endif
+
+ " allow alternate gnupg homedir
+ if (!exists('g:GPGHomedir'))
+ let g:GPGHomedir = ''
+ endif
+
+ " print version
+ call s:GPGDebug(1, "gnupg.vim ". g:loaded_gnupg)
+
+ let s:GPGCommand = g:GPGExecutable
+
+ " don't use tty in gvim except for windows: we get their a tty for free.
+ " FIXME find a better way to avoid an error.
+ " with this solution only --use-agent will work
+ if (has("gui_running") && !has("gui_win32"))
+ let s:GPGCommand .= " --no-tty"
+ endif
+
+ " setup shell environment for unix and windows
+ let s:shellredirsave = &shellredir
+ let s:shellsave = &shell
+ let s:shelltempsave = &shelltemp
+ " noshelltemp isn't currently supported on Windows, but it doesn't cause any
+ " errors and this future proofs us against requiring changes if Windows
+ " gains noshelltemp functionality
+ let s:shelltemp = !g:GPGUsePipes
+ if (has("unix"))
+ " unix specific settings
+ let s:shellredir = ">%s 2>&1"
+ let s:shell = '/bin/sh'
+ let s:stderrredirnull = '2>/dev/null'
+ else
+ " windows specific settings
+ let s:shellredir = '>%s'
+ let s:shell = &shell
+ let s:stderrredirnull = '2>nul'
+ endif
+
+ call s:GPGDebug(3, "shellredirsave: " . s:shellredirsave)
+ call s:GPGDebug(3, "shellsave: " . s:shellsave)
+ call s:GPGDebug(3, "shelltempsave: " . s:shelltempsave)
+
+ call s:GPGDebug(3, "shell: " . s:shell)
+ call s:GPGDebug(3, "shellcmdflag: " . &shellcmdflag)
+ call s:GPGDebug(3, "shellxquote: " . &shellxquote)
+ call s:GPGDebug(3, "shellredir: " . s:shellredir)
+ call s:GPGDebug(3, "stderrredirnull: " . s:stderrredirnull)
+
+ call s:GPGDebug(3, "shell implementation: " . resolve(s:shell))
+
+ " find the supported algorithms
+ let output = s:GPGSystem({ 'level': 2, 'args': '--version' })
+
+ let gpgversion = substitute(output, '^gpg (GnuPG) \([0-9]\+\.\d\+\).*', '\1', '')
+ let s:GPGPubkey = substitute(output, ".*Pubkey: \\(.\\{-}\\)\n.*", "\\1", "")
+ let s:GPGCipher = substitute(output, ".*Cipher: \\(.\\{-}\\)\n.*", "\\1", "")
+ let s:GPGHash = substitute(output, ".*Hash: \\(.\\{-}\\)\n.*", "\\1", "")
+ let s:GPGCompress = substitute(output, ".*Compress.\\{-}: \\(.\\{-}\\)\n.*", "\\1", "")
+
+ " determine if gnupg can use the gpg-agent
+ if (str2float(gpgversion) >= 2.1 || (exists("$GPG_AGENT_INFO") && g:GPGUseAgent == 1))
+ if (!exists("$GPG_TTY") && !has("gui_running"))
+ " Need to determine the associated tty by running a command in the
+ " shell. We can't use system() here because that doesn't run in a shell
+ " connected to a tty, so it's rather useless.
+ "
+ " Save/restore &modified so the buffer isn't incorrectly marked as
+ " modified just by detecting the correct tty value.
+ " Do the &undolevels dance so the :read and :delete don't get added into
+ " the undo tree, as the user needn't be aware of these.
+ let [mod, levels] = [&l:modified, &undolevels]
+ set undolevels=-1
+ silent read !tty
+ let $GPG_TTY = getline('.')
+ silent delete
+ let [&l:modified, &undolevels] = [mod, levels]
+ " redraw is needed since we're using silent to run !tty, c.f. :help :!
+ redraw!
+ if (v:shell_error)
+ let $GPG_TTY = ""
+ echohl GPGWarning
+ echom "$GPG_TTY is not set and the `tty` command failed! gpg-agent might not work."
+ echohl None
+ endif
+ endif
+ let s:GPGCommand .= " --use-agent"
+ else
+ let s:GPGCommand .= " --no-use-agent"
+ endif
+
+ call s:GPGDebug(2, "public key algorithms: " . s:GPGPubkey)
+ call s:GPGDebug(2, "cipher algorithms: " . s:GPGCipher)
+ call s:GPGDebug(2, "hashing algorithms: " . s:GPGHash)
+ call s:GPGDebug(2, "compression algorithms: " . s:GPGCompress)
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGInit()")
+ let s:GPGInitRun = 1
+endfunction
+
+" Function: s:GPGCleanup() {{{2
+"
+" cleanup on leaving vim
+"
+function s:GPGCleanup()
+ call s:GPGDebug(3, ">>>>>>>> Entering s:GPGCleanup()")
+
+ " wipe out screen
+ new +only
+ redraw!
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGCleanup()")
+endfunction
+
+" Function: s:GPGDecrypt(bufread) {{{2
+"
+" decrypt the buffer and find all recipients of the encrypted file
+" The bufread argument specifies whether this was called due to BufReadCmd
+"
+function s:GPGDecrypt(bufread)
+ call s:GPGDebug(3, printf(">>>>>>>> Entering s:GPGDecrypt(%d)", a:bufread))
+
+ " get the filename of the current buffer
+ let filename = expand("<afile>:p")
+
+ " clear GPGRecipients and GPGOptions
+ if type(g:GPGDefaultRecipients) == type([])
+ let b:GPGRecipients = copy(g:GPGDefaultRecipients)
+ else
+ let b:GPGRecipients = []
+ echohl GPGWarning
+ echom "g:GPGDefaultRecipients is not a Vim list, please correct this in your vimrc!"
+ echohl None
+ endif
+ let b:GPGOptions = []
+
+ " file name minus extension
+ let autocmd_filename = fnameescape(expand('<afile>:r'))
+
+ " File doesn't exist yet, so nothing to decrypt
+ if !filereadable(filename)
+ " Allow the user to define actions for GnuPG buffers
+ silent doautocmd User GnuPG
+ " call the autocommand for the file minus .gpg$
+ silent execute ':doautocmd BufNewFile ' . autocmd_filename
+ call s:GPGDebug(2, 'called BufNewFile autocommand for ' . autocmd_filename)
+
+ " This is a new file, so force the user to edit the recipient list if
+ " they open a new file and public keys are preferred
+ if (g:GPGPreferSymmetric == 0)
+ call s:GPGEditRecipients()
+ endif
+
+ return
+ endif
+
+ " Only let this if the file actually exists, otherwise GPG functionality
+ " will be disabled when editing a buffer that doesn't yet have a backing
+ " file
+ let b:GPGEncrypted = 0
+
+ " find the recipients of the file
+ let cmd = { 'level': 3 }
+ let cmd.args = '--verbose --decrypt --list-only --dry-run --no-use-agent --logger-fd 1 ' . s:shellescape(filename)
+ let output = s:GPGSystem(cmd)
+
+ " Suppress the "N more lines" message when editing a file, not when reading
+ " the contents of a file into a buffer
+ let silent = a:bufread ? 'silent ' : ''
+
+ let asymmPattern = 'gpg: public key is ' . s:keyPattern
+ " check if the file is symmetric/asymmetric encrypted
+ if (match(output, "gpg: encrypted with [[:digit:]]\\+ passphrase") >= 0)
+ " file is symmetric encrypted
+ let b:GPGEncrypted = 1
+ call s:GPGDebug(1, "this file is symmetric encrypted")
+
+ let b:GPGOptions += ["symmetric"]
+
+ " find the used cipher algorithm
+ let cipher = substitute(output, ".*gpg: \\([^ ]\\+\\) encrypted data.*", "\\1", "")
+ if (match(s:GPGCipher, "\\<" . cipher . "\\>") >= 0)
+ let b:GPGOptions += ["cipher-algo " . cipher]
+ call s:GPGDebug(1, "cipher-algo is " . cipher)
+ else
+ echohl GPGWarning
+ echom "The cipher " . cipher . " is not known by the local gpg command. Using default!"
+ echo
+ echohl None
+ endif
+ elseif (match(output, asymmPattern) >= 0)
+ " file is asymmetric encrypted
+ let b:GPGEncrypted = 1
+ call s:GPGDebug(1, "this file is asymmetric encrypted")
+
+ let b:GPGOptions += ["encrypt"]
+
+ " find the used public keys
+ let start = match(output, asymmPattern)
+ while (start >= 0)
+ let start = start + strlen("gpg: public key is ")
+ let recipient = matchstr(output, s:keyPattern, start)
+ call s:GPGDebug(1, "recipient is " . recipient)
+ " In order to support anonymous communication, GnuPG allows eliding
+ " information in the encryption metadata specifying what keys the file
+ " was encrypted to (c.f., --throw-keyids and --hidden-recipient). In
+ " that case, the recipient(s) will be listed as having used a key of all
+ " zeroes.
+ " Since this will obviously never actually be in a keyring, only try to
+ " convert to an ID or add to the recipients list if it's not a hidden
+ " recipient.
+ if recipient !~? '^0x0\+$'
+ let name = s:GPGNameToID(recipient)
+ if !empty(name)
+ let b:GPGRecipients += [name]
+ call s:GPGDebug(1, "name of recipient is " . name)
+ else
+ let b:GPGRecipients += [recipient]
+ echohl GPGWarning
+ echom "The recipient \"" . recipient . "\" is not in your public keyring!"
+ echohl None
+ end
+ end
+ let start = match(output, asymmPattern, start)
+ endwhile
+ else
+ " file is not encrypted
+ let b:GPGEncrypted = 0
+ call s:GPGDebug(1, "this file is not encrypted")
+ echohl GPGWarning
+ echom "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ exe printf('%sr %s', silent, fnameescape(filename))
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGDecrypt()")
+ return
+ endif
+
+ if a:bufread
+ silent execute ':doautocmd BufReadPre ' . autocmd_filename
+ call s:GPGDebug(2, 'called BufReadPre autocommand for ' . autocmd_filename)
+ else
+ silent execute ':doautocmd FileReadPre ' . autocmd_filename
+ call s:GPGDebug(2, 'called FileReadPre autocommand for ' . autocmd_filename)
+ endif
+
+ " check if the message is armored
+ if (match(output, "gpg: armor header") >= 0)
+ call s:GPGDebug(1, "this file is armored")
+ let b:GPGOptions += ["armor"]
+ endif
+
+ " finally decrypt the buffer content
+ " since even with the --quiet option passphrase typos will be reported,
+ " we must redirect stderr (using shell temporarily)
+ call s:GPGDebug(1, "decrypting file")
+ let cmd = { 'level': 1, 'ex': silent . 'r !' }
+ let cmd.args = '--quiet --decrypt ' . s:shellescape(filename, 1)
+ call s:GPGExecute(cmd)
+
+ if (v:shell_error) " message could not be decrypted
+ echohl GPGError
+ let blackhole = input("Message could not be decrypted! (Press ENTER)")
+ echohl None
+ " Only wipeout the buffer if we were creating one to start with.
+ " FileReadCmd just reads the content into the existing buffer
+ if a:bufread
+ silent bwipeout!
+ endif
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGDecrypt()")
+ return
+ endif
+
+ if a:bufread
+ " In order to make :undo a no-op immediately after the buffer is read,
+ " we need to do this dance with 'undolevels'. Actually discarding the undo
+ " history requires performing a change after setting 'undolevels' to -1 and,
+ " luckily, we have one we need to do (delete the extra line from the :r
+ " command)
+ let levels = &undolevels
+ set undolevels=-1
+ " :lockmarks doesn't actually prevent '[,'] from being overwritten, so we
+ " need to manually set them ourselves instead
+ silent 1delete
+ 1mark [
+ $mark ]
+ let &undolevels = levels
+ let &readonly = filereadable(filename) && filewritable(filename) == 0
+ " call the autocommand for the file minus .gpg$
+ silent execute ':doautocmd BufReadPost ' . autocmd_filename
+ call s:GPGDebug(2, 'called BufReadPost autocommand for ' . autocmd_filename)
+ else
+ " call the autocommand for the file minus .gpg$
+ silent execute ':doautocmd FileReadPost ' . autocmd_filename
+ call s:GPGDebug(2, 'called FileReadPost autocommand for ' . autocmd_filename)
+ endif
+
+ " Allow the user to define actions for GnuPG buffers
+ silent doautocmd User GnuPG
+
+ " refresh screen
+ redraw!
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGDecrypt()")
+endfunction
+
+" Function: s:GPGEncrypt() {{{2
+"
+" encrypts the buffer to all previous recipients
+"
+function s:GPGEncrypt()
+ call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEncrypt()")
+
+ " FileWriteCmd is only called when a portion of a buffer is being written to
+ " disk. Since Vim always sets the '[,'] marks to the part of a buffer that
+ " is being written, that can be used to determine whether BufWriteCmd or
+ " FileWriteCmd triggered us.
+ if [line("'["), line("']")] == [1, line('$')]
+ let auType = 'BufWrite'
+ else
+ let auType = 'FileWrite'
+ endif
+
+ " file name minus extension
+ let autocmd_filename = fnameescape(expand('<afile>:r'))
+
+ silent exe ':doautocmd '. auType .'Pre '. autocmd_filename
+ call s:GPGDebug(2, 'called '. auType .'Pre autocommand for ' . autocmd_filename)
+
+ " store encoding and switch to a safe one
+ if (&fileencoding != &encoding)
+ let s:GPGEncoding = &encoding
+ let &encoding = &fileencoding
+ call s:GPGDebug(2, "encoding was \"" . s:GPGEncoding . "\", switched to \"" . &encoding . "\"")
+ else
+ let s:GPGEncoding = ""
+ call s:GPGDebug(2, "encoding and fileencoding are the same (\"" . &encoding . "\"), not switching")
+ endif
+
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGError
+ let blackhole = input("Message could not be encrypted! (Press ENTER)")
+ echohl None
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncrypt()")
+ return
+ endif
+
+ " initialize GPGOptions if not happened before
+ if (!exists("b:GPGOptions") || empty(b:GPGOptions))
+ let b:GPGOptions = []
+ if (exists("g:GPGPreferSymmetric") && g:GPGPreferSymmetric == 1)
+ let b:GPGOptions += ["symmetric"]
+ let b:GPGRecipients = []
+ else
+ let b:GPGOptions += ["encrypt"]
+ endif
+ if (exists("g:GPGPreferArmor") && g:GPGPreferArmor == 1)
+ let b:GPGOptions += ["armor"]
+ endif
+ if (exists("g:GPGPreferSign") && g:GPGPreferSign == 1)
+ let b:GPGOptions += ["sign"]
+ endif
+ call s:GPGDebug(1, "no options set, so using default options: " . string(b:GPGOptions))
+ endif
+
+ " built list of options
+ let options = ""
+ for option in b:GPGOptions
+ let options = options . " --" . option . " "
+ endfor
+
+ if (!exists('b:GPGRecipients'))
+ let b:GPGRecipients = []
+ endif
+
+ " check here again if all recipients are available in the keyring
+ let recipients = s:GPGCheckRecipients(b:GPGRecipients)
+
+ " check if there are unknown recipients and warn
+ if !empty(recipients.unknown)
+ echohl GPGWarning
+ echom "Please use GPGEditRecipients to correct!!"
+ echo
+ echohl None
+
+ " Let user know whats happend and copy known_recipients back to buffer
+ let dummy = input("Press ENTER to quit")
+ endif
+
+ " built list of recipients
+ let options .= ' ' . join(map(recipients.valid, '"-r ".v:val'), ' ')
+
+ " encrypt the buffer
+ let destfile = tempname()
+ let cmd = { 'level': 1, 'ex': "'[,']w !" }
+ let cmd.args = '--quiet --no-encrypt-to ' . options
+ let cmd.redirect = '>' . s:shellescape(destfile, 1)
+ silent call s:GPGExecute(cmd)
+
+ " restore encoding
+ if (s:GPGEncoding != "")
+ let &encoding = s:GPGEncoding
+ call s:GPGDebug(2, "restored encoding \"" . &encoding . "\"")
+ endif
+
+ if (v:shell_error) " message could not be encrypted
+ " Command failed, so clean up the tempfile
+ call delete(destfile)
+ echohl GPGError
+ let blackhole = input("Message could not be encrypted! (Press ENTER)")
+ echohl None
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncrypt()")
+ return
+ endif
+
+ let filename = resolve(expand('<afile>'))
+ if rename(destfile, filename)
+ " Rename failed, so clean up the tempfile
+ call delete(destfile)
+ echohl GPGError
+ echom printf("\"%s\" E212: Can't open file for writing", filename)
+ echohl None
+ return
+ endif
+
+ if auType == 'BufWrite'
+ setl nomodified
+ let &readonly = filereadable(filename) && filewritable(filename) == 0
+ endif
+
+ silent exe ':doautocmd '. auType .'Post '. autocmd_filename
+ call s:GPGDebug(2, 'called '. auType .'Post autocommand for ' . autocmd_filename)
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncrypt()")
+endfunction
+
+" Function: s:GPGViewRecipients() {{{2
+"
+" echo the recipients
+"
+function s:GPGViewRecipients()
+ call s:GPGDebug(3, ">>>>>>>> Entering s:GPGViewRecipients()")
+
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echom "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewRecipients()")
+ return
+ endif
+
+ let recipients = s:GPGCheckRecipients(b:GPGRecipients)
+
+ echo 'This file has following recipients (Unknown recipients have a prepended "!"):'
+ " echo the recipients
+ for name in recipients.valid
+ let name = s:GPGIDToName(name)
+ echo name
+ endfor
+
+ " echo the unknown recipients
+ echohl GPGWarning
+ for name in recipients.unknown
+ let name = "!" . name
+ echo name
+ endfor
+ echohl None
+
+ " check if there is any known recipient
+ if empty(recipients.valid)
+ echohl GPGError
+ echom 'There are no known recipients!'
+ echohl None
+ endif
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewRecipients()")
+endfunction
+
+" Function: s:GPGEditRecipients() {{{2
+"
+" create a scratch buffer with all recipients to add/remove recipients
+"
+function s:GPGEditRecipients()
+ call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEditRecipients()")
+
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echom "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditRecipients()")
+ return
+ endif
+
+ " only do this if it isn't already a GPGRecipients_* buffer
+ if (match(bufname("%"), "^\\(GPGRecipients_\\|GPGOptions_\\)") != 0 && match(bufname("%"), "\.\\(gpg\\|asc\\|pgp\\)$") >= 0)
+
+ " save buffer name
+ let buffername = bufname("%")
+ let editbuffername = "GPGRecipients_" . buffername
+
+ " check if this buffer exists
+ if (!bufexists(editbuffername))
+ " create scratch buffer
+ execute 'silent! split ' . fnameescape(editbuffername)
+
+ " add a autocommand to regenerate the recipients after a write
+ autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
+ else
+ if (bufwinnr(editbuffername) >= 0)
+ " switch to scratch buffer window
+ execute 'silent! ' . bufwinnr(editbuffername) . "wincmd w"
+ else
+ " split scratch buffer window
+ execute 'silent! sbuffer ' . fnameescape(editbuffername)
+
+ " add a autocommand to regenerate the recipients after a write
+ autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
+ endif
+
+ " empty the buffer
+ silent %delete
+ endif
+
+ " Mark the buffer as a scratch buffer
+ setlocal buftype=acwrite
+ setlocal bufhidden=hide
+ setlocal noswapfile
+ setlocal nowrap
+ setlocal nobuflisted
+ setlocal nonumber
+
+ " so we know for which other buffer this edit buffer is
+ let b:GPGCorrespondingTo = buffername
+
+ " put some comments to the scratch buffer
+ silent put ='GPG: ----------------------------------------------------------------------'
+ silent put ='GPG: Please edit the list of recipients, one recipient per line.'
+ silent put ='GPG: Unknown recipients have a prepended \"!\".'
+ silent put ='GPG: Lines beginning with \"GPG:\" are removed automatically.'
+ silent put ='GPG: Data after recipients between and including \"(\" and \")\" is ignored.'
+ silent put ='GPG: Closing this buffer commits changes.'
+ silent put ='GPG: ----------------------------------------------------------------------'
+
+ " get the recipients
+ let recipients = s:GPGCheckRecipients(getbufvar(b:GPGCorrespondingTo, "GPGRecipients"))
+
+ " if there are no known or unknown recipients, use the default ones
+ if (empty(recipients.valid) && empty(recipients.unknown))
+ if (type(g:GPGDefaultRecipients) == type([]))
+ let recipients = s:GPGCheckRecipients(g:GPGDefaultRecipients)
+ else
+ echohl GPGWarning
+ echom "g:GPGDefaultRecipients is not a Vim list, please correct this in your vimrc!"
+ echohl None
+ endif
+ endif
+
+ " put the recipients in the scratch buffer
+ for name in recipients.valid
+ let name = s:GPGIDToName(name)
+ silent put =name
+ endfor
+
+ " put the unknown recipients in the scratch buffer
+ let syntaxPattern = ''
+ if !empty(recipients.unknown)
+ let flaggedNames = map(recipients.unknown, '"!".v:val')
+ call append('$', flaggedNames)
+ let syntaxPattern = '\(' . join(flaggedNames, '\|') . '\)'
+ endif
+
+ for line in g:GPGPossibleRecipients
+ silent put ='GPG: '.line
+ endfor
+
+ " define highlight
+ if (has("syntax") && exists("g:syntax_on"))
+ highlight clear GPGUnknownRecipient
+ if !empty(syntaxPattern)
+ execute 'syntax match GPGUnknownRecipient "' . syntaxPattern . '"'
+ highlight link GPGUnknownRecipient GPGHighlightUnknownRecipient
+ endif
+
+ syntax match GPGComment "^GPG:.*$"
+ execute 'syntax match GPGComment "' . s:GPGMagicString . '.*$"'
+ highlight clear GPGComment
+ highlight link GPGComment Comment
+ endif
+
+ " delete the empty first line
+ silent 1delete
+
+ " jump to the first recipient
+ silent $
+
+ endif
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditRecipients()")
+endfunction
+
+" Function: s:GPGFinishRecipientsBuffer() {{{2
+"
+" create a new recipient list from RecipientsBuffer
+"
+function s:GPGFinishRecipientsBuffer()
+ call s:GPGDebug(3, ">>>>>>>> Entering s:GPGFinishRecipientsBuffer()")
+
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echom "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishRecipientsBuffer()")
+ return
+ endif
+
+ " go to buffer before doing work
+ if (bufnr("%") != expand("<abuf>"))
+ " switch to scratch buffer window
+ execute 'silent! ' . bufwinnr(expand("<afile>")) . "wincmd w"
+ endif
+
+ " delete the autocommand
+ autocmd! * <buffer>
+
+ " get the recipients from the scratch buffer
+ let recipients = []
+ let lines = getline(1,"$")
+ for recipient in lines
+ let matches = matchlist(recipient, '^\(.\{-}\)\%(' . s:GPGMagicString . '(ID:\s\+\(' . s:keyPattern . '\)\s\+.*\)\=$')
+
+ let recipient = matches[2] ? matches[2] : matches[1]
+
+ " delete all spaces at beginning and end of the recipient
+ " also delete a '!' at the beginning of the recipient
+ let recipient = substitute(recipient, "^[[:space:]!]*\\(.\\{-}\\)[[:space:]]*$", "\\1", "")
+
+ " delete comment lines
+ let recipient = substitute(recipient, "^GPG:.*$", "", "")
+
+ " only do this if the line is not empty
+ if !empty(recipient)
+ let gpgid = s:GPGNameToID(recipient)
+ if !empty(gpgid)
+ if (match(recipients, gpgid) < 0)
+ let recipients += [gpgid]
+ endif
+ else
+ if (match(recipients, recipient) < 0)
+ let recipients += [recipient]
+ echohl GPGWarning
+ echom "The recipient \"" . recipient . "\" is not in your public keyring!"
+ echohl None
+ endif
+ endif
+ endif
+ endfor
+
+ " write back the new recipient list to the corresponding buffer and mark it
+ " as modified. Buffer is now for sure an encrypted buffer.
+ call setbufvar(b:GPGCorrespondingTo, "GPGRecipients", recipients)
+ call setbufvar(b:GPGCorrespondingTo, "&mod", 1)
+ call setbufvar(b:GPGCorrespondingTo, "GPGEncrypted", 1)
+
+ " check if there is any known recipient
+ if empty(recipients)
+ echohl GPGError
+ echom 'There are no known recipients!'
+ echohl None
+ endif
+
+ " reset modified flag
+ setl nomodified
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishRecipientsBuffer()")
+endfunction
+
+" Function: s:GPGViewOptions() {{{2
+"
+" echo the recipients
+"
+function s:GPGViewOptions()
+ call s:GPGDebug(3, ">>>>>>>> Entering s:GPGViewOptions()")
+
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echom "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewOptions()")
+ return
+ endif
+
+ if (exists("b:GPGOptions"))
+ echo 'This file has following options:'
+ " echo the options
+ for option in b:GPGOptions
+ echo option
+ endfor
+ endif
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewOptions()")
+endfunction
+
+" Function: s:GPGEditOptions() {{{2
+"
+" create a scratch buffer with all recipients to add/remove recipients
+"
+function s:GPGEditOptions()
+ call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEditOptions()")
+
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echom "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditOptions()")
+ return
+ endif
+
+ " only do this if it isn't already a GPGOptions_* buffer
+ if (match(bufname("%"), "^\\(GPGRecipients_\\|GPGOptions_\\)") != 0 && match(bufname("%"), "\.\\(gpg\\|asc\\|pgp\\)$") >= 0)
+
+ " save buffer name
+ let buffername = bufname("%")
+ let editbuffername = "GPGOptions_" . buffername
+
+ " check if this buffer exists
+ if (!bufexists(editbuffername))
+ " create scratch buffer
+ execute 'silent! split ' . fnameescape(editbuffername)
+
+ " add a autocommand to regenerate the options after a write
+ autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer()
+ else
+ if (bufwinnr(editbuffername) >= 0)
+ " switch to scratch buffer window
+ execute 'silent! ' . bufwinnr(editbuffername) . "wincmd w"
+ else
+ " split scratch buffer window
+ execute 'silent! sbuffer ' . fnameescape(editbuffername)
+
+ " add a autocommand to regenerate the options after a write
+ autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer()
+ endif
+
+ " empty the buffer
+ silent %delete
+ endif
+
+ " Mark the buffer as a scratch buffer
+ setlocal buftype=nofile
+ setlocal noswapfile
+ setlocal nowrap
+ setlocal nobuflisted
+ setlocal nonumber
+
+ " so we know for which other buffer this edit buffer is
+ let b:GPGCorrespondingTo = buffername
+
+ " put some comments to the scratch buffer
+ silent put ='GPG: ----------------------------------------------------------------------'
+ silent put ='GPG: THERE IS NO CHECK OF THE ENTERED OPTIONS!'
+ silent put ='GPG: YOU NEED TO KNOW WHAT YOU ARE DOING!'
+ silent put ='GPG: IF IN DOUBT, QUICKLY EXIT USING :x OR :bd.'
+ silent put ='GPG: Please edit the list of options, one option per line.'
+ silent put ='GPG: Please refer to the gpg documentation for valid options.'
+ silent put ='GPG: Lines beginning with \"GPG:\" are removed automatically.'
+ silent put ='GPG: Closing this buffer commits changes.'
+ silent put ='GPG: ----------------------------------------------------------------------'
+
+ " put the options in the scratch buffer
+ let options = getbufvar(b:GPGCorrespondingTo, "GPGOptions")
+
+ for option in options
+ silent put =option
+ endfor
+
+ " delete the empty first line
+ silent 1delete
+
+ " jump to the first option
+ silent $
+
+ " define highlight
+ if (has("syntax") && exists("g:syntax_on"))
+ syntax match GPGComment "^GPG:.*$"
+ highlight clear GPGComment
+ highlight link GPGComment Comment
+ endif
+ endif
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditOptions()")
+endfunction
+
+" Function: s:GPGFinishOptionsBuffer() {{{2
+"
+" create a new option list from OptionsBuffer
+"
+function s:GPGFinishOptionsBuffer()
+ call s:GPGDebug(3, ">>>>>>>> Entering s:GPGFinishOptionsBuffer()")
+
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echom "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishOptionsBuffer()")
+ return
+ endif
+
+ " go to buffer before doing work
+ if (bufnr("%") != expand("<abuf>"))
+ " switch to scratch buffer window
+ execute 'silent! ' . bufwinnr(expand("<afile>")) . "wincmd w"
+ endif
+
+ " clear options and unknownOptions
+ let options = []
+ let unknownOptions = []
+
+ " delete the autocommand
+ autocmd! * <buffer>
+
+ " get the options from the scratch buffer
+ let lines = getline(1, "$")
+ for option in lines
+ " delete all spaces at beginning and end of the option
+ " also delete a '!' at the beginning of the option
+ let option = substitute(option, "^[[:space:]!]*\\(.\\{-}\\)[[:space:]]*$", "\\1", "")
+ " delete comment lines
+ let option = substitute(option, "^GPG:.*$", "", "")
+
+ " only do this if the line is not empty
+ if (!empty(option) && match(options, option) < 0)
+ let options += [option]
+ endif
+ endfor
+
+ " write back the new option list to the corresponding buffer and mark it
+ " as modified
+ call setbufvar(b:GPGCorrespondingTo, "GPGOptions", options)
+ call setbufvar(b:GPGCorrespondingTo, "&mod", 1)
+
+ " reset modified flag
+ setl nomodified
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishOptionsBuffer()")
+endfunction
+
+" Function: s:GPGCheckRecipients(tocheck) {{{2
+"
+" check if recipients are known
+" Returns: dictionary of recipients, {'valid': [], 'unknown': []}
+"
+function s:GPGCheckRecipients(tocheck)
+ call s:GPGDebug(3, ">>>>>>>> Entering s:GPGCheckRecipients()")
+
+ let recipients = {'valid': [], 'unknown': []}
+
+ if (type(a:tocheck) == type([]))
+ for recipient in a:tocheck
+ let gpgid = s:GPGNameToID(recipient)
+ if !empty(gpgid)
+ if (match(recipients.valid, gpgid) < 0)
+ call add(recipients.valid, gpgid)
+ endif
+ else
+ if (match(recipients.unknown, recipient) < 0)
+ call add(recipients.unknown, recipient)
+ echohl GPGWarning
+ echom "The recipient \"" . recipient . "\" is not in your public keyring!"
+ echohl None
+ endif
+ end
+ endfor
+ endif
+
+ call s:GPGDebug(2, "recipients are: " . string(recipients.valid))
+ call s:GPGDebug(2, "unknown recipients are: " . string(recipients.unknown))
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGCheckRecipients()")
+ return recipients
+endfunction
+
+" Function: s:GPGNameToID(name) {{{2
+"
+" find GPG key ID corresponding to a name
+" Returns: ID for the given name
+"
+function s:GPGNameToID(name)
+ call s:GPGDebug(3, ">>>>>>>> Entering s:GPGNameToID()")
+
+ " ask gpg for the id for a name
+ let cmd = { 'level': 2 }
+ let cmd.args = '--quiet --with-colons --fixed-list-mode --list-keys ' . s:shellescape(a:name)
+ let output = s:GPGSystem(cmd)
+
+ " when called with "--with-colons" gpg encodes its output _ALWAYS_ as UTF-8,
+ " so convert it, if necessary
+ if (&encoding != "utf-8")
+ let output = iconv(output, "utf-8", &encoding)
+ endif
+ let lines = split(output, "\n")
+
+ " parse the output of gpg
+ let pubseen = 0
+ let counter = 0
+ let gpgids = []
+ let seen_keys = {}
+ let skip_key = 0
+ let has_strftime = exists('*strftime')
+ let choices = "The name \"" . a:name . "\" is ambiguous. Please select the correct key:\n"
+ for line in lines
+
+ let fields = split(line, ":")
+
+ " search for the next pub
+ if (fields[0] == "pub")
+ " check if this key has already been processed
+ if has_key(seen_keys, fields[4])
+ let skip_key = 1
+ continue
+ endif
+ let skip_key = 0
+ let seen_keys[fields[4]] = 1
+
+ " Ignore keys which are not usable for encryption
+ if fields[11] !~? 'e'
+ continue
+ endif
+
+ let identity = fields[4]
+ let gpgids += [identity]
+ if has_strftime
+ let choices = choices . counter . ": ID: 0x" . identity . " created at " . strftime("%c", fields[5]) . "\n"
+ else
+ let choices = choices . counter . ": ID: 0x" . identity . "\n"
+ endif
+ let counter = counter+1
+ let pubseen = 1
+ " search for the next uid
+ elseif (!skip_key && fields[0] == "uid")
+ let choices = choices . " " . fields[9] . "\n"
+ endif
+
+ endfor
+
+ " counter > 1 means we have more than one results
+ let answer = 0
+ if (counter > 1)
+ let choices = choices . "Enter number: "
+ let answer = input(choices, "0")
+ while (answer == "")
+ let answer = input("Enter number: ", "0")
+ endwhile
+ endif
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGNameToID()")
+ return get(gpgids, answer, "")
+endfunction
+
+" Function: s:GPGIDToName(identity) {{{2
+"
+" find name corresponding to a GPG key ID
+" Returns: Name for the given ID
+"
+function s:GPGIDToName(identity)
+ call s:GPGDebug(3, ">>>>>>>> Entering s:GPGIDToName()")
+
+ " TODO is the encryption subkey really unique?
+
+ " ask gpg for the id for a name
+ let cmd = { 'level': 2 }
+ let cmd.args = '--quiet --with-colons --fixed-list-mode --list-keys ' . a:identity
+ let output = s:GPGSystem(cmd)
+
+ " when called with "--with-colons" gpg encodes its output _ALWAYS_ as UTF-8,
+ " so convert it, if necessary
+ if (&encoding != "utf-8")
+ let output = iconv(output, "utf-8", &encoding)
+ endif
+ let lines = split(output, "\n")
+
+ " parse the output of gpg
+ let pubseen = 0
+ let uid = ""
+ for line in lines
+ let fields = split(line, ":")
+
+ if !pubseen " search for the next pub
+ if (fields[0] == "pub")
+ " Ignore keys which are not usable for encryption
+ if fields[11] !~? 'e'
+ continue
+ endif
+
+ let pubseen = 1
+ endif
+ else " search for the next uid
+ if (fields[0] == "uid")
+ let pubseen = 0
+ if exists("*strftime")
+ let uid = fields[9] . s:GPGMagicString . "(ID: 0x" . a:identity . " created at " . strftime("%c", fields[5]) . ")"
+ else
+ let uid = fields[9] . s:GPGMagicString . "(ID: 0x" . a:identity . ")"
+ endif
+ break
+ endif
+ endif
+ endfor
+
+ call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGIDToName()")
+ return uid
+endfunction
+
+" Function: s:GPGPreCmd() {{{2
+"
+" Setup the environment for running the gpg command
+"
+function s:GPGPreCmd()
+ let &shellredir = s:shellredir
+ let &shell = s:shell
+ let &shelltemp = s:shelltemp
+ " Force C locale so GPG output is consistent
+ let s:messages = v:lang
+ language messages C
+endfunction
+
+
+" Function: s:GPGPostCmd() {{{2
+"
+" Restore the user's environment after running the gpg command
+"
+function s:GPGPostCmd()
+ let &shellredir = s:shellredirsave
+ let &shell = s:shellsave
+ let &shelltemp = s:shelltempsave
+ execute 'language messages' s:messages
+ " Workaround a bug in the interaction between console vim and
+ " pinentry-curses by forcing Vim to re-detect and setup its terminal
+ " settings
+ let &term = &term
+ silent doautocmd TermChanged
+endfunction
+
+" Function: s:GPGSystem(dict) {{{2
+"
+" run g:GPGCommand using system(), logging the commandline and output. This
+" uses temp files (regardless of how 'shelltemp' is set) to hold the output of
+" the command, so it must not be used for sensitive commands.
+" Recognized keys are:
+" level - Debug level at which the commandline and output will be logged
+" args - Arguments to be given to g:GPGCommand
+"
+" Returns: command output
+"
+function s:GPGSystem(dict)
+ let commandline = s:GPGCommand
+ if (!empty(g:GPGHomedir))
+ let commandline .= ' --homedir ' . s:shellescape(g:GPGHomedir)
+ endif
+ let commandline .= ' ' . a:dict.args
+ let commandline .= ' ' . s:stderrredirnull
+ call s:GPGDebug(a:dict.level, "command: ". commandline)
+
+ call s:GPGPreCmd()
+ let output = system(commandline)
+ call s:GPGPostCmd()
+
+ call s:GPGDebug(a:dict.level, "rc: ". v:shell_error)
+ call s:GPGDebug(a:dict.level, "output: ". output)
+ return output
+endfunction
+
+" Function: s:GPGExecute(dict) {{{2
+"
+" run g:GPGCommand using :execute, logging the commandline
+" Recognized keys are:
+" level - Debug level at which the commandline will be logged
+" args - Arguments to be given to g:GPGCommand
+" ex - Ex command which will be :executed
+" redirect - Shell redirect to use, if needed
+"
+function s:GPGExecute(dict)
+ let commandline = printf('%s%s', a:dict.ex, s:GPGCommand)
+ if (!empty(g:GPGHomedir))
+ let commandline .= ' --homedir ' . s:shellescape(g:GPGHomedir, 1)
+ endif
+ let commandline .= ' ' . a:dict.args
+ if (has_key(a:dict, 'redirect'))
+ let commandline .= ' ' . a:dict.redirect
+ endif
+ let commandline .= ' ' . s:stderrredirnull
+ call s:GPGDebug(a:dict.level, "command: " . commandline)
+
+ call s:GPGPreCmd()
+ execute commandline
+ call s:GPGPostCmd()
+
+ call s:GPGDebug(a:dict.level, "rc: ". v:shell_error)
+endfunction
+
+" Function: s:GPGDebug(level, text) {{{2
+"
+" output debug message, if this message has high enough importance
+" only define function if GPGDebugLevel set at all
+"
+function s:GPGDebug(level, text)
+ if exists("g:GPGDebugLevel") && g:GPGDebugLevel >= a:level
+ if exists("g:GPGDebugLog")
+ execute "redir >> " . g:GPGDebugLog
+ silent echom "GnuPG: " . a:text
+ redir END
+ else
+ echom "GnuPG: " . a:text
+ endif
+ endif
+endfunction
+
+" Section: Commands {{{1
+
+command! GPGViewRecipients call s:GPGViewRecipients()
+command! GPGEditRecipients call s:GPGEditRecipients()
+command! GPGViewOptions call s:GPGViewOptions()
+command! GPGEditOptions call s:GPGEditOptions()
+
+" Section: Menu {{{1
+
+if (has("menu"))
+ amenu <silent> Plugin.GnuPG.View\ Recipients :GPGViewRecipients<CR>
+ amenu <silent> Plugin.GnuPG.Edit\ Recipients :GPGEditRecipients<CR>
+ amenu <silent> Plugin.GnuPG.View\ Options :GPGViewOptions<CR>
+ amenu <silent> Plugin.GnuPG.Edit\ Options :GPGEditOptions<CR>
+endif
+
+" vim600: set foldmethod=marker foldlevel=0 :
--- /dev/null
+" matrix.vim - Don Yang (uguu.org)
+"
+" Matrix screensaver for VIM.
+"
+"Usage:
+" After loading the script, use :Matrix to start.
+" Press any key a few times to exit.
+"
+" You will need to edit s:mindelay and s:maxdelay below to match your
+" machine speed and window size.
+"
+"Known Issues:
+" Sometimes you need to press keys a few times to exit instead of just
+" once. Press and hold is another way to go... feels like getchar is
+" checking for keypress state instead of keystroke availability.
+"
+" If the window is too small, script will not run. If the window is
+" resized and become too small (less than 8 rows or 10 columns) after
+" the script started, script will abort and *buffers may be lost*, so
+" don't do that. Resizing the window to most other sizes will be fine.
+"
+" Doesn't work if multiple windows exist before script started. In
+" that case the script will abort with error message.
+"
+" If the current buffer is modified, some error messages will appear
+" before the script starts, and an extra window is left behind after
+" the script exits. Workaround: save your buffers first.
+"
+"Other Info:
+" Inspired by cmatrix...
+" Didn't feel inspired enough to start using pico/nano, of course ^_^;
+"
+" 05/13/08 - disable cursorline, cursorcolumn and spell
+" (thanks to Diederick Niehorster for the suggestion).
+" 12/21/06 - multiwindow support by S. Lockwood-Childs.
+" 10/03/05 - added silent! to cursor positioning code to stop drawing
+" numbers during animation (thanks to David Eggum for the
+" suggestion).
+" 10/02/05 - disable showmatch
+" 03/16/05 - make new buffer modifiable before running
+" 01/27/05 - added sleep to consume less CPU
+" removed frame counter
+" 01/26/05 - initial version
+
+
+" Speed range, must be positive. Lower delay = faster.
+let s:mindelay = 1
+let s:maxdelay = 5
+
+" Session file for preserving original window layout
+let s:session_file = tempname()
+
+
+function! s:Rand()
+ let b:seed = b:seed * 22695477 + 1
+ if b:seed < 0
+ return -b:seed
+ endif
+ return b:seed
+endfunction
+
+function! s:CreateObject(i)
+ while 1
+ let b:x{a:i} = s:Rand() % b:columns
+ if b:reserve{b:x{a:i}} > 4
+ break
+ endif
+ endwhile
+ let b:y{a:i} = 1
+ let b:t{a:i} = s:Rand() % b:s{b:x{a:i}}
+ let b:head{a:i} = s:Rand() % 4
+ let b:len{a:i} = s:Rand() % b:h + 3
+ let b:reserve{b:x{a:i}} = 1 - b:len{a:i}
+endfunction
+
+function! s:DrawObject(i)
+ let x = b:x{a:i} * 2 + 1
+ let y = b:y{a:i}
+
+ " Draw head
+ if y <= b:h
+ if b:head{a:i}
+ silent! exec 'norm! :' . y . nr2char(13) . x . '|R' . b:d[s:Rand()%b:dl] . '_' . nr2char(27)
+ if y > 1
+ silent! exec 'norm! kR' . ((s:Rand() % 2) ? '`' : ' ') . nr2char(27)
+ endif
+ else
+ let a = ((s:Rand() % 2) ? '`' : ' ') . nr2char(27)
+ silent! exec 'norm! :'. y . nr2char(13) . x . '|R' . b:d[s:Rand() % b:dl] . a
+ endif
+ else
+ if b:head{a:i} && y == b:h + 1
+ silent! exec 'norm! :' . b:h . nr2char(13) . (x + 1) . '|R' . ((s:Rand() % 2) ? '`' : ' ') . nr2char(27)
+ endif
+ endif
+
+ " Draw tail
+ let y = y - b:len{a:i}
+ if 1 <= y && y <= b:h
+ silent! exec 'norm! :'. y . nr2char(13) . x . '|R ' . nr2char(27)
+ endif
+ let b:reserve{b:x{a:i}} = y
+endfunction
+
+function! s:Animate()
+ let i = 0
+
+ while i < b:objcount
+ " Animate object
+ if b:t{i} <= 0
+ if b:y{i} - b:len{i} <= b:h
+ " Draw
+ call s:DrawObject(i)
+ let b:t{i} = b:s{b:x{i}}
+ let b:y{i} = b:y{i} + 1
+ else
+ " Regenerate
+ call s:CreateObject(i)
+ endif
+ endif
+
+ let b:t{i} = b:t{i} - 1
+ let i = i + 1
+ endwhile
+ redraw
+ if getchar(1)
+ let b:run = 0
+ endif
+ sleep 20m
+endfunction
+
+function! s:Reset()
+ " Clear screen
+ let b:w = winwidth(0)
+ let b:h = winheight(0)
+ exec 'norm! gg"_dG' . b:h . 'O' . nr2char(27) . 'gg'
+ redraw
+ if b:w < 10 || b:h < 8
+ let b:run = 0
+ return
+ endif
+
+ " Set number of columns. This is rounded down due to line wrapping
+ " at the last column if the screen width is even. So you end up
+ " seeing the cursor blinking a lot at the right side of the screen.
+ " Alternatively, ':set rl' before running the script to have it
+ " blink on the left side.
+ let b:columns = (b:w - 1) / 2
+
+ " Initialize columns.
+ let i = 0
+ while i < b:columns
+ " Set delay time. Each column gets the same delay time.
+ let b:s{i} = s:Rand() % (s:maxdelay - s:mindelay) + s:mindelay
+
+ " Unreserve column
+ let b:reserve{i} = b:h
+ let i = i + 1
+ endwhile
+
+ " Initialize objects
+ let b:objcount = b:columns - 2
+ let i = 0
+ while i < b:objcount
+ call s:CreateObject(i)
+ let i = i + 1
+ endwhile
+endfunction
+
+function! s:Init()
+ " Create new buffer and hide the existing buffers. Hiding the
+ " existing buffers without switching to a new buffer preserves
+ " undo history.
+ exec 'mksession! ' . s:session_file
+ let s:num_orig_win = winnr("$")
+
+ " move to top window, so created window will become window 1,
+ " then attempt to create new window
+ 1 wincmd w
+ silent! new
+
+ " check that there really is an additional window
+ if winnr("$") != s:num_orig_win + 1
+ return 1
+ endif
+ let s:newbuf = bufnr('%')
+
+ " close all but window 1, which is the new window
+ only
+
+ setl bh=delete bt=nofile ma nolist nonu noro noswf tw=0 nowrap
+
+ " Set GUI options
+ if has('gui')
+ let s:o_gcr = &gcr
+ let s:o_go = &go
+ set gcr=a:ver1-blinkon0 go=
+ endif
+ if has('cmdline_info')
+ let s:o_ru = &ru
+ let s:o_sc = &sc
+ set noru nosc
+ endif
+ if has('title')
+ let s:o_ts = &titlestring
+ exec 'set titlestring=\ '
+ endif
+ if v:version >= 700
+ let s:o_spell = &spell
+ let s:o_cul = &cul
+ let s:o_cuc = &cuc
+ set nospell nocul nocuc
+ endif
+ let s:o_ch = &ch
+ let s:o_ls = &ls
+ let s:o_lz = &lz
+ let s:o_siso = &siso
+ let s:o_sm = &sm
+ let s:o_smd = &smd
+ let s:o_so = &so
+ let s:o_ve = &ve
+ set ch=1 ls=0 lz nosm nosmd siso=0 so=0 ve=all
+
+ " Initialize PRNG
+ let b:seed = localtime()
+ let b:run = 1
+
+ " Clear screen and initialize objects
+ call s:Reset()
+
+ " Set colors. Output looks better if your color scheme has black
+ " background. I would rather not have the script change the
+ " current color scheme since there is no good way to restore them
+ " afterwards.
+ hi MatrixHidden ctermfg=Black ctermbg=Black guifg=#000000 guibg=#000000
+ hi MatrixNormal ctermfg=DarkGreen ctermbg=Black guifg=#008000 guibg=#000000
+ hi MatrixBold ctermfg=LightGreen ctermbg=Black guifg=#00ff00 guibg=#000000
+ hi MatrixHead ctermfg=White ctermbg=Black guifg=#ffffff guibg=#000000
+ sy match MatrixNormal /^.*/ contains=MatrixHidden
+ sy match MatrixHidden contained /.`/ contains=MatrixBold
+ sy match MatrixHidden contained /._/ contains=MatrixHead
+ sy match MatrixBold contained /.\(`\)\@=/
+ sy match MatrixHead contained /.\(_\)\@=/
+
+ " Create random char dictionary
+ let b:d = ''
+ let i = 33
+ while i < 127
+ if i != 95 && i != 96
+ let b:d = b:d . nr2char(i)
+ endif
+ let i = i + 1
+ endwhile
+ let b:dl = strlen(b:d)
+ return 0
+endfunction
+
+function! s:Cleanup()
+ " Restore options
+ if has('gui')
+ let &gcr = s:o_gcr
+ let &go = s:o_go
+ unlet s:o_gcr s:o_go
+ endif
+ if has('cmdline_info')
+ let &ru = s:o_ru
+ let &sc = s:o_sc
+ unlet s:o_ru s:o_sc
+ endif
+ if has('title')
+ let &titlestring = s:o_ts
+ unlet s:o_ts
+ endif
+ if v:version >= 700
+ let &spell = s:o_spell
+ let &cul = s:o_cul
+ let &cuc = s:o_cuc
+ unlet s:o_cul s:o_cuc
+ endif
+ let &ch = s:o_ch
+ let &ls = s:o_ls
+ let &lz = s:o_lz
+ let &siso = s:o_siso
+ let &sm = s:o_sm
+ let &smd = s:o_smd
+ let &so = s:o_so
+ let &ve = s:o_ve
+ unlet s:o_ch s:o_ls s:o_lz s:o_siso s:o_sm s:o_smd s:o_so s:o_ve
+
+ " Restore old buffers
+ exec 'source ' . s:session_file
+ exec 'bwipe ' . s:newbuf
+ unlet s:newbuf
+
+ " Clear keystroke
+ let c = getchar(0)
+endfunction
+
+function! Matrix()
+ if s:Init()
+ echohl ErrorMsg
+ echon 'Can not create window'
+ echohl None
+ return
+ endif
+
+ while b:run
+ if b:w != winwidth(0) || b:h != winheight(0)
+ call s:Reset()
+ else
+ call s:Animate()
+ endif
+ endwhile
+
+ call s:Cleanup()
+endfunction
+
+
+if !has('virtualedit') || !has('windows') || !has('syntax')
+ echohl ErrorMsg
+ echon 'Not enough features, need at least +virtualedit, +windows and +syntax'
+ echohl None
+else
+ command! Matrix call Matrix()
+endif
--- /dev/null
+" vim: set sw=4 sts=4 et ft=vim :
+" Script: securemodelines.vim
+" Version: 10d6c6b52fcdd12f3ba457126f66fee4ccceec04
+" Author: Ciaran McCreesh <ciaran.mccreesh at googlemail.com>
+" Homepage: http://github.com/ciaranm/securemodelines
+" Requires: Vim 7
+" License: Redistribute under the same terms as Vim itself
+" Purpose: A secure alternative to modelines
+
+if &compatible || v:version < 700 || exists('g:loaded_securemodelines')
+ finish
+endif
+let g:loaded_securemodelines = 1
+
+if (! exists("g:secure_modelines_allowed_items"))
+ let g:secure_modelines_allowed_items = [
+ \ "textwidth", "tw",
+ \ "softtabstop", "sts",
+ \ "tabstop", "ts",
+ \ "shiftwidth", "sw",
+ \ "expandtab", "et", "noexpandtab", "noet",
+ \ "filetype", "ft",
+ \ "foldmethod", "fdm",
+ \ "readonly", "ro", "noreadonly", "noro",
+ \ "rightleft", "rl", "norightleft", "norl",
+ \ "cindent", "cin", "nocindent", "nocin",
+ \ "smartindent", "si", "nosmartindent", "nosi",
+ \ "autoindent", "ai", "noautoindent", "noai",
+ \ "spell",
+ \ "spelllang"
+ \ ]
+endif
+
+if (! exists("g:secure_modelines_verbose"))
+ let g:secure_modelines_verbose = 0
+endif
+
+if (! exists("g:secure_modelines_modelines"))
+ let g:secure_modelines_modelines=5
+endif
+
+if (! exists("g:secure_modelines_leave_modeline"))
+ if &modeline
+ set nomodeline
+ if g:secure_modelines_verbose
+ echohl WarningMsg
+ echo "Forcibly disabling internal modelines for securemodelines.vim"
+ echohl None
+ endif
+ endif
+endif
+
+fun! <SID>IsInList(list, i) abort
+ for l:item in a:list
+ if a:i == l:item
+ return 1
+ endif
+ endfor
+ return 0
+endfun
+
+fun! <SID>DoOne(item) abort
+ let l:matches = matchlist(a:item, '^\([a-z]\+\)\%([-+^]\?=[a-zA-Z0-9_\-.]\+\)\?$')
+ if len(l:matches) > 0
+ if <SID>IsInList(g:secure_modelines_allowed_items, l:matches[1])
+ exec "setlocal " . a:item
+ elseif g:secure_modelines_verbose
+ echohl WarningMsg
+ echo "Ignoring '" . a:item . "' in modeline"
+ echohl None
+ endif
+ endif
+endfun
+
+fun! <SID>DoNoSetModeline(line) abort
+ for l:item in split(a:line, '[ \t:]')
+ call <SID>DoOne(l:item)
+ endfor
+endfun
+
+fun! <SID>DoSetModeline(line) abort
+ for l:item in split(a:line)
+ call <SID>DoOne(l:item)
+ endfor
+endfun
+
+fun! <SID>CheckVersion(op, ver) abort
+ if a:op == "="
+ return v:version != a:ver
+ elseif a:op == "<"
+ return v:version < a:ver
+ elseif a:op == ">"
+ return v:version >= a:ver
+ else
+ return 0
+ endif
+endfun
+
+fun! <SID>DoModeline(line) abort
+ let l:matches = matchlist(a:line, '\%(\S\@<!\%(vi\|vim\([<>=]\?\)\([0-9]\+\)\?\)\|\sex\):\s*\%(set\s\+\)\?\([^:]\+\):\S\@!')
+ if len(l:matches) > 0
+ let l:operator = ">"
+ if len(l:matches[1]) > 0
+ let l:operator = l:matches[1]
+ endif
+ if len(l:matches[2]) > 0
+ if <SID>CheckVersion(l:operator, l:matches[2]) ? 0 : 1
+ return
+ endif
+ endif
+ return <SID>DoSetModeline(l:matches[3])
+ endif
+
+ let l:matches = matchlist(a:line, '\%(\S\@<!\%(vi\|vim\([<>=]\?\)\([0-9]\+\)\?\)\|\sex\):\(.\+\)')
+ if len(l:matches) > 0
+ let l:operator = ">"
+ if len(l:matches[1]) > 0
+ let l:operator = l:matches[1]
+ endif
+ if len(l:matches[2]) > 0
+ if <SID>CheckVersion(l:operator, l:matches[2]) ? 0 : 1
+ return
+ endif
+ endif
+ return <SID>DoNoSetModeline(l:matches[3])
+ endif
+endfun
+
+fun! <SID>DoModelines() abort
+ if line("$") > g:secure_modelines_modelines
+ let l:lines={ }
+ call map(filter(getline(1, g:secure_modelines_modelines) +
+ \ getline(line("$") - g:secure_modelines_modelines, "$"),
+ \ 'v:val =~ ":"'), 'extend(l:lines, { v:val : 0 } )')
+ for l:line in keys(l:lines)
+ call <SID>DoModeline(l:line)
+ endfor
+ else
+ for l:line in getline(1, "$")
+ call <SID>DoModeline(l:line)
+ endfor
+ endif
+endfun
+
+fun! SecureModelines_DoModelines() abort
+ call <SID>DoModelines()
+endfun
+
+aug SecureModeLines
+ au!
+ au BufRead,StdinReadPost * :call <SID>DoModelines()
+aug END
+
--- /dev/null
+" Vim syntax file
+" Language: AsciiDoc
+" Author: Stuart Rackham <srackham@gmail.com> (inspired by Felix
+" Obenhuber's original asciidoc.vim script).
+" URL: http://www.methods.co.nz/asciidoc/
+" Licence: GPL (http://www.gnu.org)
+" Remarks: Vim 6 or greater
+" Limitations: See 'Appendix E: Vim Syntax Highlighter' in the AsciiDoc 'User
+" Guide'.
+
+if exists("b:current_syntax")
+ finish
+endif
+
+syn clear
+syn sync fromstart
+syn sync linebreaks=1
+
+" Run :help syn-priority to review syntax matching priority.
+syn keyword asciidocToDo TODO FIXME CHECK TEST XXX ZZZ DEPRECATED
+syn match asciidocBackslash /\\/
+syn region asciidocIdMarker start=/^\$Id:\s/ end=/\s\$$/
+syn match asciidocCallout /\\\@<!<\d\{1,2}>/
+syn match asciidocListBlockDelimiter /^--$/
+syn match asciidocLineBreak /[ \t]+$/
+syn match asciidocRuler /^'\{3,}$/
+syn match asciidocPagebreak /^<\{3,}$/
+syn match asciidocEntityRef /\\\@<!&[#a-zA-Z]\S\{-};/
+syn region asciidocLiteralParagraph start=/\(\%^\|\_^\n\)\@<=\s\+\S\+/ end=/\(^\(+\|--\)\?\s*$\)\@=/ contains=asciidocToDo
+syn match asciidocURL /\\\@<!\<\(http\|https\|ftp\|file\|irc\):\/\/[^| \t]*\(\w\|\/\)/
+syn match asciidocEmail /[\\.:]\@<!\(\<\|<\)\w\(\w\|[.-]\)*@\(\w\|[.-]\)*\w>\?[0-9A-Za-z_]\@!/
+syn match asciidocAttributeRef /\\\@<!{\w\(\w\|[-,+]\)*\([=!@#$%?:].*\)\?}/
+
+" As a damage control measure quoted patterns always terminate at a blank
+" line (see 'Limitations' above).
+syn match asciidocQuotedAttributeList /\\\@<!\[[a-zA-Z0-9_-][a-zA-Z0-9 _-]*\][+_'`#*]\@=/
+syn match asciidocQuotedSubscript /\\\@<!\~\S\_.\{-}\(\~\|\n\s*\n\)/ contains=asciidocEntityRef
+syn match asciidocQuotedSuperscript /\\\@<!\^\S\_.\{-}\(\^\|\n\s*\n\)/ contains=asciidocEntityRef
+
+syn match asciidocQuotedMonospaced /\(^\|[| \t([.,=\]]\)\@<=+\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(+\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+syn match asciidocQuotedMonospaced2 /\(^\|[| \t([.,=\]]\)\@<=`\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(`\([| \t)[\],.?!;:=]\|$\)\@=\)/
+syn match asciidocQuotedUnconstrainedMonospaced /[\\+]\@<!++\S\_.\{-}\(++\|\n\s*\n\)/ contains=asciidocEntityRef
+
+syn match asciidocQuotedEmphasized /\(^\|[| \t([.,=\]]\)\@<=_\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(_\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+syn match asciidocQuotedEmphasized2 /\(^\|[| \t([.,=\]]\)\@<='\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\('\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+syn match asciidocQuotedUnconstrainedEmphasized /\\\@<!__\S\_.\{-}\(__\|\n\s*\n\)/ contains=asciidocEntityRef
+
+syn match asciidocQuotedBold /\(^\|[| \t([.,=\]]\)\@<=\*\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(\*\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+syn match asciidocQuotedUnconstrainedBold /\\\@<!\*\*\S\_.\{-}\(\*\*\|\n\s*\n\)/ contains=asciidocEntityRef
+
+" Don't allow ` in single quoted (a kludge to stop confusion with `monospaced`).
+syn match asciidocQuotedSingleQuoted /\(^\|[| \t([.,=\]]\)\@<=`\([ )\n\t]\)\@!\([^`]\|\n\(\s*\n\)\@!\)\{-}[^` \t]\('\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+
+syn match asciidocQuotedDoubleQuoted /\(^\|[| \t([.,=\]]\)\@<=``\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(''\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+
+syn match asciidocDoubleDollarPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=\$\$..\{-}\(\$\$\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/
+syn match asciidocTriplePlusPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=+++..\{-}\(+++\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/
+
+syn match asciidocAdmonition /^\u\{3,15}:\(\s\+.*\)\@=/
+
+syn region asciidocTable_OLD start=/^\([`.']\d*[-~_]*\)\+[-~_]\+\d*$/ end=/^$/
+syn match asciidocBlockTitle /^\.[^. \t].*[^-~_]$/ contains=asciidocQuoted.*,asciidocAttributeRef
+syn match asciidocTitleUnderline /[-=~^+]\{2,}$/ transparent contained contains=NONE
+syn match asciidocOneLineTitle /^=\{1,5}\s\+\S.*$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash
+syn match asciidocTwoLineTitle /^[^. +/].*[^.]\n[-=~^+]\{2,}$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocTitleUnderline
+
+syn match asciidocAttributeList /^\[[^[ \t].*\]$/
+syn match asciidocQuoteBlockDelimiter /^_\{4,}$/
+syn match asciidocExampleBlockDelimiter /^=\{4,}$/
+syn match asciidocSidebarDelimiter /^*\{4,}$/
+
+" See http://vimdoc.sourceforge.net/htmldoc/usr_44.html for excluding region
+" contents from highlighting.
+syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?|/ containedin=asciidocTableBlock contained
+syn region asciidocTableBlock matchgroup=asciidocTableDelimiter start=/^|=\{3,}$/ end=/^|=\{3,}$/ keepend contains=ALL
+syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?!/ containedin=asciidocTableBlock contained
+syn region asciidocTableBlock2 matchgroup=asciidocTableDelimiter2 start=/^!=\{3,}$/ end=/^!=\{3,}$/ keepend contains=ALL
+
+syn match asciidocListContinuation /^+$/
+syn region asciidocLiteralBlock start=/^\.\{4,}$/ end=/^\.\{4,}$/ contains=asciidocCallout,asciidocToDo keepend
+syn region asciidocListingBlock start=/^-\{4,}$/ end=/^-\{4,}$/ contains=asciidocCallout,asciidocToDo keepend
+syn region asciidocCommentBlock start="^/\{4,}$" end="^/\{4,}$" contains=asciidocToDo
+syn region asciidocPassthroughBlock start="^+\{4,}$" end="^+\{4,}$"
+
+" Allowing leading \w characters in the filter delimiter is to accomodate
+" the pre version 8.2.7 syntax and may be removed in future releases.
+syn region asciidocFilterBlock start=/^\w*\~\{4,}$/ end=/^\w*\~\{4,}$/
+
+syn region asciidocMacroAttributes matchgroup=asciidocRefMacro start=/\\\@<!<<"\{-}\(\w\|-\|_\|:\|\.\)\+"\?,\?/ end=/\(>>\)\|^$/ contains=asciidocQuoted.* keepend
+syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{2}\(\w\|-\|_\|:\|\.\)\+,\?/ end=/\]\{2}/ keepend
+syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{3}\(\w\|-\|_\|:\|\.\)\+/ end=/\]\{3}/ keepend
+syn region asciidocMacroAttributes matchgroup=asciidocMacro start=/[\\0-9a-zA-Z]\@<!\w\(\w\|-\)*:\S\{-}\[/ skip=/\\\]/ end=/\]\|^$/ contains=asciidocQuoted.*,asciidocAttributeRef keepend
+" Highlight macro that starts with an attribute reference (a common idiom).
+syn region asciidocMacroAttributes matchgroup=asciidocMacro start=/\(\\\@<!{\w\(\w\|[-,+]\)*\([=!@#$%?:].*\)\?}\)\@<=\S\{-}\[/ skip=/\\\]/ end=/\]\|^$/ contains=asciidocQuoted.*,asciidocAttributeRef keepend
+syn region asciidocMacroAttributes matchgroup=asciidocIndexTerm start=/\\\@<!(\{2,3}/ end=/)\{2,3}/ contains=asciidocQuoted.*,asciidocAttributeRef keepend
+
+syn match asciidocCommentLine "^//\([^/].*\|\)$" contains=asciidocToDo
+
+syn region asciidocAttributeEntry start=/^:\w/ end=/:\(\s\|$\)/ oneline
+
+" Lists.
+syn match asciidocListBullet /^\s*\zs\(-\|\*\{1,5}\)\ze\s/
+syn match asciidocListNumber /^\s*\zs\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\ze\s\+/
+syn region asciidocListLabel start=/^\s*/ end=/\(:\{2,4}\|;;\)$/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocToDo keepend
+" DEPRECATED: Horizontal label.
+syn region asciidocHLabel start=/^\s*/ end=/\(::\|;;\)\(\s\+\|\\$\)/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes keepend
+" Starts with any of the above.
+syn region asciidocList start=/^\s*\(-\|\*\{1,5}\)\s/ start=/^\s*\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\s\+/ start=/.\+\(:\{2,4}\|;;\)$/ end=/\(^[=*]\{4,}$\)\@=/ end=/\(^+\?\s*$\)\@=/ contains=asciidocList.\+,asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocCommentLine,asciidocAttributeList,asciidocToDo
+
+highlight link asciidocAdmonition Special
+highlight link asciidocAnchorMacro Macro
+highlight link asciidocAttributeEntry Special
+highlight link asciidocAttributeList Special
+highlight link asciidocAttributeMacro Macro
+highlight link asciidocAttributeRef Special
+highlight link asciidocBackslash Special
+highlight link asciidocBlockTitle Title
+highlight link asciidocCallout Label
+highlight link asciidocCommentBlock Comment
+highlight link asciidocCommentLine Comment
+highlight link asciidocDoubleDollarPassthrough Special
+highlight link asciidocEmail Macro
+highlight link asciidocEntityRef Special
+highlight link asciidocExampleBlockDelimiter Type
+highlight link asciidocFilterBlock Type
+highlight link asciidocHLabel Label
+highlight link asciidocIdMarker Special
+highlight link asciidocIndexTerm Macro
+highlight link asciidocLineBreak Special
+highlight link asciidocListBlockDelimiter Label
+highlight link asciidocListBullet Label
+highlight link asciidocListContinuation Label
+highlight link asciidocListingBlock Identifier
+highlight link asciidocListLabel Label
+highlight link asciidocListNumber Label
+highlight link asciidocLiteralBlock Identifier
+highlight link asciidocLiteralParagraph Identifier
+highlight link asciidocMacroAttributes Label
+highlight link asciidocMacro Macro
+highlight link asciidocOneLineTitle Title
+highlight link asciidocPagebreak Type
+highlight link asciidocPassthroughBlock Identifier
+highlight link asciidocQuoteBlockDelimiter Type
+highlight link asciidocQuotedAttributeList Special
+highlight link asciidocQuotedBold Special
+highlight link asciidocQuotedDoubleQuoted Label
+highlight link asciidocQuotedEmphasized2 Type
+highlight link asciidocQuotedEmphasized Type
+highlight link asciidocQuotedMonospaced2 Identifier
+highlight link asciidocQuotedMonospaced Identifier
+highlight link asciidocQuotedSingleQuoted Label
+highlight link asciidocQuotedSubscript Type
+highlight link asciidocQuotedSuperscript Type
+highlight link asciidocQuotedUnconstrainedBold Special
+highlight link asciidocQuotedUnconstrainedEmphasized Type
+highlight link asciidocQuotedUnconstrainedMonospaced Identifier
+highlight link asciidocRefMacro Macro
+highlight link asciidocRuler Type
+highlight link asciidocSidebarDelimiter Type
+highlight link asciidocTableBlock2 NONE
+highlight link asciidocTableBlock NONE
+highlight link asciidocTableDelimiter2 Label
+highlight link asciidocTableDelimiter Label
+highlight link asciidocTable_OLD Type
+highlight link asciidocTablePrefix2 Label
+highlight link asciidocTablePrefix Label
+highlight link asciidocToDo Todo
+highlight link asciidocTriplePlusPassthrough Special
+highlight link asciidocTwoLineTitle Title
+highlight link asciidocURL Macro
+let b:current_syntax = "asciidoc"
+
+" vim: wrap et sw=2 sts=2:
--- /dev/null
+" Vim syntax file
+" Language: getmailrc - configuration file for getmail version 4
+" Maintainer: Nikolai Nespor <nikolai.nespor@utanet.at>
+" URL: http://www.unet.univie.ac.at/~a9600989/vim/getmailrc.vim
+" Last Change: 2005 02 22
+
+" 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
+
+" string, ints and comments
+syn match gmComment /#.*$/
+syn match gmInt /\<\d\+\>/
+syn region gmDbQuoteStr start=+"+ skip=+\\"+ end=+"+
+syn region gmQuoteStr start=+'+ skip=+\\'+ end=+'+
+
+" booleans are case insensitive
+syn case ignore
+ syn keyword gmTrue 1 true yes on
+ syn keyword gmFalse 0 false no off
+syn case match
+
+syn match gmParam /^\s*\w\+\s*=/ contains=gmKeywd
+syn match gmSection /^\s*\[\(retriever\|destination\|options\)\]\s*$/
+syn match gmFilterSec /^\s*\[filter-\w\+\]\s*$/
+
+syn keyword gmType type contained
+
+" retriever section
+"
+
+" retriever type
+syn match gmRetType /^\s*type\s*=\s*[a-zA-Z3]\+\s*$/ contains=gmRetTypes,gmType
+syn keyword gmRetTypes BrokenUIDLPOP3Retriver contained
+syn keyword gmRetTypes SimplePOP3Retriever SimpleIMAPRetriever contained
+syn keyword gmRetTypes SimplePOP3SSLRetriever SimpleIMAPSSLRetriever contained
+syn keyword gmRetTypes MultidropPOP3Retriever MultidropPOP3SSLRetriever contained
+syn keyword gmRetTypes MultidropSPDSRetriever MultidropIMAPRetriever contained
+syn keyword gmRetTypes MultidropIMAPSSLRetriever contained
+
+" common retriever options
+syn keyword gmKeywd password port server username contained
+" POP3
+syn keyword gmKeywd use_apop contained
+" IMAP
+syn keyword gmKeywd mailboxes move_on_delete contained
+" SSL
+syn keyword gmKeywd certfile keyfile contained
+" multidrop
+syn keyword gmKeywd envelope_recipient contained
+" timeout
+syn keyword gmKeywd timeout contained
+
+" destination section
+"
+
+" destination type
+syn match gmDestType /^\s*type\s*=\s*\(Maildir\|Mboxrd\|MDA_external\|MultiDestination\|MultiGuesser\|MultiSorter\|MDA_qmaillocal\)\s*$/ contains=gmDestTypes,gmType
+syn keyword gmDestTypes Maildir Mboxrd MDA_external MultiDestination contained
+syn keyword gmDestTypes MultiGuesser MultiSorter MDA_qmaillocal contained
+
+" Maildir, Mboxrd and MDA_external common options
+syn keyword gmKeywd path contained
+" MDA_external
+syn keyword gmKeywd allow_root_commands arguments group contained
+syn keyword gmKeywd unixfrom user contained
+" MultiSorter
+syn keyword gmKeywd default locals contained
+" MDA_qmaillocal plus allow_root_command, group and user from
+" MDA_external
+syn keyword gmKeywd conf-break defaultdelivery homedir contained
+syn keyword gmKeywd localdomain localpart_translate qmaillocal contained
+syn keyword gmKeywd strip_delivered_to contained
+
+" option section
+"
+syn keyword gmKeywd delete delete_after delivered_to contained
+syn keyword gmKeywd max_messages_per_session max_message_size contained
+syn keyword gmKeywd message_log message_log_syslog read_all received contained
+syn keyword gmKeywd verbose contained
+
+" filter section
+"
+
+" filter type
+syn match gmFilterType /^\s*type\s*=\s*\(Filter_classifier\|Filter_external\|Filter_TMDA\)\s*$/ contains=gmFilterTypes,gmType
+syn keyword gmFilterTypes Filter_classifier Filter_external Filter_TMDA contained
+
+" filter options
+syn keyword gmKeywd allow_root_commands arguments exitcodes_drop contained
+syn keyword gmKeywd exitcodes_keep group path unixfrom user contained
+
+" 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_getmail_syn_inits")
+ if version < 508
+ let did_getmail_syn_inits = 1
+ command -nargs=+ HiLink hi link <args>
+ else
+ command -nargs=+ HiLink hi def link <args>
+ endif
+ HiLink gmComment Comment
+ HiLink gmInt Identifier
+ HiLink gmDbQuoteStr String
+ HiLink gmQuoteStr String
+
+ HiLink gmTrue Identifier
+ HiLink gmFalse Constant
+
+ HiLink gmParam Normal
+ HiLink gmSection Statement
+ HiLink gmFilterSec Statement
+
+ HiLink gmKeywd Type
+ HiLink gmType Type
+
+ HiLink gmRetTypes PreProc
+ HiLink gmDestTypes PreProc
+ HiLink gmFilterTypes PreProc
+ delcommand HiLink
+endif
+
+let b:current_syntax = "getmail"
+
+" vim: ts=8
--- /dev/null
+" Vim syntax file
+" Language: msmtp rc files
+" Maintainer: Simon Ruderich <simon@ruderich.org>
+" Last Change: 2008-08-23
+" Filenames: msmtprc
+" Version: 0.1
+
+
+if version < 600
+ syntax clear
+elseif exists("b:current_syntax")
+ finish
+endif
+
+
+" Comments.
+syn match msmtpComment /#.*$/ contains=@Spell
+
+" General commands.
+syntax match msmtpOption /\<\(defaults\|account\|host\|port\|timeout\|protocol\|domain\)\>/
+" Authentication commands.
+syntax match msmtpOption /\<\(auth\|user\|password\|passwordeval\|ntlmdomain\)\>/
+" TLS commands.
+syntax match msmtpOption /\<\(tls\|tls_trust_file\|tls_crl_file\|tls_fingerprint\|tls_key_file\|tls_cert_file\|tls_certcheck\|tls_starttls\|tls_force_sslv3\|tls_min_dh_prime_bits\|tls_priorities\)\>/
+" Sendmail mode specific commands.
+syntax match msmtpOption /\<\(auto_from\|from\|maildomain\|dsn_notify\|dsn_return\|keepbcc\|logfile\|syslog\)\>/
+
+
+" Options which accept only an on/off value.
+syn match msmtpWrongOption /\<\(tls\|tls_certcheck\|tls_starttls\|tls_force_sslv3\|auto_from\|keepbcc\) \(on$\|off$\)\@!.*$/
+" Option port accepts numeric values.
+syn match msmtpWrongOption /\<port \(\d\+$\)\@!.*$/
+" Option timeout accepts off and numeric values.
+syn match msmtpWrongOption /\<timeout \(off$\|\d\+$\)\@!.*$/
+" Option protocol accepts smtp and lmtp.
+syn match msmtpWrongOption /\<protocol \(smtp$\|lmtp$\)\@!.*$/
+" Option auth accepts on, off and the method.
+syn match msmtpWrongOption /\<auth \(on$\|off$\|plain$\|cram-md5$\|digest-md5$\|scram-sha-1$\|gssapi$\|external$\|login$\|ntlm$\)\@!.*$/
+" Option auth accepts on, off and the facility.
+syn match msmtpWrongOption /\<syslog \(on$\|off$\|LOG_USER$\|LOG_MAIL$\|LOG_LOCAL\d$\)\@!.*$/
+
+" Marks all wrong option values as errors.
+syn match msmtpWrongOptionValue /\S* \zs.*$/ contained containedin=msmtpWrongOption
+
+" Mark the option part as a normal option.
+highlight default link msmtpWrongOption msmtpOption
+
+highlight default link msmtpComment Comment
+highlight default link msmtpOption Type
+highlight default link msmtpWrongOptionValue Error
+
+let b:current_syntax = "msmtp"
--- /dev/null
+" Vim syntax file
+" Language: Perl 5
+" Maintainer: Andy Lester <andy@petdance.com>
+" Homepage: http://github.com/petdance/vim-perl/tree/master
+" Bugs/requests: http://github.com/petdance/vim-perl/issues
+" Last Change: 2010-08-10
+" Contributors: Andy Lester <andy@petdance.com>
+" Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
+" Lukas Mai <l.mai.web.de>
+" Nick Hibma <nick@van-laarhoven.org>
+" Sonia Heimann <niania@netsurf.org>
+" and many others.
+"
+" Please download most recent version first before mailing
+" any comments.
+"
+" The following parameters are available for tuning the
+" perl syntax highlighting, with defaults given:
+"
+" unlet perl_include_pod
+" unlet perl_no_scope_in_variables
+" unlet perl_no_extended_vars
+" unlet perl_string_as_statement
+" unlet perl_no_sync_on_sub
+" unlet perl_no_sync_on_global_var
+" let perl_sync_dist = 100
+" unlet perl_fold
+" unlet perl_fold_blocks
+" let perl_nofold_packages = 1
+" let perl_nofold_subs = 1
+
+if exists("b:current_syntax")
+ finish
+endif
+
+
+" POD starts with ^=<word> and ends with ^=cut
+
+if exists("perl_include_pod")
+ " Include a while extra syntax file
+ syn include @Pod syntax/pod.vim
+ unlet b:current_syntax
+ if exists("perl_fold")
+ syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend fold
+ syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend fold
+ else
+ syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend
+ syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend
+ endif
+else
+ " Use only the bare minimum of rules
+ if exists("perl_fold")
+ syn region perlPOD start="^=[a-z]" end="^=cut" fold
+ else
+ syn region perlPOD start="^=[a-z]" end="^=cut"
+ endif
+endif
+
+
+syn cluster perlTop contains=TOP
+syn region perlGenericBlock matchgroup=perlGenericBlock start="{" end="}" contained transparent
+
+
+" All keywords
+"
+syn match perlConditional "\<\%(if\|elsif\|unless\|given\|when\|default\)\>"
+syn match perlConditional "\<else\>" nextgroup=perlElseIfError skipwhite skipnl skipempty
+syn match perlRepeat "\<\%(while\|for\%(each\)\=\|do\|until\|continue\)\>"
+syn match perlOperator "\<\%(defined\|undef\|eq\|ne\|[gl][et]\|cmp\|not\|and\|or\|xor\|not\|bless\|ref\|do\)\>"
+syn match perlControl "\<\%(BEGIN\|CHECK\|INIT\|END\|UNITCHECK\)\>"
+
+syn match perlStatementStorage "\<\%(my\|our\|local\|state\)\>"
+syn match perlStatementControl "\<\%(return\|last\|next\|redo\|goto\|break\)\>"
+syn match perlStatementScalar "\<\%(chom\=p\|chr\|crypt\|r\=index\|lc\%(first\)\=\|length\|ord\|pack\|sprintf\|substr\|uc\%(first\)\=\)\>"
+syn match perlStatementRegexp "\<\%(pos\|quotemeta\|split\|study\)\>"
+syn match perlStatementNumeric "\<\%(abs\|atan2\|cos\|exp\|hex\|int\|log\|oct\|rand\|sin\|sqrt\|srand\)\>"
+syn match perlStatementList "\<\%(splice\|unshift\|shift\|push\|pop\|join\|reverse\|grep\|map\|sort\|unpack\)\>"
+syn match perlStatementHash "\<\%(delete\|each\|exists\|keys\|values\)\>"
+syn match perlStatementIOfunc "\<\%(syscall\|dbmopen\|dbmclose\)\>"
+syn match perlStatementFiledesc "\<\%(binmode\|close\%(dir\)\=\|eof\|fileno\|getc\|lstat\|printf\=\|read\%(dir\|line\|pipe\)\|rewinddir\|say\|select\|stat\|tell\%(dir\)\=\|write\)\>" nextgroup=perlFiledescStatementNocomma skipwhite
+syn match perlStatementFiledesc "\<\%(fcntl\|flock\|ioctl\|open\%(dir\)\=\|read\|seek\%(dir\)\=\|sys\%(open\|read\|seek\|write\)\|truncate\)\>" nextgroup=perlFiledescStatementComma skipwhite
+syn match perlStatementVector "\<vec\>"
+syn match perlStatementFiles "\<\%(ch\%(dir\|mod\|own\|root\)\|glob\|link\|mkdir\|readlink\|rename\|rmdir\|symlink\|umask\|unlink\|utime\)\>"
+syn match perlStatementFiles "-[rwxoRWXOezsfdlpSbctugkTBMAC]\>"
+syn match perlStatementFlow "\<\%(caller\|die\|dump\|eval\|exit\|wantarray\)\>"
+syn match perlStatementInclude "\<require\>"
+syn match perlStatementInclude "\<\%(use\|no\)\s\+\%(\%(attributes\|attrs\|autouse\|parent\|base\|big\%(int\|num\|rat\)\|blib\|bytes\|charnames\|constant\|diagnostics\|encoding\%(::warnings\)\=\|feature\|fields\|filetest\|if\|integer\|less\|lib\|locale\|mro\|open\|ops\|overload\|re\|sigtrap\|sort\|strict\|subs\|threads\%(::shared\)\=\|utf8\|vars\|version\|vmsish\|warnings\%(::register\)\=\)\>\)\="
+syn match perlStatementProc "\<\%(alarm\|exec\|fork\|get\%(pgrp\|ppid\|priority\)\|kill\|pipe\|set\%(pgrp\|priority\)\|sleep\|system\|times\|wait\%(pid\)\=\)\>"
+syn match perlStatementSocket "\<\%(acept\|bind\|connect\|get\%(peername\|sock\%(name\|opt\)\)\|listen\|recv\|send\|setsockopt\|shutdown\|socket\%(pair\)\=\)\>"
+syn match perlStatementIPC "\<\%(msg\%(ctl\|get\|rcv\|snd\)\|sem\%(ctl\|get\|op\)\|shm\%(ctl\|get\|read\|write\)\)\>"
+syn match perlStatementNetwork "\<\%(\%(end\|[gs]et\)\%(host\|net\|proto\|serv\)ent\|get\%(\%(host\|net\)by\%(addr\|name\)\|protoby\%(name\|number\)\|servby\%(name\|port\)\)\)\>"
+syn match perlStatementPword "\<\%(get\%(pw\%(uid\|nam\)\|gr\%(gid\|nam\)\|login\)\)\|\%(end\|[gs]et\)\%(pw\|gr\)ent\>"
+syn match perlStatementTime "\<\%(gmtime\|localtime\|time\)\>"
+
+syn match perlStatementMisc "\<\%(warn\|formline\|reset\|scalar\|prototype\|lock\|tied\=\|untie\)\>"
+
+syn keyword perlTodo TODO TBD FIXME XXX NOTE contained
+
+syn region perlStatementIndirObjWrap matchgroup=perlStatementIndirObj start="\<\%(map\|grep\|sort\|print\|system\|exec\)\>\s*{" end="}" contains=@perlTop,perlGenericBlock
+
+syn match perlLabel "^\s*\h\w*\s*::\@!\%(\<v\d\+\s*:\)\@<!"
+
+" Perl Identifiers.
+"
+" Should be cleaned up to better handle identifiers in particular situations
+" (in hash keys for example)
+"
+" Plain identifiers: $foo, @foo, $#foo, %foo, &foo and dereferences $$foo, @$foo, etc.
+" We do not process complex things such as @{${"foo"}}. Too complicated, and
+" too slow. And what is after the -> is *not* considered as part of the
+" variable - there again, too complicated and too slow.
+
+" Special variables first ($^A, ...) and ($|, $', ...)
+syn match perlVarPlain "$^[ACDEFHILMNOPRSTVWX]\="
+syn match perlVarPlain "$[\\\"\[\]'&`+*.,;=%~!?@#$<>(-]"
+syn match perlVarPlain "%+"
+syn match perlVarPlain "$\%(0\|[1-9]\d*\)"
+" Same as above, but avoids confusion in $::foo (equivalent to $main::foo)
+syn match perlVarPlain "$::\@!"
+" These variables are not recognized within matches.
+syn match perlVarNotInMatches "$[|)]"
+" This variable is not recognized within matches delimited by m//.
+syn match perlVarSlash "$/"
+
+" And plain identifiers
+syn match perlPackageRef "[$@#%*&]\%(\%(::\|'\)\=\I\i*\%(\%(::\|'\)\I\i*\)*\)\=\%(::\|'\)\I"ms=s+1,me=e-1 contained
+
+" To not highlight packages in variables as a scope reference - i.e. in
+" $pack::var, pack:: is a scope, just set "perl_no_scope_in_variables"
+" If you don't want complex things like @{${"foo"}} to be processed,
+" just set the variable "perl_no_extended_vars"...
+
+if !exists("perl_no_scope_in_variables")
+ syn match perlVarPlain "\%([@$]\|\$#\)\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+ syn match perlVarPlain2 "%\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" contains=perlPackageRef
+ syn match perlFunctionName "&\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+else
+ syn match perlVarPlain "\%([@$]\|\$#\)\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+ syn match perlVarPlain2 "%\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)"
+ syn match perlFunctionName "&\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+endif
+
+if !exists("perl_no_extended_vars")
+ syn cluster perlExpr contains=perlStatementIndirObjWrap,perlStatementScalar,perlStatementRegexp,perlStatementNumeric,perlStatementList,perlStatementHash,perlStatementFiles,perlStatementTime,perlStatementMisc,perlVarPlain,perlVarPlain2,perlVarNotInMatches,perlVarSlash,perlVarBlock,perlVarBlock2,perlShellCommand,perlFloat,perlNumber,perlStringUnexpanded,perlString,perlQQ,perlArrow,perlGenericBlock
+ syn region perlArrow matchgroup=perlArrow start="->\s*(" end=")" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
+ syn region perlArrow matchgroup=perlArrow start="->\s*\[" end="\]" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
+ syn region perlArrow matchgroup=perlArrow start="->\s*{" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
+ syn match perlArrow "->\s*{\s*\I\i*\s*}" contains=perlVarSimpleMemberName nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
+ syn region perlArrow matchgroup=perlArrow start="->\s*\$*\I\i*\s*(" end=")" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
+ syn region perlVarBlock matchgroup=perlVarPlain start="\%($#\|[$@]\)\$*{" skip="\\}" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+ syn region perlVarBlock2 matchgroup=perlVarPlain start="[%&*]\$*{" skip="\\}" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+ syn match perlVarPlain2 "[%&*]\$*{\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+ syn match perlVarPlain "\%(\$#\|[@$]\)\$*{\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+ syn region perlVarMember matchgroup=perlVarPlain start="\%(->\)\={" skip="\\}" end="}" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+ syn match perlVarSimpleMember "\%(->\)\={\s*\I\i*\s*}" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contains=perlVarSimpleMemberName contained
+ syn match perlVarSimpleMemberName "\I\i*" contained
+ syn region perlVarMember matchgroup=perlVarPlain start="\%(->\)\=\[" skip="\\]" end="]" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+ syn match perlPackageConst "__PACKAGE__" nextgroup=perlMethod
+ syn match perlMethod "->\$*\I\i*" contained nextgroup=perlVarSimpleMember,perlVarMember,perlMethod
+endif
+
+" File Descriptors
+syn match perlFiledescRead "<\h\w*>"
+
+syn match perlFiledescStatementComma "(\=\s*\u\w*\s*,"me=e-1 transparent contained contains=perlFiledescStatement
+syn match perlFiledescStatementNocomma "(\=\s*\u\w*\s*[^, \t]"me=e-1 transparent contained contains=perlFiledescStatement
+
+syn match perlFiledescStatement "\u\w*" contained
+
+" Special characters in strings and matches
+syn match perlSpecialString "\\\%(\o\{1,3}\|x\%({\x\+}\|\x\{1,2}\)\|c.\|[^cx]\)" contained extend
+syn match perlSpecialStringU2 "\\." extend contained transparent contains=NONE
+syn match perlSpecialStringU "\\\\" contained
+syn match perlSpecialMatch "\\[1-9]" contained extend
+syn match perlSpecialMatch "\\g\%(\d\+\|{\%(-\=\d\+\|\h\w*\)}\)" contained
+syn match perlSpecialMatch "\\k\%(<\h\w*>\|'\h\w*'\)" contained
+syn match perlSpecialMatch "{\d\+\%(,\%(\d\+\)\=\)\=}" contained
+syn match perlSpecialMatch "\[[]-]\=[^\[\]]*[]-]\=\]" contained
+syn match perlSpecialMatch "[+*()?.]" contained
+syn match perlSpecialMatch "(?[#:=!]" contained
+syn match perlSpecialMatch "(?[impsx]*\%(-[imsx]\+\)\=)" contained
+syn match perlSpecialMatch "(?\%([-+]\=\d\+\|R\))" contained
+syn match perlSpecialMatch "(?\%(&\|P[>=]\)\h\w*)" contained
+syn match perlSpecialMatch "(\*\%(\%(PRUNE\|SKIP\|THEN\)\%(:[^)]*\)\=\|\%(MARK\|\):[^)]*\|COMMIT\|F\%(AIL\)\=\|ACCEPT\))" contained
+
+" Possible errors
+"
+" Highlight lines with only whitespace (only in blank delimited here documents) as errors
+syn match perlNotEmptyLine "^\s\+$" contained
+" Highlight "} else if (...) {", it should be "} else { if (...) { " or "} elsif (...) {"
+syn match perlElseIfError "\s\+if" contained
+syn keyword perlElseIfError elseif
+
+" Variable interpolation
+"
+" These items are interpolated inside "" strings and similar constructs.
+syn cluster perlInterpDQ contains=perlSpecialString,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBlock
+" These items are interpolated inside '' strings and similar constructs.
+syn cluster perlInterpSQ contains=perlSpecialStringU,perlSpecialStringU2
+" These items are interpolated inside m// matches and s/// substitutions.
+syn cluster perlInterpSlash contains=perlSpecialString,perlSpecialMatch,perlVarPlain,perlVarBlock
+" These items are interpolated inside m## matches and s### substitutions.
+syn cluster perlInterpMatch contains=@perlInterpSlash,perlVarSlash
+
+" Shell commands
+syn region perlShellCommand matchgroup=perlMatchStartEnd start="`" end="`" contains=@perlInterpDQ keepend
+
+" Constants
+"
+" Numbers
+syn match perlNumber "\<\%(0\%(x\x[[:xdigit:]_]*\|b[01][01_]*\|\o[0-7_]*\|\)\|[1-9][[:digit:]_]*\)\>"
+syn match perlFloat "\<\d[[:digit:]_]*[eE][\-+]\=\d\+"
+syn match perlFloat "\<\d[[:digit:]_]*\.[[:digit:]_]*\%([eE][\-+]\=\d\+\)\="
+syn match perlFloat "\.[[:digit:]_]\+\%([eE][\-+]\=\d\+\)\="
+
+syn match perlString "\<\%(v\d\+\%(\.\d\+\)*\|\d\+\%(\.\d\+\)\{2,}\)\>" contains=perlVStringV
+syn match perlVStringV "\<v" contained
+
+
+syn region perlParensSQ start=+(+ end=+)+ extend contained transparent contains=perlParensSQ,@perlInterpSQ keepend
+syn region perlBracketsSQ start=+\[+ end=+\]+ extend contained transparent contains=perlBracketsSQ,@perlInterpSQ keepend
+syn region perlBracesSQ start=+{+ end=+}+ extend contained transparent contains=perlBracesSQ,@perlInterpSQ keepend
+syn region perlAnglesSQ start=+<+ end=+>+ extend contained transparent contains=perlAnglesSQ,@perlInterpSQ keepend
+
+syn region perlParensDQ start=+(+ end=+)+ extend contained transparent contains=perlParensDQ,@perlInterpDQ keepend
+syn region perlBracketsDQ start=+\[+ end=+\]+ extend contained transparent contains=perlBracketsDQ,@perlInterpDQ keepend
+syn region perlBracesDQ start=+{+ end=+}+ extend contained transparent contains=perlBracesDQ,@perlInterpDQ keepend
+syn region perlAnglesDQ start=+<+ end=+>+ extend contained transparent contains=perlAnglesDQ,@perlInterpDQ keepend
+
+
+" Simple version of searches and matches
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\>\s*\z([^[:space:]'([{<#]\)+ end=+\z1[cgimopsx]*+ contains=@perlInterpMatch keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m#+ end=+#[cgimopsx]*+ contains=@perlInterpMatch keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*'+ end=+'[cgimopsx]*+ contains=@perlInterpSQ keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*/+ end=+/[cgimopsx]*+ contains=@perlInterpSlash keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*(+ end=+)[cgimopsx]*+ contains=@perlInterpMatch,perlParensDQ keepend
+
+" A special case for m{}, m<> and m[] which allows for comments and extra whitespace in the pattern
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*{+ end=+}[cgimopsx]*+ contains=@perlInterpMatch,perlComment,perlBracesDQ keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*<+ end=+>[cgimopsx]*+ contains=@perlInterpMatch,perlAnglesDQ keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*\[+ end=+\][cgimopsx]*+ contains=@perlInterpMatch,perlComment,perlBracketsDQ keepend
+
+" Below some hacks to recognise the // variant. This is virtually impossible to catch in all
+" cases as the / is used in so many other ways, but these should be the most obvious ones.
+syn region perlMatch matchgroup=perlMatchStartEnd start="\%([$@%&*]\@<!\%(\<split\|\<while\|\<if\|\<unless\|\.\.\|[-+*!~(\[{=]\)\s*\)\@<=/\%(/=\)\@!" start=+^/\%(/=\)\@!+ start=+\s\@<=/\%(/=\)\@![^[:space:][:digit:]$@%=]\@=\%(/\_s*\%([([{$@%&*[:digit:]"'`]\|\_s\w\|[[:upper:]_abd-fhjklnqrt-wyz]\)\)\@!+ skip=+\\/+ end=+/[cgimopsx]*+ contains=@perlInterpSlash
+
+
+" Substitutions
+" perlMatch is the first part, perlSubstitution* is the substitution part
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\>\s*\z([^[:space:]'([{<#]\)+ end=+\z1+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionGQQ keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*'+ end=+'+me=e-1 contains=@perlInterpSQ nextgroup=perlSubstitutionSQ keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*/+ end=+/+me=e-1 contains=@perlInterpSlash nextgroup=perlSubstitutionGQQ keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s#+ end=+#+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionGQQ keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*(+ end=+)+ contains=@perlInterpMatch,perlParensDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*<+ end=+>+ contains=@perlInterpMatch,perlAnglesDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*\[+ end=+\]+ contains=@perlInterpMatch,perlBracketsDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*{+ end=+}+ contains=@perlInterpMatch,perlBracesDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend
+syn region perlSubstitutionGQQ matchgroup=perlMatchStartEnd start=+\z([^[:space:]'([{<]\)+ end=+\z1[ecgimopsx]*+ keepend contained contains=@perlInterpDQ
+syn region perlSubstitutionGQQ matchgroup=perlMatchStartEnd start=+(+ end=+)[ecgimopsx]*+ contained contains=@perlInterpDQ,perlParensDQ keepend
+syn region perlSubstitutionGQQ matchgroup=perlMatchStartEnd start=+\[+ end=+\][ecgimopsx]*+ contained contains=@perlInterpDQ,perlBracketsDQ keepend
+syn region perlSubstitutionGQQ matchgroup=perlMatchStartEnd start=+{+ end=+}[ecgimopsx]*+ contained contains=@perlInterpDQ,perlBracesDQ keepend
+syn region perlSubstitutionGQQ matchgroup=perlMatchStartEnd start=+<+ end=+>[ecgimopsx]*+ contained contains=@perlInterpDQ,perlAnglesDQ keepend
+syn region perlSubstitutionSQ matchgroup=perlMatchStartEnd start=+'+ end=+'[ecgimopsx]*+ contained contains=@perlInterpSQ keepend
+
+" Translations
+" perlMatch is the first part, perlTranslation* is the second, translator part.
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\>\s*\z([^[:space:]([{<#]\)+ end=+\z1+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationGQ
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)#+ end=+#+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationGQ
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*\[+ end=+\]+ contains=@perlInterpSQ,perlBracketsSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*(+ end=+)+ contains=@perlInterpSQ,perlParensSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*<+ end=+>+ contains=@perlInterpSQ,perlAnglesSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
+syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*{+ end=+}+ contains=@perlInterpSQ,perlBracesSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
+syn region perlTranslationGQ matchgroup=perlMatchStartEnd start=+\z([^[:space:]([{<]\)+ end=+\z1[cds]*+ contained
+syn region perlTranslationGQ matchgroup=perlMatchStartEnd start=+(+ end=+)[cds]*+ contains=perlParensSQ contained
+syn region perlTranslationGQ matchgroup=perlMatchStartEnd start=+\[+ end=+\][cds]*+ contains=perlBracketsSQ contained
+syn region perlTranslationGQ matchgroup=perlMatchStartEnd start=+{+ end=+}[cds]*+ contains=perlBracesSQ contained
+syn region perlTranslationGQ matchgroup=perlMatchStartEnd start=+<+ end=+>[cds]*+ contains=perlAnglesSQ contained
+
+
+" Strings and q, qq, qw and qr expressions
+
+syn region perlStringUnexpanded matchgroup=perlStringStartEnd start="'" end="'" contains=@perlInterpSQ keepend
+syn region perlString matchgroup=perlStringStartEnd start=+"+ end=+"+ contains=@perlInterpDQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\>\s*\z([^[:space:]#([{<]\)+ end=+\z1+ contains=@perlInterpSQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q#+ end=+#+ contains=@perlInterpSQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*(+ end=+)+ contains=@perlInterpSQ,perlParensSQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*\[+ end=+\]+ contains=@perlInterpSQ,perlBracketsSQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*{+ end=+}+ contains=@perlInterpSQ,perlBracesSQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*<+ end=+>+ contains=@perlInterpSQ,perlAnglesSQ keepend
+
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\>\s*\z([^[:space:]#([{<]\)+ end=+\z1+ contains=@perlInterpDQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]#+ end=+#+ contains=@perlInterpDQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*(+ end=+)+ contains=@perlInterpDQ,perlParensDQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*\[+ end=+\]+ contains=@perlInterpDQ,perlBracketsDQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*{+ end=+}+ contains=@perlInterpDQ,perlBracesDQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*<+ end=+>+ contains=@perlInterpDQ,perlAnglesDQ keepend
+
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*\z([^[:space:]#([{<]\)+ end=+\z1+ contains=@perlInterpSQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw#+ end=+#+ contains=@perlInterpSQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*(+ end=+)+ contains=@perlInterpSQ,perlParensSQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*\[+ end=+\]+ contains=@perlInterpSQ,perlBracketsSQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*{+ end=+}+ contains=@perlInterpSQ,perlBracesSQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*<+ end=+>+ contains=@perlInterpSQ,perlAnglesSQ keepend
+
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\>\s*\z([^[:space:]#([{<'/]\)+ end=+\z1[imosx]*+ contains=@perlInterpMatch keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*/+ end=+/[imosx]*+ contains=@perlInterpSlash keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr#+ end=+#[imosx]*+ contains=@perlInterpMatch keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*'+ end=+'[imosx]*+ contains=@perlInterpSQ keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*(+ end=+)[imosx]*+ contains=@perlInterpMatch,perlParensDQ keepend
+
+" A special case for qr{}, qr<> and qr[] which allows for comments and extra whitespace in the pattern
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*{+ end=+}[imosx]*+ contains=@perlInterpMatch,perlBracesDQ,perlComment keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*<+ end=+>[imosx]*+ contains=@perlInterpMatch,perlAnglesDQ,perlComment keepend
+syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*\[+ end=+\][imosx]*+ contains=@perlInterpMatch,perlBracketsDQ,perlComment keepend
+
+" Constructs such as print <<EOF [...] EOF, 'here' documents
+"
+" XXX Any statements after the identifier are in perlString colour (i.e.
+" 'if $a' in 'print <<EOF if $a'). This is almost impossible to get right it
+" seems due to the 'auto-extending nature' of regions.
+if exists("perl_fold")
+ syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\).*+ end=+^\z1$+ contains=@perlInterpDQ fold
+ syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z([^\\"]*\%(\\.[^\\"]*\)*\)"+ end=+^\z1$+ contains=@perlInterpDQ fold
+ syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z([^\\']*\%(\\.[^\\']*\)*\)'+ end=+^\z1$+ contains=@perlInterpSQ fold
+ syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine fold
+ syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine fold
+ syn region perlAutoload matchgroup=perlStringStartEnd start=+<<\s*\(['"]\=\)\z(END_\%(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\z1$+ contains=ALL fold
+else
+ syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\)+ end=+^\z1$+ contains=@perlInterpDQ
+ syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z([^\\"]*\%(\\.[^\\"]*\)*\)"+ end=+^\z1$+ contains=@perlInterpDQ
+ syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z([^\\']*\%(\\.[^\\']*\)*\)'+ end=+^\z1$+ contains=@perlInterpSQ
+ syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine
+ syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine
+ syn region perlAutoload matchgroup=perlStringStartEnd start=+<<\s*\(['"]\=\)\z(END_\%(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\z1$+ contains=ALL
+endif
+
+
+" Class declarations
+"
+syn match perlPackageDecl "\<package\s\+\%(\h\|::\)\%(\w\|::\)*" contains=perlStatementPackage
+syn keyword perlStatementPackage package contained
+
+" Functions
+" sub [name] [(prototype)] {
+"
+syn match perlSubError "[^[:space:];{#]" contained
+if v:version == 701 && !has('patch221') " XXX I hope that's the right one
+ syn match perlSubAttributes ":" contained
+else
+ syn match perlSubAttributesCont "\h\w*\_s*\%(:\_s*\)\=" nextgroup=@perlSubAttrMaybe contained
+ syn region perlSubAttributesCont matchgroup=perlSubAttributesCont start="\h\w*(" end=")\_s*\%(:\_s*\)\=" nextgroup=@perlSubAttrMaybe contained contains=@perlInterpSQ,perlParensSQ
+ syn cluster perlSubAttrMaybe contains=perlSubAttributesCont,perlSubError
+ syn match perlSubAttributes "" contained nextgroup=perlSubError
+ syn match perlSubAttributes ":\_s*" contained nextgroup=@perlSubAttrMaybe
+endif
+syn match perlSubPrototypeError "(\%(\_s*\%(\%(\\\%([$@%&*]\|\[[$@%&*]\+\]\)\|[$&*]\|[@%]\%(\_s*)\)\@=\|;\%(\_s*[)$@%&*\\]\)\@=\|_\%(\_s*[);]\)\@=\)\_s*\)*\)\@>\zs\_[^)]\+" contained
+syn match perlSubPrototype +(\_[^)]*)\_s*\|+ nextgroup=perlSubAttributes contained contains=perlSubPrototypeError
+syn match perlSubName +\%(\h\|::\|'\w\)\%(\w\|::\|'\w\)*\_s*\|+ contained nextgroup=perlSubPrototype
+
+syn match perlFunction +\<sub\>\_s*+ nextgroup=perlSubName
+
+if !exists("perl_no_scope_in_variables")
+ syn match perlFunctionPRef "\h\w*::" contained
+ syn match perlFunctionName "\h\w*[^:]" contained
+else
+ syn match perlFunctionName "\h[[:alnum:]_:]*" contained
+endif
+
+" The => operator forces a bareword to the left of it to be interpreted as
+" a string
+syn match perlString "\I\@<!-\?\I\i*\%(\s*=>\)\@="
+
+" All other # are comments, except ^#!
+syn match perlComment "#.*" contains=perlTodo,@Spell
+syn match perlSharpBang "^#!.*"
+
+" Formats
+syn region perlFormat matchgroup=perlStatementIOFunc start="^\s*\<format\s\+\k\+\s*=\s*$"rs=s+6 end="^\s*\.\s*$" contains=perlFormatName,perlFormatField,perlVarPlain,perlVarPlain2
+syn match perlFormatName "format\s\+\k\+\s*="lc=7,me=e-1 contained
+syn match perlFormatField "[@^][|<>~]\+\%(\.\.\.\)\=" contained
+syn match perlFormatField "[@^]#[#.]*" contained
+syn match perlFormatField "@\*" contained
+syn match perlFormatField "@[^A-Za-z_|<>~#*]"me=e-1 contained
+syn match perlFormatField "@$" contained
+
+" __END__ and __DATA__ clauses
+if exists("perl_fold")
+ syntax region perlDATA start="^__\%(DATA\|END\)__$" skip="." end="." contains=perlPOD,@perlDATA fold
+else
+ syntax region perlDATA start="^__\%(DATA\|END\)__$" skip="." end="." contains=perlPOD,@perlDATA
+endif
+
+"
+" Folding
+
+if exists("perl_fold")
+ " Note: this bit must come before the actual highlighting of the "package"
+ " keyword, otherwise this will screw up Pod lines that match /^package/
+ if !exists("perl_nofold_packages")
+ syn region perlPackageFold start="^package \S\+;\s*\%(#.*\)\=$" end="^1;\=\s*\%(#.*\)\=$" end="\n\+package"me=s-1 transparent fold keepend
+ endif
+ if !exists("perl_nofold_subs")
+ syn region perlSubFold start="^\z(\s*\)\<sub\>.*[^};]$" end="^\z1}\s*\%(#.*\)\=$" transparent fold keepend
+ syn region perlSubFold start="^\z(\s*\)\<\%(BEGIN\|END\|CHECK\|INIT\|UNITCHECK\)\>.*[^};]$" end="^\z1}\s*$" transparent fold keepend
+ endif
+
+ if exists("perl_fold_blocks")
+ syn region perlBlockFold start="^\z(\s*\)\%(if\|elsif\|unless\|for\|while\|until\|given\)\s*(.*)\%(\s*{\)\=\s*\%(#.*\)\=$" start="^\z(\s*\)foreach\s*\%(\%(my\|our\)\=\s*\S\+\s*\)\=(.*)\%(\s*{\)\=\s*\%(#.*\)\=$" end="^\z1}\s*;\=\%(#.*\)\=$" transparent fold keepend
+ syn region perlBlockFold start="^\z(\s*\)\%(do\|else\)\%(\s*{\)\=\s*\%(#.*\)\=$" end="^\z1}\s*while" end="^\z1}\s*;\=\%(#.*\)\=$" transparent fold keepend
+ endif
+
+ setlocal foldmethod=syntax
+ syn sync fromstart
+else
+ " fromstart above seems to set minlines even if perl_fold is not set.
+ syn sync minlines=0
+endif
+
+command -nargs=+ HiLink hi def link <args>
+
+" The default highlighting.
+HiLink perlSharpBang PreProc
+HiLink perlControl PreProc
+HiLink perlInclude Include
+HiLink perlSpecial Special
+HiLink perlString String
+HiLink perlCharacter Character
+HiLink perlNumber Number
+HiLink perlFloat Float
+HiLink perlType Type
+HiLink perlIdentifier Identifier
+HiLink perlLabel Label
+HiLink perlStatement Statement
+HiLink perlConditional Conditional
+HiLink perlRepeat Repeat
+HiLink perlOperator Operator
+HiLink perlFunction Keyword
+HiLink perlSubName Function
+HiLink perlSubPrototype Type
+HiLink perlSubAttributes PreProc
+HiLink perlSubAttributesCont perlSubAttributes
+HiLink perlComment Comment
+HiLink perlTodo Todo
+if exists("perl_string_as_statement")
+ HiLink perlStringStartEnd perlStatement
+else
+ HiLink perlStringStartEnd perlString
+endif
+HiLink perlVStringV perlStringStartEnd
+HiLink perlList perlStatement
+HiLink perlMisc perlStatement
+HiLink perlVarPlain perlIdentifier
+HiLink perlVarPlain2 perlIdentifier
+HiLink perlArrow perlIdentifier
+HiLink perlFiledescRead perlIdentifier
+HiLink perlFiledescStatement perlIdentifier
+HiLink perlVarSimpleMember perlIdentifier
+HiLink perlVarSimpleMemberName perlString
+HiLink perlVarNotInMatches perlIdentifier
+HiLink perlVarSlash perlIdentifier
+HiLink perlQQ perlString
+HiLink perlHereDoc perlString
+HiLink perlStringUnexpanded perlString
+HiLink perlSubstitutionSQ perlString
+HiLink perlSubstitutionGQQ perlString
+HiLink perlTranslationGQ perlString
+HiLink perlMatch perlString
+HiLink perlMatchStartEnd perlStatement
+HiLink perlFormatName perlIdentifier
+HiLink perlFormatField perlString
+HiLink perlPackageDecl perlType
+HiLink perlStorageClass perlType
+HiLink perlPackageRef perlType
+HiLink perlStatementPackage perlStatement
+HiLink perlStatementStorage perlStatement
+HiLink perlStatementControl perlStatement
+HiLink perlStatementScalar perlStatement
+HiLink perlStatementRegexp perlStatement
+HiLink perlStatementNumeric perlStatement
+HiLink perlStatementList perlStatement
+HiLink perlStatementHash perlStatement
+HiLink perlStatementIOfunc perlStatement
+HiLink perlStatementFiledesc perlStatement
+HiLink perlStatementVector perlStatement
+HiLink perlStatementFiles perlStatement
+HiLink perlStatementFlow perlStatement
+HiLink perlStatementInclude perlStatement
+HiLink perlStatementProc perlStatement
+HiLink perlStatementSocket perlStatement
+HiLink perlStatementIPC perlStatement
+HiLink perlStatementNetwork perlStatement
+HiLink perlStatementPword perlStatement
+HiLink perlStatementTime perlStatement
+HiLink perlStatementMisc perlStatement
+HiLink perlStatementIndirObj perlStatement
+HiLink perlFunctionName perlIdentifier
+HiLink perlMethod perlIdentifier
+HiLink perlFunctionPRef perlType
+HiLink perlPOD perlComment
+HiLink perlShellCommand perlString
+HiLink perlSpecialAscii perlSpecial
+HiLink perlSpecialDollar perlSpecial
+HiLink perlSpecialString perlSpecial
+HiLink perlSpecialStringU perlSpecial
+HiLink perlSpecialMatch perlSpecial
+HiLink perlDATA perlComment
+
+" Possible errors
+HiLink perlNotEmptyLine Error
+HiLink perlElseIfError Error
+HiLink perlSubPrototypeError Error
+HiLink perlSubError Error
+
+delcommand HiLink
+
+" Syncing to speed up processing
+"
+if !exists("perl_no_sync_on_sub")
+ syn sync match perlSync grouphere NONE "^\s*\<package\s"
+ syn sync match perlSync grouphere NONE "^\s*\<sub\>"
+ syn sync match perlSync grouphere NONE "^}"
+endif
+
+if !exists("perl_no_sync_on_global_var")
+ syn sync match perlSync grouphere NONE "^$\I[[:alnum:]_:]+\s*=\s*{"
+ syn sync match perlSync grouphere NONE "^[@%]\I[[:alnum:]_:]+\s*=\s*("
+endif
+
+if exists("perl_sync_dist")
+ execute "syn sync maxlines=" . perl_sync_dist
+else
+ syn sync maxlines=100
+endif
+
+syn sync match perlSyncPOD grouphere perlPOD "^=pod"
+syn sync match perlSyncPOD grouphere perlPOD "^=head"
+syn sync match perlSyncPOD grouphere perlPOD "^=item"
+syn sync match perlSyncPOD grouphere NONE "^=cut"
+
+let b:current_syntax = "perl"
+
+" XXX Change to sts=4:sw=4
+" vim:ts=8:sts=2:sw=2:expandtab:ft=vim
--- /dev/null
+" Vim syntax file
+" Language: Python
+" Maintainer: Dmitry Vasiliev <dima@hlabs.spb.ru>
+" URL: http://www.hlabs.spb.ru/vim/python.vim
+" Last Change: 2010-04-09
+" Filenames: *.py
+" Version: 2.6.6
+"
+" Based on python.vim (from Vim 6.1 distribution)
+" by Neil Schemenauer <nas@python.ca>
+"
+" Thanks:
+"
+" Jeroen Ruigrok van der Werven
+" for the idea to highlight erroneous operators
+" Pedro Algarvio
+" for the patch to enable spell checking only for the right spots
+" (strings and comments)
+" John Eikenberry
+" for the patch fixing small typo
+" Caleb Adamantine
+" for the patch fixing highlighting for decorators
+" Andrea Riciputi
+" for the patch with new configuration options
+
+"
+" Options:
+"
+" For set option do: let OPTION_NAME = 1
+" For clear option do: let OPTION_NAME = 0
+"
+" Option names:
+"
+" For highlight builtin functions and objects:
+" python_highlight_builtins
+"
+" For highlight builtin objects:
+" python_highlight_builtin_objs
+"
+" For highlight builtin funtions:
+" python_highlight_builtin_funcs
+"
+" For highlight standard exceptions:
+" python_highlight_exceptions
+"
+" For highlight string formatting:
+" python_highlight_string_formatting
+"
+" For highlight str.format syntax:
+" python_highlight_string_format
+"
+" For highlight string.Template syntax:
+" python_highlight_string_templates
+"
+" For highlight indentation errors:
+" python_highlight_indent_errors
+"
+" For highlight trailing spaces:
+" python_highlight_space_errors
+"
+" For highlight doc-tests:
+" python_highlight_doctests
+"
+" If you want all Python highlightings above:
+" python_highlight_all
+" (This option not override previously set options)
+"
+" For fast machines:
+" python_slow_sync
+"
+" For "print" builtin as function:
+" python_print_as_function
+
+" 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
+
+if exists("python_highlight_all") && python_highlight_all != 0
+ " Not override previously set options
+ if !exists("python_highlight_builtins")
+ if !exists("python_highlight_builtin_objs")
+ let python_highlight_builtin_objs = 1
+ endif
+ if !exists("python_highlight_builtin_funcs")
+ let python_highlight_builtin_funcs = 1
+ endif
+ endif
+ if !exists("python_highlight_exceptions")
+ let python_highlight_exceptions = 1
+ endif
+ if !exists("python_highlight_string_formatting")
+ let python_highlight_string_formatting = 1
+ endif
+ if !exists("python_highlight_string_format")
+ let python_highlight_string_format = 1
+ endif
+ if !exists("python_highlight_string_templates")
+ let python_highlight_string_templates = 1
+ endif
+ if !exists("python_highlight_indent_errors")
+ let python_highlight_indent_errors = 1
+ endif
+ if !exists("python_highlight_space_errors")
+ let python_highlight_space_errors = 1
+ endif
+ if !exists("python_highlight_doctests")
+ let python_highlight_doctests = 1
+ endif
+endif
+
+" Keywords
+syn keyword pythonStatement break continue del
+syn keyword pythonStatement exec return
+syn keyword pythonStatement pass raise
+syn keyword pythonStatement global assert
+syn keyword pythonStatement lambda yield
+syn keyword pythonStatement with
+syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
+syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained
+syn keyword pythonRepeat for while
+syn keyword pythonConditional if elif else
+syn keyword pythonPreCondit import from as
+syn keyword pythonException try except finally
+syn keyword pythonOperator and in is not or
+
+if !exists("python_print_as_function") || python_print_as_function == 0
+ syn keyword pythonStatement print
+endif
+
+" Decorators (new in Python 2.4)
+syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhite
+syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained
+syn match pythonDot "\." display containedin=pythonDottedName
+
+" Comments
+syn match pythonComment "#.*$" display contains=pythonTodo,@Spell
+syn match pythonRun "\%^#!.*$"
+syn match pythonCoding "\%^.*\(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
+syn keyword pythonTodo TODO FIXME XXX contained
+
+" Errors
+syn match pythonError "\<\d\+\D\+\>" display
+syn match pythonError "[$?]" display
+syn match pythonError "[&|]\{2,}" display
+syn match pythonError "[=]\{3,}" display
+
+" TODO: Mixing spaces and tabs also may be used for pretty formatting multiline
+" statements. For now I don't know how to work around this.
+if exists("python_highlight_indent_errors") && python_highlight_indent_errors != 0
+ syn match pythonIndentError "^\s*\( \t\|\t \)\s*\S"me=e-1 display
+endif
+
+" Trailing space errors
+if exists("python_highlight_space_errors") && python_highlight_space_errors != 0
+ syn match pythonSpaceError "\s\+$" display
+endif
+
+" Strings
+syn region pythonString start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell
+syn region pythonString start=+[bB]\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell
+syn region pythonString start=+[bB]\="""+ end=+"""+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest2,pythonSpaceError,@Spell
+syn region pythonString start=+[bB]\='''+ end=+'''+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest,pythonSpaceError,@Spell
+
+syn match pythonEscape +\\[abfnrtv'"\\]+ display contained
+syn match pythonEscape "\\\o\o\=\o\=" display contained
+syn match pythonEscapeError "\\\o\{,2}[89]" display contained
+syn match pythonEscape "\\x\x\{2}" display contained
+syn match pythonEscapeError "\\x\x\=\X" display contained
+syn match pythonEscape "\\$"
+
+" Unicode strings
+syn region pythonUniString start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spell
+syn region pythonUniString start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spell
+syn region pythonUniString start=+[uU]"""+ end=+"""+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
+syn region pythonUniString start=+[uU]'''+ end=+'''+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
+
+syn match pythonUniEscape "\\u\x\{4}" display contained
+syn match pythonUniEscapeError "\\u\x\{,3}\X" display contained
+syn match pythonUniEscape "\\U\x\{8}" display contained
+syn match pythonUniEscapeError "\\U\x\{,7}\X" display contained
+syn match pythonUniEscape "\\N{[A-Z ]\+}" display contained
+syn match pythonUniEscapeError "\\N{[^A-Z ]\+}" display contained
+
+" Raw strings
+syn region pythonRawString start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell
+syn region pythonRawString start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell
+syn region pythonRawString start=+[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell
+syn region pythonRawString start=+[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell
+
+syn match pythonRawEscape +\\['"]+ display transparent contained
+
+" Unicode raw strings
+syn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
+syn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
+syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell
+syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell
+
+syn match pythonUniRawEscape "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained
+syn match pythonUniRawEscapeError "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained
+
+if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0
+ " String formatting
+ syn match pythonStrFormatting "%\(([^)]\+)\)\=[-#0 +]*\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+ syn match pythonStrFormatting "%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+endif
+
+if exists("python_highlight_string_format") && python_highlight_string_format != 0
+ " str.format syntax
+ syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+ syn match pythonStrFormat "{\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)\(\.[a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\|[^!:\}]\+\)\]\)*\(![rs]\)\=\(:\({\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)}\|\([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*\(\.\d\+\)\=[bcdeEfFgGnoxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+endif
+
+if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
+ " String templates
+ syn match pythonStrTemplate "\$\$" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+ syn match pythonStrTemplate "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+ syn match pythonStrTemplate "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+endif
+
+if exists("python_highlight_doctests") && python_highlight_doctests != 0
+ " DocTests
+ syn region pythonDocTest start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained
+ syn region pythonDocTest2 start="^\s*>>>" end=+"""+he=s-1 end="^\s*$" contained
+endif
+
+" Numbers (ints, longs, floats, complex)
+syn match pythonHexError "\<0[xX]\x*[g-zG-Z]\x*[lL]\=\>" display
+
+syn match pythonHexNumber "\<0[xX]\x\+[lL]\=\>" display
+syn match pythonOctNumber "\<0[oO]\o\+[lL]\=\>" display
+syn match pythonBinNumber "\<0[bB][01]\+[lL]\=\>" display
+
+syn match pythonNumber "\<\d\+[lLjJ]\=\>" display
+
+syn match pythonFloat "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" display
+syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display
+syn match pythonFloat "\<\d\+\.\d*\([eE][+-]\=\d\+\)\=[jJ]\=" display
+
+syn match pythonOctError "\<0[oO]\=\o*[8-9]\d*[lL]\=\>" display
+syn match pythonBinError "\<0[bB][01]*[2-9]\d*[lL]\=\>" display
+
+if exists("python_highlight_builtin_objs") && python_highlight_builtin_objs != 0
+ " Builtin objects and types
+ syn keyword pythonBuiltinObj True False Ellipsis None NotImplemented
+ syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__
+endif
+
+if exists("python_highlight_builtin_funcs") && python_highlight_builtin_funcs != 0
+ " Builtin functions
+ syn keyword pythonBuiltinFunc __import__ abs all any apply
+ syn keyword pythonBuiltinFunc basestring bin bool buffer bytearray bytes callable
+ syn keyword pythonBuiltinFunc chr classmethod cmp coerce compile complex
+ syn keyword pythonBuiltinFunc delattr dict dir divmod enumerate eval
+ syn keyword pythonBuiltinFunc execfile file filter float format frozenset getattr
+ syn keyword pythonBuiltinFunc globals hasattr hash help hex id
+ syn keyword pythonBuiltinFunc input int intern isinstance
+ syn keyword pythonBuiltinFunc issubclass iter len list locals long map max
+ syn keyword pythonBuiltinFunc min next object oct open ord
+ syn keyword pythonBuiltinFunc pow property range
+ syn keyword pythonBuiltinFunc raw_input reduce reload repr
+ syn keyword pythonBuiltinFunc reversed round set setattr
+ syn keyword pythonBuiltinFunc slice sorted staticmethod str sum super tuple
+ syn keyword pythonBuiltinFunc type unichr unicode vars xrange zip
+
+ if exists("python_print_as_function") && python_print_as_function != 0
+ syn keyword pythonBuiltinFunc print
+ endif
+endif
+
+if exists("python_highlight_exceptions") && python_highlight_exceptions != 0
+ " Builtin exceptions and warnings
+ syn keyword pythonExClass BaseException
+ syn keyword pythonExClass Exception StandardError ArithmeticError
+ syn keyword pythonExClass LookupError EnvironmentError
+
+ syn keyword pythonExClass AssertionError AttributeError BufferError EOFError
+ syn keyword pythonExClass FloatingPointError GeneratorExit IOError
+ syn keyword pythonExClass ImportError IndexError KeyError
+ syn keyword pythonExClass KeyboardInterrupt MemoryError NameError
+ syn keyword pythonExClass NotImplementedError OSError OverflowError
+ syn keyword pythonExClass ReferenceError RuntimeError StopIteration
+ syn keyword pythonExClass SyntaxError IndentationError TabError
+ syn keyword pythonExClass SystemError SystemExit TypeError
+ syn keyword pythonExClass UnboundLocalError UnicodeError
+ syn keyword pythonExClass UnicodeEncodeError UnicodeDecodeError
+ syn keyword pythonExClass UnicodeTranslateError ValueError VMSError
+ syn keyword pythonExClass WindowsError ZeroDivisionError
+
+ syn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarning
+ syn keyword pythonExClass PendingDepricationWarning SyntaxWarning
+ syn keyword pythonExClass RuntimeWarning FutureWarning
+ syn keyword pythonExClass ImportWarning UnicodeWarning
+endif
+
+if exists("python_slow_sync") && python_slow_sync != 0
+ syn sync minlines=2000
+else
+ " This is fast but code inside triple quoted strings screws it up. It
+ " is impossible to fix because the only way to know if you are inside a
+ " triple quoted string is to start from the beginning of the file.
+ syn sync match pythonSync grouphere NONE "):$"
+ syn sync maxlines=200
+endif
+
+if version >= 508 || !exists("did_python_syn_inits")
+ if version <= 508
+ let did_python_syn_inits = 1
+ command -nargs=+ HiLink hi link <args>
+ else
+ command -nargs=+ HiLink hi def link <args>
+ endif
+
+ HiLink pythonStatement Statement
+ HiLink pythonPreCondit Statement
+ HiLink pythonFunction Function
+ HiLink pythonConditional Conditional
+ HiLink pythonRepeat Repeat
+ HiLink pythonException Exception
+ HiLink pythonOperator Operator
+
+ HiLink pythonDecorator Define
+ HiLink pythonDottedName Function
+ HiLink pythonDot Normal
+
+ HiLink pythonComment Comment
+ HiLink pythonCoding Special
+ HiLink pythonRun Special
+ HiLink pythonTodo Todo
+
+ HiLink pythonError Error
+ HiLink pythonIndentError Error
+ HiLink pythonSpaceError Error
+
+ HiLink pythonString String
+ HiLink pythonUniString String
+ HiLink pythonRawString String
+ HiLink pythonUniRawString String
+
+ HiLink pythonEscape Special
+ HiLink pythonEscapeError Error
+ HiLink pythonUniEscape Special
+ HiLink pythonUniEscapeError Error
+ HiLink pythonUniRawEscape Special
+ HiLink pythonUniRawEscapeError Error
+
+ HiLink pythonStrFormatting Special
+ HiLink pythonStrFormat Special
+ HiLink pythonStrTemplate Special
+
+ HiLink pythonDocTest Special
+ HiLink pythonDocTest2 Special
+
+ HiLink pythonNumber Number
+ HiLink pythonHexNumber Number
+ HiLink pythonOctNumber Number
+ HiLink pythonBinNumber Number
+ HiLink pythonFloat Float
+ HiLink pythonOctError Error
+ HiLink pythonHexError Error
+ HiLink pythonBinError Error
+
+ HiLink pythonBuiltinObj Structure
+ HiLink pythonBuiltinFunc Function
+
+ HiLink pythonExClass Structure
+
+ delcommand HiLink
+endif
+
+let b:current_syntax = "python"
--- /dev/null
+" Vim syntax file
+" Language: tmux(1) configuration file
+" Maintainer: Tiago Cunha <me@tiagocunha.org>
+" Last Change: $Date: 2010/07/02 02:46:39 $
+" License: This file is placed in the public domain.
+
+if version < 600
+ syntax clear
+elseif exists("b:current_syntax")
+ finish
+endif
+
+setlocal iskeyword+=-
+syntax case match
+
+syn keyword tmuxAction any current none
+syn keyword tmuxBoolean off on
+
+syn keyword tmuxCmds detach[-client] ls list-sessions neww new-window
+syn keyword tmuxCmds bind[-key] unbind[-key] prev[ious-window] last[-window]
+syn keyword tmuxCmds lsk list-keys set[-option] renamew rename-window selectw
+syn keyword tmuxCmds select-window lsw list-windows attach[-session]
+syn keyword tmuxCmds send-prefix refresh[-client] killw kill-window lsc
+syn keyword tmuxCmds list-clients linkw link-window unlinkw unlink-window
+syn keyword tmuxCmds next[-window] send[-keys] swapw swap-window
+syn keyword tmuxCmds rename[-session] kill-session switchc switch-client
+syn keyword tmuxCmds has[-session] copy-mode pasteb paste-buffer
+syn keyword tmuxCmds new[-session] start[-server] kill-server setw
+syn keyword tmuxCmds set-window-option show[-options] showw show-window-options
+syn keyword tmuxCmds command-prompt setb set-buffer showb show-buffer lsb
+syn keyword tmuxCmds list-buffers deleteb delete-buffer lscm list-commands
+syn keyword tmuxCmds movew move-window respawnw respawn-window
+syn keyword tmuxCmds source[-file] info server-info clock-mode lock[-server]
+syn keyword tmuxCmds saveb save-buffer downp down-pane killp
+syn keyword tmuxCmds kill-pane resizep resize-pane selectp select-pane swapp
+syn keyword tmuxCmds swap-pane splitw split-window upp up-pane choose-session
+syn keyword tmuxCmds choose-window loadb load-buffer copyb copy-buffer suspendc
+syn keyword tmuxCmds suspend-client findw find-window breakp break-pane nextl
+syn keyword tmuxCmds next-layout rotatew rotate-window confirm[-before]
+syn keyword tmuxCmds clearhist clear-history selectl select-layout if[-shell]
+syn keyword tmuxCmds display[-message] setenv set-environment showenv
+syn keyword tmuxCmds show-environment choose-client displayp display-panes
+syn keyword tmuxCmds run[-shell] lockc lock-client locks lock-session lsp
+syn keyword tmuxCmds list-panes pipep pipe-pane showmsgs show-messages capturep
+syn keyword tmuxCmds capture-pane joinp join-pane choose-buffer
+
+syn keyword tmuxOptsSet prefix status status-fg status-bg bell-action
+syn keyword tmuxOptsSet default-command history-limit status-left status-right
+syn keyword tmuxOptsSet status-interval set-titles display-time buffer-limit
+syn keyword tmuxOptsSet status-left-length status-right-length message-fg
+syn keyword tmuxOptsSet message-bg lock-after-time default-path repeat-time
+syn keyword tmuxOptsSet message-attr status-attr status-keys set-remain-on-exit
+syn keyword tmuxOptsSet status-utf8 default-terminal visual-activity
+syn keyword tmuxOptsSet visual-bell visual-content status-justify
+syn keyword tmuxOptsSet terminal-overrides status-left-attr status-left-bg
+syn keyword tmuxOptsSet status-left-fg status-right-attr status-right-bg
+syn keyword tmuxOptsSet status-right-fg update-environment base-index
+syn keyword tmuxOptsSet display-panes-colour display-panes-time default-shell
+syn keyword tmuxOptsSet set-titles-string lock-command lock-server
+syn keyword tmuxOptsSet mouse-select-pane message-limit quiet escape-time
+syn keyword tmuxOptsSet pane-active-border-bg pane-active-border-fg
+syn keyword tmuxOptsSet pane-border-bg pane-border-fg
+syn keyword tmuxOptsSet display-panes-active-colour alternate-screen
+syn keyword tmuxOptsSet detach-on-destroy
+
+syn keyword tmuxOptsSetw monitor-activity aggressive-resize force-width
+syn keyword tmuxOptsSetw force-height remain-on-exit uft8 mode-fg mode-bg
+syn keyword tmuxOptsSetw mode-keys clock-mode-colour clock-mode-style
+syn keyword tmuxOptsSetw xterm-keys mode-attr window-status-attr
+syn keyword tmuxOptsSetw window-status-bg window-status-fg automatic-rename
+syn keyword tmuxOptsSetw main-pane-width main-pane-height monitor-content
+syn keyword tmuxOptsSetw window-status-current-attr window-status-current-bg
+syn keyword tmuxOptsSetw window-status-current-fg mode-mouse synchronize-panes
+syn keyword tmuxOptsSetw window-status-format window-status-current-format
+syn keyword tmuxOptsSetw word-separators
+
+syn keyword tmuxTodo FIXME NOTE TODO XXX contained
+
+syn match tmuxKey /\(C-\|M-\|\^\)\p/ display
+syn match tmuxNumber /\d\+/ display
+syn match tmuxOptions /\s-\a\+/ display
+syn match tmuxVariable /\w\+=/ display
+syn match tmuxVariableExpansion /\${\=\w\+}\=/ display
+
+syn region tmuxComment start=/#/ end=/$/ contains=tmuxTodo display oneline
+syn region tmuxString start=/"/ end=/"/ display oneline
+syn region tmuxString start=/'/ end=/'/ display oneline
+
+hi def link tmuxAction Boolean
+hi def link tmuxBoolean Boolean
+hi def link tmuxCmds Keyword
+hi def link tmuxComment Comment
+hi def link tmuxKey Special
+hi def link tmuxNumber Number
+hi def link tmuxOptions Identifier
+hi def link tmuxOptsSet Function
+hi def link tmuxOptsSetw Function
+hi def link tmuxString String
+hi def link tmuxTodo Todo
+hi def link tmuxVariable Constant
+hi def link tmuxVariableExpansion Constant
+
+let b:current_syntax = "tmux"
--- /dev/null
+" Vim syntax file
+" Language: VIMperator configuration file
+" Maintainer: Doug Kearns <dougkearns@gmail.com>
+" Latest Revision: 2008 August 19
+
+if exists("b:current_syntax")
+ finish
+endif
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+syn include @javascriptTop syntax/javascript.vim
+unlet b:current_syntax
+
+syn keyword vimperatorTodo FIXME NOTE TODO XXX contained
+syn match vimperatorComment +".*$+ contains=vimperatorTodo,@Spell
+
+syn region vimperatorString start="\z(["']\)" end="\z1" skip="\\\\\|\\\z1" oneline
+
+syn match vimperatorLineComment +^\s*".*$+ contains=vimperatorTodo,@Spell
+
+syn keyword vimperatorCommand ab[breviate] ab[clear] addo[ns] au[tocmd] b[uffer] ba[ck] bd[elete] beep bma[rk] bmarks buffers
+ \ bun[load] bw[ipeout] ca[bbrev] cabc[lear] cd cuna[bbrev] cm[ap] cmapc[lear] cno[remap] comc[lear] com[mand] cu[nmap]
+ \ delbm[arks] delc[ommand] delmac[ros] delm[arks] delqm[arks] dia[log] dl downl[oads] e[dit] ec[ho] echoe[rr] em[enu]
+ \ exe[cute] exu[sage] files fo[rward] fw h[elp] ha[rdcopy] hist[ory] hs ia[bbrev] iabc[lear] im[ap] imapc[lear] ino[remap]
+ \ iuna[bbrev] iu[nmap] javas[cript] ju[mps] js let ls macros ma[rk] map mapc[lear] marks mkv[imperatorrc] no[remap]
+ \ noh[lsearch] norm[al] o[pen] pa[geinfo] pagest[yle] pc[lose] pl[ay] pref[erences] prefs pwd q[uit] qa[ll] qma[rk] qmarks
+ \ quita[ll] re[draw] re[load] reloada[ll] res[tart] run sav[eas] sb[ar] sb[open] sbcl[ose] se[t] setg[lobal] setl[ocal]
+ \ sideb[ar] so[urce] st[op] tN[ext] t[open] tab tabd[uplicate] tabN[ext] tabc[lose] tabe[dit] tabfir[st] tabl[ast] tabm[ove]
+ \ tabn[ext] tabnew tabo[nly] tabopen tabp[revious] tabr[ewind] tabs time tn[ext] tp[revious] u[ndo] una[bbreviate] undoa[ll]
+ \ unl[et] unm[ap] ve[rsion] vie[wsource] viu[sage] w[rite] wc[lose] win[open] winc[lose] wine[dit] wo[pen] wqa[ll] wq xa[ll]
+ \ zo[om]
+ \ contained
+
+syn match vimperatorCommand "!" contained
+
+" FIXME
+syn match vimperatorCommandWrapper "\%(^\s*:\=\)\@<=\%(!\|\h\w*\>\)" contains=vimperatorCommand
+
+syn region vimperatorSet matchgroup=vimperatorCommand start="\%(^\s*:\=\)\@<=\<set\=\>" end="$" keepend oneline contains=vimperatorOption
+syn keyword vimperatorOption activate act activelinkfgcolor alfc activelinkbgcolor albc complete cpt defsearch ds editor
+ \ extendedhinttags eht focuscontent fc nofocuscontent nofc fullscreen fs nofullscreen nofs guioptions go hintmatching hm
+ \ hintstyle hs hinttags ht hinttimeout hto history hi hlsearch hls nohlsearch nohls hlsearchstyle hlss incsearch is
+ \ noincsearch nois ignorecase ic noignorecase noic insertmode im noinsertmode noim laststatus ls linkbgcolor lbc linkfgcolor
+ \ lfc linksearch lks nolinksearch nolks more newtab nextpattern nomore pageinfo pa popups pps preload nopreload previewheight
+ \ pvh previouspattern online noonline scroll scr shell sh shellcmdflag shcf showmode smd noshowmode nosmd showstatuslinks ssli
+ \ showtabline stal smartcase scs nosmartcase noscs suggestengines titlestring usermode um nousermode noum urlseparator verbose
+ \ vbs visualbell vb novisualbell novb visualbellstyle wildmode wim wildoptions wop wordseparators wsp
+ \ contained
+
+syn region vimperatorJavascript start="\%(^\s*\%(javascript\|js\)\s\+\)\@<=" end="$" contains=@javascriptTop keepend oneline
+syn region vimperatorJavascript matchgroup=vimperatorJavascriptDelimiter
+ \ start="\%(^\s*\%(javascript\|js\)\s\+\)\@<=<<\z(\h\w*\)"hs=s+2 end="^\z1$" contains=@javascriptTop fold
+
+syn region vimperatorMap matchgroup=vimperatorCommand start="\%(^\s*:\=\)\@<=\<map\>" end="$" keepend oneline contains=vimperatorKeySym
+
+syn match vimperatorKeySym "<[0-9A-Za-z-]\+>"
+
+" Note: match vim.vim highlighting groups
+hi def link vimperatorCommand Statement
+hi def link vimperatorComment Comment
+hi def link vimperatorJavascriptDelimiter Delimiter
+hi def link vimperatorKeySym Special
+hi def link vimperatorLineComment Comment
+hi def link vimperatorOption PreProc
+hi def link vimperatorString String
+hi def link vimperatorTodo Todo
+
+let b:current_syntax = "vimperator"
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
+" vim: tw=130 et ts=4 sw=4:
--- /dev/null
+" Vim main configuration file.
+
+" Copyright (C) 2008-2016 Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+
+" EDITOR SETTINGS
+
+" Save 'runtimepath' in case it was changed by the system's configuration
+" files. Also save 'diff' as set all& resets it; but somehow later (after
+" sourcing the vimrc - for example in a VimEnter autocmd) it gets
+" automagically restored to the correct value. Not sure what exactly Vim is
+" doing there.
+if has('eval')
+ let s:save_runtimepath = &runtimepath
+ let s:save_diff = &diff
+endif
+" Reset all options (except 'term', 'lines' and 'columns'). This makes sure a
+" system wide configuration file doesn't change default values.
+set all&
+" And restore it after all other options were reset.
+if has('eval')
+ let &runtimepath = s:save_runtimepath
+ let &diff = s:save_diff
+ unlet s:save_runtimepath
+ unlet s:save_diff
+endif
+
+" Make sure Vim (and not Vi) settings are used.
+set nocompatible
+
+" Disallow :autocmd, shell and write commands in .vimrc and .exrc files in the
+" current directory. Only used if 'exrc' is enabled (off by default),
+" precaution just in case somebody enables 'exrc'.
+set secure
+
+" Try to use pipes instead of temporary files. Prevents some auto commands
+" from running for temporary files but also prevents the file's content to be
+" written to disk.
+set noshelltemp
+
+" Use UTF-8 for all internal data (buffers, registers, etc.). This doesn't
+" affect reading files in different encodings, see 'fileencodings' for that.
+set encoding=utf-8
+
+" Load my scripts from ~/.vim (my scripts) and ~/.vim/runtime (checkout of Vim
+" runtime files) if available.
+set runtimepath-=~/.vim
+set runtimepath^=~/.vim,~/.vim/runtime
+
+" Don't store swap files in the same directory as the edited file, but only if
+" we have a "safe" writable directory available.
+if filewritable('~/.tmp') == 2 || filewritable('~/tmp') == 2
+ set directory-=.
+endif
+" But store them in ~/.tmp or ~/tmp (already set by default) if available.
+set directory^=~/.tmp
+" Never use /tmp which gets cleaned on reboot.
+set directory-=/tmp
+
+" Disable modelines as they may cause security problems. Instead use
+" securemodelines (Vim script #1876).
+set nomodeline
+
+" Complete to longest common string (list:longest) and then complete all full
+" matches after another (full). Thanks to pbrisbin
+" (http://pbrisbin.com:8080/dotfiles/vimrc).
+set wildmode=list:longest,full
+" Ignore case when completing files/directories.
+if exists('+wildignorecase')
+ set wildignorecase
+endif
+
+" Ignore files with the following extensions because I almost never want to
+" edit them in Vim (specifying them manually still works of course).
+set wildignore=
+" C
+set wildignore+=*.o,*.d,*.so
+" Java
+set wildignore+=*.class
+" LaTeX
+set wildignore+=*.aux,*.log,*.out,*.toc,*.pdf
+" Python
+set wildignore+=*.pyc
+
+" Show completion menu even if only one entry matches.
+if exists('+completeopt')
+ set completeopt+=menuone
+endif
+
+" Increase history of executed commands (:) and search patterns (/).
+set history=1000
+
+" Increase number of possible undos.
+set undolevels=1000
+
+" Remember marks (including the last cursor position) for more files. ^= is
+" necessary because 'viminfo' is parsed from the beginning and the first match
+" is used.
+if has('viminfo')
+ set viminfo^='1000
+endif
+
+" Use strong encryption if possible, also used for swap/undo files.
+if exists('+cryptmethod')
+ set cryptmethod=blowfish
+endif
+
+" Clear all vimrc-related autocmds. Has to be done here as the vimrc augroup
+" is used multiple times. Necessary to support reloading the vimrc.
+if has('autocmd')
+ augroup vimrc
+ autocmd!
+ augroup END
+endif
+
+
+" HELPER FUNCTIONS
+
+if has('eval')
+" Check if the given syntax group is available. Thanks to bairui in #vim on
+" Freenode (2012-02-19 01:15 CET) for the try/catch silent highlight idea.
+ function! s:HasSyntaxGroup(group)
+ try
+ execute 'silent highlight ' . a:group
+ " \a = [A-Za-z]
+ catch /^Vim\%((\a\+)\)\=:E411/ " 'highlight group not found'
+ return 0
+ endtry
+ return 1
+ endfunction
+
+" Check if the given Vim version and patch is available.
+ function! s:HasVersionAndPatch(version, patch)
+ return v:version > a:version
+ \ || (v:version == a:version && has('patch' . a:patch))
+ endfunction
+endif
+
+
+" TERMINAL SETTINGS
+
+" Also enable fast terminal mode in GNU screen and tmux, but not for SSH
+" connections.
+if &term =~# '^screen' && !exists('$SSH_CONNECTION')
+ set ttyfast
+endif
+
+
+" EDIT SETTINGS
+
+" Enable automatic file detection, plugin and indention support.
+if has('autocmd')
+ filetype off " necessary for pathogen to force a reload of ftplugins
+ filetype plugin indent on
+endif
+
+" Use UTF-8 file encoding for all files. Automatically recognize latin1 in
+" existing files.
+set fileencodings=utf-8,latin1
+
+" Always use unix line-endings for new files. DOS line endings in existing
+" files are recognized.
+set fileformats=unix,dos
+
+" Wrap text after 78 characters.
+set textwidth=78
+
+" Set tabs to 4 spaces, use softtabs.
+set shiftwidth=4
+set softtabstop=4
+set expandtab
+" When < and > is used indent/deindent to the next 'shiftwidth' boundary.
+set shiftround
+" Use the default value for real tabs.
+set tabstop=8
+
+" Enable auto indention.
+set autoindent
+
+" When joining lines only add one space after a sentence.
+set nojoinspaces
+
+" Allow backspacing over autoindent and line breaks.
+set backspace=indent,eol
+
+" Start a comment when hitting enter after a commented line (r) and when using
+" o or O around a commented line (o).
+set formatoptions+=ro
+" Don't break a line if was already longer then 'textwidth' when insert mode
+" started.
+set formatoptions+=l
+" Remove comment leader when joining lines where it makes sense.
+if s:HasVersionAndPatch(703, 541)
+ set formatoptions+=j
+endif
+
+" Allow virtual editing (cursor can be positioned anywhere, even when there is
+" no character) in visual block mode.
+set virtualedit=block
+
+" Already display matches while typing the search command. This makes spotting
+" typos easy and searching faster.
+set incsearch
+
+" Activate syntax folding.
+if has('folding')
+ set foldmethod=syntax
+ " Only use fold column if we have enough space (for example not in a
+ " (virtual) terminal which has only 80 columns).
+ if &columns > 80
+ set foldcolumn=2
+ endif
+ set foldlevel=99 " no closed folds at default, 'foldenable' would disable
+ " folding which is not what I want
+ " Don't open folds for block movements like '(', '{', '[[', '[{', etc.
+ set foldopen-=block
+endif
+
+" Only check case if the searched word contains a capital character.
+set ignorecase
+set smartcase
+
+" Activate spell checking, use English as default.
+if exists('+spell') && has('syntax')
+ " But not when diffing because spell checking is distracting in this case.
+ if !&diff
+ set spell
+ endif
+ set spelllang=en_us
+endif
+
+" Allow buffers with changes to be hidden. Very important for efficient
+" editing with multiple buffers. Prevents the "E37: No write since last change
+" (add ! to override)" warning when switching modified buffers.
+set hidden
+
+" When splitting vertically put the new window right of the current one.
+if has('vertsplit')
+ set splitright
+endif
+
+
+" DISPLAY SETTINGS
+
+" Use a dark background. Doesn't change the background color, only sets text
+" colors for a dark terminal.
+set background=dark
+
+" Use my color scheme if 256 colors are available.
+if &t_Co == 256 || has('gui_running')
+ colorscheme simon
+endif
+
+" Display line numbers.
+set number
+" But use as little space as possible for the numbers column. Thanks to James
+" Vega (http://git.jamessan.com/?p=etc/vim.git;a=summary).
+if exists('+numberwidth')
+ set numberwidth=1
+endif
+" Display the ruler with current line/file position. If 'statusline' is used,
+" then this only affects <C-G>.
+set ruler
+" Display partial commands in the status line.
+set showcmd
+
+" Don't redraw screen when executing macros; increases speed. Thanks to James
+" Vega (http://git.jamessan.com/?p=etc/vim.git;a=summary).
+set lazyredraw
+
+" Visualize the line the cursor is currently in.
+if exists('+cursorline')
+ set cursorline
+endif
+
+" Highlight all matches on the screen when searching. Use <C-L> (see below) to
+" remove the highlighting until the next search.
+set hlsearch
+
+" Display some special characters.
+set list
+set listchars=
+" Display tabs as ">--------".
+set listchars+=tab:>-
+" Display trailing whitespace as "-".
+set listchars+=trail:-
+" Display markers for long lines when wrapping is disabled.
+set listchars+=extends:>,precedes:<
+" Display non-breakable space as "!".
+if v:version >= 700
+ set listchars+=nbsp:!
+endif
+
+" Don't draw the vertical split separator by using space as character. Thanks
+" to scp1 in #vim on Freenode (2012-06-16 16:12 CEST) for the idea to use a
+" non-breakable space. But a simple space works as well, as long as the
+" current color scheme is not reset.
+if has('windows') && has('folding')
+ set fillchars+=vert:\ " comment to prevent trailing whitespace
+endif
+
+if has('statusline')
+ " Always display the status line even if there is only one window.
+ set laststatus=2
+
+ " If there's more than one buffer return "/<nr>" (e.g. "/05") where <nr>
+ " is the highest buffer number, otherwise return nothing. Used in
+ " 'statusline' to get an overview of available buffer numbers.
+ function! s:StatuslineBufferCount()
+ let l:bufnr = bufnr('$')
+ if l:bufnr > 1
+ let l:result = '/'
+ if exists('*printf')
+ let l:result .= printf('%02d', l:bufnr)
+ else
+ " Older Vims don't have printf() (and no .= either). Emulate
+ " "%02d".
+ if l:bufnr < 10
+ let l:result = l:result . '0'
+ endif
+ let l:result = l:result . l:bufnr
+ endif
+ return l:result
+ else
+ return ''
+ endif
+ endfunction
+
+ " Like %f but use relative filename if it's shorter than the absolute path
+ " (e.g. '../../file' vs. '~/long/path/to/file'). fnamemodify()'s ':.' is
+ " not enough because it doesn't create '../'s.
+ function! s:StatuslineRelativeFilename()
+ " Display only filename for help files.
+ if &buftype == 'help'
+ return expand('%:t')
+ endif
+ " Special case for scratch files.
+ if &buftype == 'nofile'
+ return '[Scratch]'
+ endif
+
+ let l:path = expand('%')
+ " No file.
+ if l:path == ''
+ return '[No Name]'
+ endif
+ " Path is already relative, nothing to do.
+ if stridx(l:path, '/') != 0
+ return l:path
+ endif
+
+ " Absolute path to this file.
+ let l:path = expand('%:p')
+ " Shortened path to this file, thanks to bairui in #vim on Freenode
+ " (2012-06-23 00:54) for the tip to use fnamemodify(). This is what
+ " Vim normally uses as %f (minus some exceptions).
+ let l:original_path = fnamemodify(l:path, ':~')
+ " Absolute path to the current working directory.
+ let l:cwd = getcwd()
+
+ " Working directory completely contained in path, replace it with a
+ " relative path. Happens for example when opening a file with netrw.
+ " %f displays this as absolute path, but we want a relative path of
+ " course.
+ if stridx(l:path, l:cwd) == 0
+ return strpart(l:path, strlen(l:cwd) + 1)
+ endif
+
+ let l:path_list = split(l:path, '/')
+ let l:cwd_list = split(l:cwd, '/')
+
+ " Remove the common path.
+ while l:path_list[0] == l:cwd_list[0]
+ call remove(l:path_list, 0)
+ call remove(l:cwd_list, 0)
+ endwhile
+
+ " Add as many '..' as necessary for the relative path and join the
+ " path. Thanks to Raimondi in #vim on Freenode (2012-06-23 01:13) for
+ " the hint to use repeat() instead of a loop.
+ let l:path = repeat('../', len(l:cwd_list)) . join(l:path_list, '/')
+
+ " Use the shorter path, either relative or absolute.
+ if strlen(l:path) < strlen(l:original_path)
+ return l:path
+ else
+ return l:original_path
+ endif
+ endfunction
+
+ " Display unexpected 'fileformat', 'fileencoding' and 'bomb' settings.
+ function! s:StatuslineFileFormat()
+ if &fileformat != 'unix'
+ return '[' . &fileformat . ']'
+ else
+ return ''
+ endif
+ endfunction
+ function! s:StatuslineFileEncoding()
+ if &fileencoding != '' && &fileencoding != 'utf-8'
+ \ && &filetype != 'help'
+ return '[' . &fileencoding . ']'
+ else
+ return ''
+ endif
+ endfunction
+ function! s:StatuslineFileBOMB()
+ if exists('+bomb') && &bomb
+ return '[BOM]'
+ else
+ return ''
+ endif
+ endfunction
+
+ " Return current syntax group in brackets or nothing if there's none.
+ function! s:StatuslineSyntaxGroup()
+ let l:group = synIDattr(synID(line('.'), col('.'), 1), 'name')
+ if l:group != ''
+ return '[' . l:group . '] '
+ else
+ return ''
+ endif
+ endfunction
+
+ " Short function names to make 'statusline' more readable.
+ function! SBC()
+ return s:StatuslineBufferCount()
+ endfunction
+ function! SRF()
+ return s:StatuslineRelativeFilename()
+ endfunction
+ function! SFF()
+ return s:StatuslineFileFormat()
+ endfunction
+ function! SFE()
+ return s:StatuslineFileEncoding()
+ endfunction
+ function! SFB()
+ return s:StatuslineFileBOMB()
+ endfunction
+ function! SSG()
+ return s:StatuslineSyntaxGroup()
+ endfunction
+
+ set statusline=
+ " on the left
+ set statusline+=%02n " buffer number
+ set statusline+=%{SBC()} " highest buffer number
+ set statusline+=:
+ if has('modify_fname') && v:version >= 700 " some functions need 7.0
+ set statusline+=%{SRF()} " path to current file
+ else
+ set statusline+=%f " path to current file in buffer
+ endif
+ set statusline+=\ " space after path
+ set statusline+=%h " [help] if buffer is help file
+ set statusline+=%w " [Preview] if buffer is preview buffer
+ set statusline+=%m " [+] if buffer was modified,
+ " [-] if 'modifiable' is off
+ set statusline+=%r " [RO] if buffer is read only
+ if v:version >= 700 " %#..# needs 7.0
+ set statusline+=%#Error# " display warnings
+ set statusline+=%{SFF()} " - unexpected file format
+ set statusline+=%{SFE()} " - unexpected file encoding
+ set statusline+=%{SFB()} " - unexpected file byte order mask
+ set statusline+=%## " continue with normal colors
+ endif
+
+ " on the right
+ set statusline+=%= " right align
+ set statusline+=0x%-8B\ " current character under cursor as hex
+ set statusline+=%-12.(%l,%c%V%)\ " line number (%l),
+ " column number (%c),
+ " virtual column number if different
+ " than %c (%V)
+ set statusline+=%P " position in file in percent
+endif
+
+
+" MAPPINGS (except for plugins, see PLUGIN SETTINGS below)
+
+" noremap is used to make sure the right side is executed as is and can't be
+" modified by a plugin or other settings. Except for <Nop> which isn't
+" affected by mappings.
+
+" Easy way to exit insert mode (jj is too slow).
+inoremap jk <Esc>
+" Also for command mode, thanks to http://github.com/mitechie/pyvim
+" (2010-10-15).
+cnoremap jk <C-C>
+" And fix my typos ...
+inoremap JK <Esc>
+inoremap Jk <Esc>
+inoremap jK <Esc>
+cnoremap JK <C-C>
+cnoremap Jk <C-C>
+cnoremap jK <C-C>
+
+" Disable arrow keys for all modes except command modes. Thanks to James Vega
+" (http://git.jamessan.com/?p=etc/vim.git;a=summary).
+map <Right> <Nop>
+map <Left> <Nop>
+map <Up> <Nop>
+map <Down> <Nop>
+imap <Right> <Nop>
+imap <Left> <Nop>
+imap <Up> <Nop>
+imap <Down> <Nop>
+" Also disable arrow keys in command mode, use <C-P>/<C-N> as replacement (see
+" below).
+cmap <Up> <Nop>
+cmap <Down> <Nop>
+cmap <Right> <Nop>
+cmap <Left> <Nop>
+
+" Use <C-P>/<C-N> as replacement for <Up>/<Down> in command mode. Thanks to
+" abstrakt and grayw in #vim on Freenode (2010-04-12 21:20 CEST).
+cnoremap <C-P> <Up>
+cnoremap <C-N> <Down>
+
+" Use :tjump to lookup tags (instead of :tag) which lists all available tags
+" if there's more than one match. This is really helpful in larger projects
+" where tags may occur multiple times.
+nnoremap <C-]> g<C-]>
+
+if has('eval')
+" Don't move the cursor to the first column for certain scroll commands (<C-F,
+" <C-B>, <C-D>, <C-U>). Thanks to jamessan in #vim on Freenode (2011-08-31
+" 02:27 CEST) for the 'nostartofline' tip. But I can't use 'nostartofline'
+" directly because it also enables that feature for other commands which I
+" don't want.
+
+ " Set 'nostartofline' for a single movement.
+ function! s:TemporaryNostartofline(movement)
+ let l:startofline = &startofline
+ set nostartofline
+ execute 'normal! ' . a:movement
+ let &startofline = l:startofline
+ endfunction
+
+ " Thanks to fow in #vim on Freenode (2012-02-16 15:38 CET) for the idea to
+ " use "<Bslash><Lt>"; Vim documentation reference: :help <>.
+ nnoremap <silent> <C-F>
+ \ :call <SID>TemporaryNostartofline("<Bslash><Lt>C-F>")<CR>
+ nnoremap <silent> <C-B>
+ \ :call <SID>TemporaryNostartofline("<Bslash><Lt>C-B>")<CR>
+ nnoremap <silent> <C-D>
+ \ :call <SID>TemporaryNostartofline("<Bslash><Lt>C-D>")<CR>
+ nnoremap <silent> <C-U>
+ \ :call <SID>TemporaryNostartofline("<Bslash><Lt>C-U>")<CR>
+endif
+
+" Let Y yank to the end of the line, similar to D and C. Use yy if you want to
+" yank a line. This fixes a weird inconsistency in Vi(m).
+nnoremap Y y$
+
+" Write before suspending, thanks to deryni in #vim on Freenode (2011-05-09
+" 20:02 CEST). To suspend without saving either unmap this or use :stop<CR>.
+" Only the current buffer is written, thus switching to another buffer works
+" too.
+nnoremap <silent> <C-Z> :update<CR>:stop<CR>
+
+" 2<C-G> gives more verbose information, use it by default. Thanks to NCS_One
+" in #vim on Freenode (2011-08-15 00:17 CEST).
+nnoremap <C-G> 2<C-G>
+
+" Use <Space> to move down a page and - to move up one like in mutt. Don't use
+" nnoremap so the <C-F>/<C-B> 'nostartofline' fix (see above) works.
+nmap <Space> <C-F>
+nmap - <C-B>
+
+" Go to next and previous buffer. Thanks to elik in #vim on Freenode
+" (2010-05-16 18:38 CEST) for this idea.
+nnoremap <silent> gb :bnext<CR>
+nnoremap <silent> gB :bprevious<CR>
+if has('eval')
+ " But when starting again at the first buffer, print a warning which
+ " reminds me that I've already seen that buffer.
+ function! s:NextBuffer()
+ " Are we currently on the last buffer and moving to the first?
+ let l:last_buffer = 0
+ if bufnr('%') == bufnr('$') && bufnr('$') > 1
+ let l:last_buffer = 1
+ endif
+
+ " Go to the next buffer.
+ if !l:last_buffer
+ bnext
+
+ " Go to the first buffer, silent is necessary or the following message
+ " won't be displayed because it's overwritten by the status message
+ " displayed when entering a buffer.
+ else
+ silent bnext
+
+ echohl WarningMsg
+ echo 'Starting again at first buffer.'
+ echohl None
+ endif
+ endfunction
+ nnoremap <silent> gb :call <SID>NextBuffer()<CR>
+endif
+
+" Fast access to buffers.
+nnoremap <silent> <Leader>1 :1buffer<CR>
+nnoremap <silent> <Leader>2 :2buffer<CR>
+nnoremap <silent> <Leader>3 :3buffer<CR>
+nnoremap <silent> <Leader>4 :4buffer<CR>
+nnoremap <silent> <Leader>5 :5buffer<CR>
+nnoremap <silent> <Leader>6 :6buffer<CR>
+nnoremap <silent> <Leader>7 :7buffer<CR>
+nnoremap <silent> <Leader>8 :8buffer<CR>
+nnoremap <silent> <Leader>9 :9buffer<CR>
+nnoremap <silent> <Leader>0 :10buffer<CR>
+
+" Use real tabs instead of soft tabs.
+if has('eval')
+" Switch from soft tabs to real tabs.
+ function! s:UseTabs()
+ setlocal noexpandtab shiftwidth=8 softtabstop=8
+ endfunction
+ nnoremap <silent> <Leader>t :call <SID>UseTabs()<CR>
+endif
+" Enable "verbatim" mode. Used to view files with long lines or without syntax
+" coloring. 'list' is not changed, see next mapping.
+nnoremap <silent> <Leader>v :setlocal nowrap nospell synmaxcol=0<CR>
+ \ :2match<CR>
+" Toggle 'list'.
+nnoremap <silent> <Leader>l :set invlist<CR>
+
+" Make last active window the only window. Similar to <C-W> o.
+nnoremap <C-W>O <C-W>p<C-W>o
+
+" Maps to change spell language between English and German and disable spell
+" checking.
+if exists('+spell')
+ nnoremap <silent> <Leader>sn :set nospell<CR>
+ nnoremap <silent> <Leader>se :set spell spelllang=en_us<CR>
+ nnoremap <silent> <Leader>sd :set spell spelllang=de_de<CR>
+" If no spell support is available, these mappings do nothing.
+else
+ nmap <Leader>sn <Nop>
+ nmap <Leader>se <Nop>
+ nmap <Leader>sd <Nop>
+endif
+
+if has('eval')
+" * and # for selections in visual mode. Thanks to
+" http://got-ravings.blogspot.com/2008/07/vim-pr0n-visual-search-mappings.html
+" and all nerds involved (godlygeek, strull in #vim on Freenode).
+ function! s:VSetSearch()
+ let l:temp = @@ " unnamed register
+ normal! gvy
+ " Added \C to force 'noignorecase' while searching the current visual
+ " selection. I want to search for the exact string in this case.
+ let @/ = '\C' . '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
+ let @@ = l:temp
+ endfunction
+ vnoremap * :<C-U>call <SID>VSetSearch()<CR>//<CR>
+ vnoremap # :<C-U>call <SID>VSetSearch()<CR>??<CR>
+
+" Use 'noignorecase' for * and #. See comment in s:VSetSearch() for details.
+" Thanks to the writers of s:VSetSearch(), see above.
+ function! s:NSetSearch()
+ let l:cword = expand('<cword>')
+ let l:regex = substitute(escape(l:cword, '\'), '\n', '\\n', 'g')
+ let @/ = '\C\V'. '\<' . l:regex . '\>'
+ endfunction
+ nnoremap * :call <SID>NSetSearch()<CR>//<CR>
+ nnoremap # :call <SID>NSetSearch()<CR>??<CR>
+endif
+
+" I often type "W" instead of "w" when trying to save a file. Fix my mistake.
+" Thanks to Tony Mechelynck <antoine.mechelynck@gmail.com> from the Vim
+" mailing list for the commands.
+if v:version < 700
+ cnoreabbrev W w
+ cnoreabbrev Wa wa
+ cnoreabbrev Wq wq
+ cnoreabbrev Wqa wqa
+else
+ cnoreabbrev <expr> W
+ \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'w' : 'W')
+ cnoreabbrev <expr> Wa
+ \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'wa' : 'Wa')
+ cnoreabbrev <expr> Wq
+ \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'wq' : 'Wq')
+ cnoreabbrev <expr> Wqa
+ \ ((getcmdtype() == ':' && getcmdpos() <= 4) ? 'wqa' : 'Wqa')
+endif
+" Also fix my typo with "Q".
+if v:version < 700
+ cnoreabbrev Q q
+ cnoreabbrev Qa qa
+else
+ cnoreabbrev <expr> Q
+ \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'q' : 'Q')
+ cnoreabbrev <expr> Qa
+ \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'qa' : 'Qa')
+endif
+
+" In case 'hlsearch' is used disable it with <C-L>. Thanks to frogonwheels and
+" vimgor (bot) in #vim on Freenode (2010-03-30 05:58 CEST).
+nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
+
+" <C-U> in insert mode deletes a lot, break undo sequence before deleting the
+" line so the change can be undone. Thanks to the vimrc_example.vim file in
+" Vim's source.
+inoremap <C-U> <C-G>u<C-U>
+" Same for <C-@> (insert previously inserted text and leave insert mode).
+inoremap <C-@> <C-G>u<C-@>
+" And for <C-A> (insert previously inserted text).
+inoremap <C-A> <C-G>u<C-A>
+" And for <C-W> (delete word before cursor).
+inoremap <C-W> <C-G>u<C-W>
+
+if has('eval')
+" New text-objects ii and ai to work on text with the same indentation. Thanks
+" to http://vim.wikia.com/index.php?title=Indent_text_object&oldid=27126
+" (visited on 2011-11-19).
+ onoremap <silent> ai :<C-U>call <SID>IndTxtObj(0)<CR>
+ onoremap <silent> ii :<C-U>call <SID>IndTxtObj(1)<CR>
+ vnoremap <silent> ai :<C-U>call <SID>IndTxtObj(0)<CR><Esc>gv
+ vnoremap <silent> ii :<C-U>call <SID>IndTxtObj(1)<CR><Esc>gv
+
+ function! s:IndTxtObj(inner)
+ let curline = line(".")
+ let lastline = line("$")
+ let i = indent(line(".")) - &shiftwidth * (v:count1 - 1)
+ let i = i < 0 ? 0 : i
+ if getline(".") !~ "^\\s*$"
+ let p = line(".") - 1
+ let nextblank = getline(p) =~ "^\\s*$"
+ while p > 0
+ \ && ((i == 0 && !nextblank)
+ \ || (i > 0 && ((indent(p) >= i
+ \ && !(nextblank && a:inner))
+ \ || (nextblank && !a:inner))))
+ -
+ let p = line(".") - 1
+ let nextblank = getline(p) =~ "^\\s*$"
+ endwhile
+ normal! 0V
+ call cursor(curline, 0)
+ let p = line(".") + 1
+ let nextblank = getline(p) =~ "^\\s*$"
+ while p <= lastline
+ \ && ((i == 0 && !nextblank)
+ \ || (i > 0 && ((indent(p) >= i
+ \ && !(nextblank && a:inner))
+ \ || (nextblank && !a:inner))))
+ +
+ let p = line(".") + 1
+ let nextblank = getline(p) =~ "^\\s*$"
+ endwhile
+ normal! $
+ endif
+ endfunction
+endif
+
+
+" ABBREVIATIONS
+
+" Fix some of my spelling mistakes (German).
+inoreabbrev relle reelle
+inoreabbrev reele reelle
+" Fix some of my spelling mistakes (English).
+inoreabbrev completly completely
+
+
+" SYNTAX SETTINGS
+
+" Activate syntax coloring.
+if has('syntax')
+ " But only if it wasn't already active. Prevents breaking the syntax
+ " coloring when reloading the vimrc. Thanks to johnLate for the idea.
+ if !exists('g:syntax_on')
+ syntax enable
+ endif
+
+" Don't highlight more than 500 columns as I normally don't have that long
+" lines and they slow down syntax coloring. Thanks to Derek Wyatt
+" (http://www.derekwyatt.org/vim/the-vimrc-file/).
+ if exists('+synmaxcol')
+ set synmaxcol=500
+ endif
+
+" Use (limited) syntax based omni completion if no other omni completion is
+" available. Taken from :help ft-syntax-omni.
+ if has('autocmd') && exists('+omnifunc')
+ augroup vimrc
+ autocmd FileType *
+ \ if &omnifunc == '' |
+ \ setlocal omnifunc=syntaxcomplete#Complete |
+ \ endif
+ augroup END
+ endif
+
+" Function to enable all custom highlights. Necessary as highlights are
+" window-local and thus must be set for each new window.
+ function! s:CustomSyntaxHighlights()
+ " Not the first time called, nothing to do.
+ if exists('w:vimrc_syntax_run')
+ return
+ endif
+ let w:vimrc_syntax_run = 1
+
+" Highlight lines longer than 78 characters. Thanks to Tony Mechelynck
+" <antoine.mechelynck@gmail.com> from the Vim mailing list. It can easily be
+" disabled when necessary with :2match (in Vim >= 700).
+ if !&diff && exists(':2match')
+ " Use ColorColumn for overlong lines if available and my color
+ " scheme is used.
+ if &t_Co == 256 && s:HasSyntaxGroup('ColorColumn')
+ 2match ColorColumn /\%>78v./
+ else
+ 2match Todo /\%>78v./
+ endif
+ elseif !&diff
+ match Todo /\%>78v./
+ endif
+
+ if exists('*matchadd')
+" Highlight some important keywords in all documents.
+ let l:todos = ['TODO', 'XXX', 'FIXME', 'NOTE',
+ \ 'CHANGED', 'REMOVED', 'DELETED']
+ " Compatibility fix for Vim 6.4 which can't parse for in functions
+ " (without function it's ignored).
+ execute ' for l:x in l:todos'
+ \ '| call matchadd("Todo", l:x)'
+ \ '| endfor'
+
+" Highlight Unicode whitespace which is no normal whitespace (0x20).
+ let l:spaces = ['00a0', '1680', '180e', '2000', '2001', '2002',
+ \ '2003', '2004', '2005', '2006', '2007', '2008',
+ \ '2009', '200a', '200b', '200c', '200d', '202f',
+ \ '205f', '2060', '3000', 'feff']
+ " Compatibility fix for Vim 6.4. Escape \ inside the " string or
+ " it won't work!
+ execute ' for l:x in l:spaces'
+ \ '| call matchadd("Error", "\\%u" . l:x)'
+ \ '| endfor'
+
+" Special highlight for tabs to reduce their visibility in contrast to other
+" SpecialKey characters (e.g. ^L).
+ if &t_Co == 256 && s:HasSyntaxGroup('specialKeyTab')
+ call matchadd('specialKeyTab', '\t')
+ endif
+ endif
+ endfunction
+" Enable highlights for the current and all new windows. Thanks to bairui in
+" #vim on Freenode (2012-04-01 00:22 CEST) for the WinEnter suggestion.
+ call s:CustomSyntaxHighlights()
+ if has('autocmd')
+ augroup vimrc
+ autocmd WinEnter * call s:CustomSyntaxHighlights()
+ augroup END
+ endif
+
+" Settings for specific filetypes.
+
+ " C
+ let g:c_no_if0_fold = 1 " fix weird double fold in #if0 in recent versions
+ " Haskell
+ let g:hs_highlight_delimiters = 1
+ let g:hs_highlight_boolean = 1
+ let g:hs_highlight_types = 1
+ let g:hs_highlight_more_types = 1
+ " Java
+ let g:java_highlight_java_lang_ids = 1 " color java.lang.* identifiers
+ " Perl
+ let g:perl_fold = 1
+ let g:perl_fold_blocks = 1
+ let g:perl_nofold_packages = 1
+ let g:perl_include_pod = 1 " syntax coloring for PODs
+ " PHP
+ let g:php_folding = 3 " fold functions
+ let g:php_short_tags = 0 " no short tags (<? .. ?>), not always usable
+ let g:php_sql_query = 1 " highlight SQL queries in strings
+ " Python
+ let g:python_highlight_all = 1
+ " Shell
+ let g:sh_noisk = 1 " don't add . to 'iskeyword'
+ let g:sh_is_posix = 1 " POSIX shell (e.g. dash) is compatible enough
+ let g:is_posix = 1 " POSIX shell (e.g. dash) is compatible enough
+ let g:sh_fold_enabled = 7 " functions (1), heredoc (2) and if/do/for (4)
+ " Vim
+ let g:vimsyn_embed = 0 " don't highlight embedded languages
+ let g:vimsyn_folding = 'af' " folding for autogroups (a) and functions (f)
+ " XML
+ let g:xml_syntax_folding = 1
+endif
+
+
+" PLUGIN SETTINGS
+
+if has('eval')
+" Use pathogen which allows one 'runtimepath' entry per plugin. This makes
+" installing/removing/updating plugins simple. (Used for plugins with more
+" than one file.) Ignore errors in case pathogen is not installed.
+ if v:version >= 700
+ silent! execute 'call pathogen#infect()'
+ endif
+
+" Settings for securemodelines.
+ " Only allow items I need (also includes spl which is not enabled by
+ " default).
+ if v:version >= 700 " need lists
+ let g:secure_modelines_allowed_items = ['ft', 'spl', 'fdm',
+ \ 'sw', 'sts', 'noet']
+ endif
+
+" Settings for gnupg.
+ " Don't use temporary files for sensitive data.
+ let g:GPGUsePipes = 1
+
+" Settings for the NERD commenter.
+ " Don't create any mappings I don't want to use.
+ let g:NERDCreateDefaultMappings = 0
+ " Map toggle comment.
+ nmap <Leader><Leader> <Plug>NERDCommenterToggle
+
+" XPTemplate settings.
+ " Try to maintain snippet rendering even after editing outside of a
+ " snippet.
+ let g:xptemplate_strict = 0
+ " Don't complete any braces automatically.
+ let g:xptemplate_brace_complete = 0
+ " Only highlight the current placeholder.
+ let g:xptemplate_highlight = 'current'
+
+" CtrlP settings.
+ " Don't manage the working directory (the default setting is too slow for
+ " me).
+ let g:ctrlp_working_path_mode = 0
+
+ " Path to cache directory. I prefer to keep generated files as local as
+ " possible.
+ let g:ctrlp_cache_dir = $HOME . '/.vim/cache/ctrlp'
+ " Permanent cache, cleared by a crontab entry. Use <F5> to update the
+ " cache manually.
+ let g:ctrlp_clear_cache_on_exit = 0
+
+ " Don't switch the window if the selected buffer is already open. I want
+ " to open another view on this buffer in most cases.
+ let g:ctrlp_switch_buffer = 0
+
+" FSWitch settings.
+ " Defaults don't work well for my projects.
+ augroup vimrc
+ autocmd BufEnter *.cc let b:fswitchdst = 'h'
+ \ | let b:fswitchlocs = './'
+ autocmd BufEnter *.h let b:fswitchdst = 'cc,c'
+ \ | let b:fswitchlocs = './'
+ augroup END
+
+ " Switch to corresponding header/source file.
+ nnoremap <silent> <Leader>h :FSHere<CR>
+
+" netrw settings.
+ " Don't create ~/.vim/.netrwhist history file.
+ let g:netrw_dirhistmax = 0
+endif
+
+
+" AUTO COMMANDS
+
+" Use a custom auto group to prevent problems when the vimrc files is sourced
+" multiple times.
+if has('autocmd')
+ augroup vimrc
+
+" Go to last position of opened files. Taken from :help last-position-jump.
+ autocmd BufReadPost *
+ \ if line("'\"") > 1 && line("'\"") <= line('$') |
+ \ execute "normal! g'\"" |
+ \ endif
+" But not for Git commits, go to beginning of the file.
+ autocmd BufReadPost COMMIT_EDITMSG normal! gg
+
+" Make sure 'list' and 'number' is disabled in help files. This is necessary
+" when switching to a help buffer which is in the background with :buffer as
+" these options are local to windows (and not only to buffers). This happens
+" because I often want to use only one window and thus the help buffer is in
+" the background.
+ autocmd BufWinEnter *.txt
+ \ if &filetype == 'help' |
+ \ setlocal nolist |
+ \ setlocal nonumber |
+ \ endif
+
+" Automatically disable 'paste' mode when leaving insert mode. Thanks to
+" Raimondi in #vim on Freenode (2010-08-14 23:01 CEST). Very useful as I only
+" want to paste once and then 'paste' gets automatically unset. InsertLeave
+" doesn't exist in older Vims. Use "*p to paste X11's selection, no need for
+" 'paste' in this case.
+ if exists('##InsertLeave')
+ autocmd InsertLeave * set nopaste
+ endif
+
+" Write all files when running :mak[e] before 'makeprg' is called.
+" QuickFixCmdPre doesn't exist in older Vims.
+ if exists('##QuickFixCmdPre')
+ autocmd QuickFixCmdPre * wall
+ endif
+
+" Don't ignore case while in insert mode, but ignore case in all other modes.
+" This causes <C-N>/<C-P> to honor the case and thus only complete matching
+" capitalization. But while searching (/) 'ignorecase' is used.
+" InsertEnter/InsertLeave doesn't exist in older Vims.
+ if exists('##InsertEnter') && exists('##InsertLeave')
+ autocmd InsertEnter * set noignorecase
+ autocmd InsertLeave * set ignorecase
+ endif
+
+" Display a warning when editing a file which contains "do not edit" (ignoring
+" the case) and similar messages in the first lines of the file, for example
+" template files which were preprocessed or auto-generated files. Especially
+" useful when the header is not displayed on the first screen, e.g. when the
+" old position is restored.
+ function! s:SearchForDoNotEditHeader()
+ " Only search the first 20 lines to prevent false positives, e.g.
+ " in scripts which write files containing this warning and ignore
+ " the case (\c). (Can't use search()'s {stopline} as we might not
+ " start searching from the top.)
+ let l:search = '\c\(do not \(edit\|modify\)\|autogenerated by\)'
+ let l:match = search(l:search, 'n')
+ if l:match == 0 || l:match > 20
+ return
+ endif
+
+ echoerr 'Do not edit this file! (Maybe a template file.)'
+ endfunction
+ autocmd BufRead * call s:SearchForDoNotEditHeader()
+
+" AFTER/FTPLUGIN AUTO COMMANDS
+
+" Disable spell checking for files which don't need it.
+ autocmd FileType deb setlocal nospell
+ autocmd FileType diff setlocal nospell
+ autocmd FileType tar setlocal nospell
+" Fix to allow Vim edit crontab files as crontab doesn't work with
+" backupcopy=auto.
+ autocmd FileType crontab setlocal backupcopy=yes
+" Don't use the modeline in git commits as the diff created by `git commit -v`
+" may contain one which could change the filetype or other settings of the
+" commit buffer. Also make sure we use only 72 characters per line which is
+" the recommendation for git commit messages (http://tpope.net/node/106).
+ autocmd FileType gitcommit let g:secure_modelines_allowed_items = [] |
+ \ setlocal textwidth=72
+" Fix 'include' setting for shell files to recognize '.' and 'source'
+" commands.
+ autocmd FileType sh let &l:include = '^\s*\(\.\|source\)\s\+'
+" Use the same comment string as for Vim files in Vimperator files.
+ autocmd FileType vimperator setlocal commentstring=\"%s
+" Use TeX compiler for (La)TeX files.
+ autocmd FileType tex compiler tex
+
+" FTDETECT AUTO COMMANDS
+
+" Recognize .md as markdown files (Vim default is .mkd).
+ autocmd BufRead,BufNewFile *.md set filetype=mkd
+" Recognize .test as Tcl files.
+ autocmd BufRead,BufNewFile *.test set filetype=tcl
+
+" OTHER AUTO COMMANDS
+
+" Disable spell checking, displaying of list characters and long lines when
+" viewing documentation.
+ autocmd BufReadPost /usr/share/doc/* setlocal nospell nolist | 2match
+
+" Use diff filetype for mercurial patches in patch queue.
+ autocmd BufReadPost */.hg/patches/* set filetype=diff
+
+ augroup END
+endif
+
+
+" CUSTOM FUNCTIONS AND COMMANDS
+
+if has('eval')
+" Convenient command to see the difference between the current buffer and the
+" file it was loaded from, thus the changes you made. Thanks to the
+" vimrc_example.vim file in Vim's source. Modified to use the same filetype
+" for the diffed file as the filetype for the original file.
+ if !exists(':DiffOrig')
+ command DiffOrig
+ \ let s:diff_orig_filetype = &filetype
+ \ | vertical new
+ \ | let &filetype = s:diff_orig_filetype
+ \ | unlet s:diff_orig_filetype
+ \ | set buftype=nofile
+ \ | read ++edit #
+ \ | 0d_
+ \ | diffthis
+ \ | wincmd p
+ \ | diffthis
+ endif
+endif