Commits

Martin Tournoij  committed 7a565c9

Update

  • Participants
  • Parent commits a601793

Comments (0)

Files changed (145)

File home/dot.vim/autoload/gundo.py

+# ============================================================================
+# File:        gundo.py
+# Description: vim global plugin to visualize your undo tree
+# Maintainer:  Steve Losh <steve@stevelosh.com>
+# License:     GPLv2+ -- look it up.
+# Notes:       Much of this code was thiefed from Mercurial, and the rest was
+#              heavily inspired by scratch.vim and histwin.vim.
+#
+# ============================================================================
+
+import difflib
+import itertools
+import sys
+import time
+import vim
+
+
+# Mercurial's graphlog code --------------------------------------------------------
+def asciiedges(seen, rev, parents):
+    """adds edge info to changelog DAG walk suitable for ascii()"""
+    if rev not in seen:
+        seen.append(rev)
+    nodeidx = seen.index(rev)
+
+    knownparents = []
+    newparents = []
+    for parent in parents:
+        if parent in seen:
+            knownparents.append(parent)
+        else:
+            newparents.append(parent)
+
+    ncols = len(seen)
+    seen[nodeidx:nodeidx + 1] = newparents
+    edges = [(nodeidx, seen.index(p)) for p in knownparents]
+
+    if len(newparents) > 0:
+        edges.append((nodeidx, nodeidx))
+    if len(newparents) > 1:
+        edges.append((nodeidx, nodeidx + 1))
+
+    nmorecols = len(seen) - ncols
+    return nodeidx, edges, ncols, nmorecols
+
+def get_nodeline_edges_tail(
+        node_index, p_node_index, n_columns, n_columns_diff, p_diff, fix_tail):
+    if fix_tail and n_columns_diff == p_diff and n_columns_diff != 0:
+        # Still going in the same non-vertical direction.
+        if n_columns_diff == -1:
+            start = max(node_index + 1, p_node_index)
+            tail = ["|", " "] * (start - node_index - 1)
+            tail.extend(["/", " "] * (n_columns - start))
+            return tail
+        else:
+            return ["\\", " "] * (n_columns - node_index - 1)
+    else:
+        return ["|", " "] * (n_columns - node_index - 1)
+
+def draw_edges(edges, nodeline, interline):
+    for (start, end) in edges:
+        if start == end + 1:
+            interline[2 * end + 1] = "/"
+        elif start == end - 1:
+            interline[2 * start + 1] = "\\"
+        elif start == end:
+            interline[2 * start] = "|"
+        else:
+            nodeline[2 * end] = "+"
+            if start > end:
+                (start, end) = (end, start)
+            for i in range(2 * start + 1, 2 * end):
+                if nodeline[i] != "+":
+                    nodeline[i] = "-"
+
+def fix_long_right_edges(edges):
+    for (i, (start, end)) in enumerate(edges):
+        if end > start:
+            edges[i] = (start, end + 1)
+
+def ascii(buf, state, type, char, text, coldata):
+    """prints an ASCII graph of the DAG
+
+    takes the following arguments (one call per node in the graph):
+
+      - Somewhere to keep the needed state in (init to asciistate())
+      - Column of the current node in the set of ongoing edges.
+      - Type indicator of node data == ASCIIDATA.
+      - Payload: (char, lines):
+        - Character to use as node's symbol.
+        - List of lines to display as the node's text.
+      - Edges; a list of (col, next_col) indicating the edges between
+        the current node and its parents.
+      - Number of columns (ongoing edges) in the current revision.
+      - The difference between the number of columns (ongoing edges)
+        in the next revision and the number of columns (ongoing edges)
+        in the current revision. That is: -1 means one column removed;
+        0 means no columns added or removed; 1 means one column added.
+    """
+
+    idx, edges, ncols, coldiff = coldata
+    assert -2 < coldiff < 2
+    if coldiff == -1:
+        # Transform
+        #
+        #     | | |        | | |
+        #     o | |  into  o---+
+        #     |X /         |/ /
+        #     | |          | |
+        fix_long_right_edges(edges)
+
+    # add_padding_line says whether to rewrite
+    #
+    #     | | | |        | | | |
+    #     | o---+  into  | o---+
+    #     |  / /         |   | |  # <--- padding line
+    #     o | |          |  / /
+    #                    o | |
+    add_padding_line = (len(text) > 2 and coldiff == -1 and
+                        [x for (x, y) in edges if x + 1 < y])
+
+    # fix_nodeline_tail says whether to rewrite
+    #
+    #     | | o | |        | | o | |
+    #     | | |/ /         | | |/ /
+    #     | o | |    into  | o / /   # <--- fixed nodeline tail
+    #     | |/ /           | |/ /
+    #     o | |            o | |
+    fix_nodeline_tail = len(text) <= 2 and not add_padding_line
+
+    # nodeline is the line containing the node character (typically o)
+    nodeline = ["|", " "] * idx
+    nodeline.extend([char, " "])
+
+    nodeline.extend(
+        get_nodeline_edges_tail(idx, state[1], ncols, coldiff,
+                                state[0], fix_nodeline_tail))
+
+    # shift_interline is the line containing the non-vertical
+    # edges between this entry and the next
+    shift_interline = ["|", " "] * idx
+    if coldiff == -1:
+        n_spaces = 1
+        edge_ch = "/"
+    elif coldiff == 0:
+        n_spaces = 2
+        edge_ch = "|"
+    else:
+        n_spaces = 3
+        edge_ch = "\\"
+    shift_interline.extend(n_spaces * [" "])
+    shift_interline.extend([edge_ch, " "] * (ncols - idx - 1))
+
+    # draw edges from the current node to its parents
+    draw_edges(edges, nodeline, shift_interline)
+
+    # lines is the list of all graph lines to print
+    lines = [nodeline]
+    if add_padding_line:
+        lines.append(get_padding_line(idx, ncols, edges))
+    lines.append(shift_interline)
+
+    # make sure that there are as many graph lines as there are
+    # log strings
+    while len(text) < len(lines):
+        text.append("")
+    if len(lines) < len(text):
+        extra_interline = ["|", " "] * (ncols + coldiff)
+        while len(lines) < len(text):
+            lines.append(extra_interline)
+
+    # print lines
+    indentation_level = max(ncols, ncols + coldiff)
+    for (line, logstr) in zip(lines, text):
+        ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr)
+        buf.write(ln.rstrip() + '\n')
+
+    # ... and start over
+    state[0] = coldiff
+    state[1] = idx
+
+def generate(dag, edgefn, current):
+    seen, state = [], [0, 0]
+    buf = Buffer()
+    for node, parents in list(dag):
+        if node.time:
+            age_label = age(int(node.time))
+        else:
+            age_label = 'Original'
+        line = '[%s] %s' % (node.n, age_label)
+        if node.n == current:
+            char = '@'
+        else:
+            char = 'o'
+        ascii(buf, state, 'C', char, [line], edgefn(seen, node, parents))
+    return buf.b
+
+
+# Mercurial age function -----------------------------------------------------------
+agescales = [("year", 3600 * 24 * 365),
+             ("month", 3600 * 24 * 30),
+             ("week", 3600 * 24 * 7),
+             ("day", 3600 * 24),
+             ("hour", 3600),
+             ("minute", 60),
+             ("second", 1)]
+
+def age(ts):
+    '''turn a timestamp into an age string.'''
+
+    def plural(t, c):
+        if c == 1:
+            return t
+        return t + "s"
+    def fmt(t, c):
+        return "%d %s" % (c, plural(t, c))
+
+    now = time.time()
+    then = ts
+    if then > now:
+        return 'in the future'
+
+    delta = max(1, int(now - then))
+    if delta > agescales[0][1] * 2:
+        return time.strftime('%Y-%m-%d', time.gmtime(float(ts)))
+
+    for t, s in agescales:
+        n = delta // s
+        if n >= 2 or s == 1:
+            return '%s ago' % fmt(t, n)
+
+
+# Python Vim utility functions -----------------------------------------------------
+normal = lambda s: vim.command('normal %s' % s)
+
+MISSING_BUFFER = "Cannot find Gundo's target buffer (%s)"
+MISSING_WINDOW = "Cannot find window (%s) for Gundo's target buffer (%s)"
+
+def _check_sanity():
+    '''Check to make sure we're not crazy.
+
+    Does the following things:
+
+        * Make sure the target buffer still exists.
+    '''
+    b = int(vim.eval('g:gundo_target_n'))
+
+    if not vim.eval('bufloaded(%d)' % b):
+        vim.command('echo "%s"' % (MISSING_BUFFER % b))
+        return False
+
+    w = int(vim.eval('bufwinnr(%d)' % b))
+    if w == -1:
+        vim.command('echo "%s"' % (MISSING_WINDOW % (w, b)))
+        return False
+
+    return True
+
+def _goto_window_for_buffer(b):
+    w = int(vim.eval('bufwinnr(%d)' % int(b)))
+    vim.command('%dwincmd w' % w)
+
+def _goto_window_for_buffer_name(bn):
+    b = vim.eval('bufnr("%s")' % bn)
+    return _goto_window_for_buffer(b)
+
+def _undo_to(n):
+    n = int(n)
+    if n == 0:
+        vim.command('silent earlier %s' % (int(vim.eval('&undolevels')) + 1))
+    else:
+        vim.command('silent undo %d' % n)
+
+
+INLINE_HELP = '''\
+" Gundo for %s (%d)
+" %s/%s  - move between undo states
+" p    - preview diff of selected and current states
+" <cr> - revert to selected state
+
+'''
+
+
+# Python undo tree data structures and functions -----------------------------------
+class Buffer(object):
+    def __init__(self):
+        self.b = ''
+
+    def write(self, s):
+        self.b += s
+
+class Node(object):
+    def __init__(self, n, parent, time, curhead):
+        self.n = int(n)
+        self.parent = parent
+        self.children = []
+        self.curhead = curhead
+        self.time = time
+
+def _make_nodes(alts, nodes, parent=None):
+    p = parent
+
+    for alt in alts:
+        curhead = 'curhead' in alt
+        node = Node(n=alt['seq'], parent=p, time=alt['time'], curhead=curhead)
+        nodes.append(node)
+        if alt.get('alt'):
+            _make_nodes(alt['alt'], nodes, p)
+        p = node
+
+def make_nodes():
+    ut = vim.eval('undotree()')
+    entries = ut['entries']
+
+    root = Node(0, None, False, 0)
+    nodes = []
+    _make_nodes(entries, nodes, root)
+    nodes.append(root)
+    nmap = dict((node.n, node) for node in nodes)
+    return nodes, nmap
+
+def changenr(nodes):
+    _curhead_l = list(itertools.dropwhile(lambda n: not n.curhead, nodes))
+    if _curhead_l:
+        current = _curhead_l[0].parent.n
+    else:
+        current = int(vim.eval('changenr()'))
+    return current
+
+
+# Gundo rendering ------------------------------------------------------------------
+
+# Rendering utility functions
+def _fmt_time(t):
+    return time.strftime('%Y-%m-%d %I:%M:%S %p', time.localtime(float(t)))
+
+def _output_preview_text(lines):
+    _goto_window_for_buffer_name('__Gundo_Preview__')
+    vim.command('setlocal modifiable')
+    vim.current.buffer[:] = lines
+    vim.command('setlocal nomodifiable')
+
+def _generate_preview_diff(current, node_before, node_after):
+    _goto_window_for_buffer(vim.eval('g:gundo_target_n'))
+
+    if not node_after.n:    # we're at the original file
+        before_lines = []
+
+        _undo_to(0)
+        after_lines = vim.current.buffer[:]
+
+        before_name = 'n/a'
+        before_time = ''
+        after_name = 'Original'
+        after_time = ''
+    elif not node_before.n: # we're at a pseudo-root state
+        _undo_to(0)
+        before_lines = vim.current.buffer[:]
+
+        _undo_to(node_after.n)
+        after_lines = vim.current.buffer[:]
+
+        before_name = 'Original'
+        before_time = ''
+        after_name = node_after.n
+        after_time = _fmt_time(node_after.time)
+    else:
+        _undo_to(node_before.n)
+        before_lines = vim.current.buffer[:]
+
+        _undo_to(node_after.n)
+        after_lines = vim.current.buffer[:]
+
+        before_name = node_before.n
+        before_time = _fmt_time(node_before.time)
+        after_name = node_after.n
+        after_time = _fmt_time(node_after.time)
+
+    _undo_to(current)
+
+    return list(difflib.unified_diff(before_lines, after_lines,
+                                     before_name, after_name,
+                                     before_time, after_time))
+
+def _generate_change_preview_diff(current, node_before, node_after):
+    _goto_window_for_buffer(vim.eval('g:gundo_target_n'))
+
+    _undo_to(node_before.n)
+    before_lines = vim.current.buffer[:]
+
+    _undo_to(node_after.n)
+    after_lines = vim.current.buffer[:]
+
+    before_name = node_before.n or 'Original'
+    before_time = node_before.time and _fmt_time(node_before.time) or ''
+    after_name = node_after.n or 'Original'
+    after_time = node_after.time and _fmt_time(node_after.time) or ''
+
+    _undo_to(current)
+
+    return list(difflib.unified_diff(before_lines, after_lines,
+                                     before_name, after_name,
+                                     before_time, after_time))
+
+def GundoRenderGraph():
+    if not _check_sanity():
+        return
+
+    nodes, nmap = make_nodes()
+
+    for node in nodes:
+        node.children = [n for n in nodes if n.parent == node]
+
+    def walk_nodes(nodes):
+        for node in nodes:
+            if node.parent:
+                yield (node, [node.parent])
+            else:
+                yield (node, [])
+
+    dag = sorted(nodes, key=lambda n: int(n.n), reverse=True)
+    current = changenr(nodes)
+
+    result = generate(walk_nodes(dag), asciiedges, current).rstrip().splitlines()
+    result = [' ' + l for l in result]
+
+    target = (vim.eval('g:gundo_target_f'), int(vim.eval('g:gundo_target_n')))
+    mappings = (vim.eval('g:gundo_map_move_older'),
+                vim.eval('g:gundo_map_move_newer'))
+
+    if int(vim.eval('g:gundo_help')):
+        header = (INLINE_HELP % (target + mappings)).splitlines()
+    else:
+        header = []
+
+    vim.command('call s:GundoOpenGraph()')
+    vim.command('setlocal modifiable')
+    vim.current.buffer[:] = (header + result)
+    vim.command('setlocal nomodifiable')
+
+    i = 1
+    for line in result:
+        try:
+            line.split('[')[0].index('@')
+            i += 1
+            break
+        except ValueError:
+            pass
+        i += 1
+    vim.command('%d' % (i+len(header)-1))
+
+def GundoRenderPreview():
+    if not _check_sanity():
+        return
+
+    target_state = vim.eval('s:GundoGetTargetState()')
+
+    # Check that there's an undo state. There may not be if we're talking about
+    # a buffer with no changes yet.
+    if target_state == None:
+        _goto_window_for_buffer_name('__Gundo__')
+        return
+    else:
+        target_state = int(target_state)
+
+    _goto_window_for_buffer(vim.eval('g:gundo_target_n'))
+
+    nodes, nmap = make_nodes()
+    current = changenr(nodes)
+
+    node_after = nmap[target_state]
+    node_before = node_after.parent
+
+    vim.command('call s:GundoOpenPreview()')
+    _output_preview_text(_generate_preview_diff(current, node_before, node_after))
+
+    _goto_window_for_buffer_name('__Gundo__')
+
+def GundoRenderChangePreview():
+    if not _check_sanity():
+        return
+
+    target_state = vim.eval('s:GundoGetTargetState()')
+
+    # Check that there's an undo state. There may not be if we're talking about
+    # a buffer with no changes yet.
+    if target_state == None:
+        _goto_window_for_buffer_name('__Gundo__')
+        return
+    else:
+        target_state = int(target_state)
+
+    _goto_window_for_buffer(vim.eval('g:gundo_target_n'))
+
+    nodes, nmap = make_nodes()
+    current = changenr(nodes)
+
+    node_after = nmap[target_state]
+    node_before = nmap[current]
+
+    vim.command('call s:GundoOpenPreview()')
+    _output_preview_text(_generate_change_preview_diff(current, node_before, node_after))
+
+    _goto_window_for_buffer_name('__Gundo__')
+
+
+# Gundo undo/redo
+def GundoRevert():
+    if not _check_sanity():
+        return
+
+    target_n = int(vim.eval('s:GundoGetTargetState()'))
+    back = vim.eval('g:gundo_target_n')
+
+    _goto_window_for_buffer(back)
+    _undo_to(target_n)
+
+    vim.command('GundoRenderGraph')
+    _goto_window_for_buffer(back)
+
+    if int(vim.eval('g:gundo_close_on_revert')):
+        vim.command('GundoToggle')
+
+def GundoPlayTo():
+    if not _check_sanity():
+        return
+
+    target_n = int(vim.eval('s:GundoGetTargetState()'))
+    back = int(vim.eval('g:gundo_target_n'))
+    delay = int(vim.eval('g:gundo_playback_delay'))
+
+    vim.command('echo "%s"' % back)
+
+    _goto_window_for_buffer(back)
+    normal('zR')
+
+    nodes, nmap = make_nodes()
+
+    start = nmap[changenr(nodes)]
+    end = nmap[target_n]
+
+    def _walk_branch(origin, dest):
+        rev = origin.n < dest.n
+
+        nodes = []
+        if origin.n > dest.n:
+            current, final = origin, dest
+        else:
+            current, final = dest, origin
+
+        while current.n >= final.n:
+            if current.n == final.n:
+                break
+            nodes.append(current)
+            current = current.parent
+        else:
+            return None
+        nodes.append(current)
+
+        if rev:
+            return reversed(nodes)
+        else:
+            return nodes
+
+    branch = _walk_branch(start, end)
+
+    if not branch:
+        vim.command('unsilent echo "No path to that node from here!"')
+        return
+
+    for node in branch:
+        _undo_to(node.n)
+        vim.command('GundoRenderGraph')
+        normal('zz')
+        _goto_window_for_buffer(back)
+        vim.command('redraw')
+        vim.command('sleep %dm' % delay)
+
+def initPythonModule():
+    if sys.version_info[:2] < (2, 4):
+        vim.command('let s:has_supported_python = 0')

File home/dot.vim/autoload/gundo.vim

+" ============================================================================
+" File:        gundo.vim
+" Description: vim global plugin to visualize your undo tree
+" Maintainer:  Steve Losh <steve@stevelosh.com>
+" License:     GPLv2+ -- look it up.
+" Notes:       Much of this code was thiefed from Mercurial, and the rest was
+"              heavily inspired by scratch.vim and histwin.vim.
+"
+" ============================================================================
+
+
+"{{{ Init
+
+if v:version < '703'"{{{
+    function! s:GundoDidNotLoad()
+        echohl WarningMsg|echomsg "Gundo unavailable: requires Vim 7.3+"|echohl None
+    endfunction
+    command! -nargs=0 GundoToggle call s:GundoDidNotLoad()
+    finish
+endif"}}}
+
+if !exists('g:gundo_width')"{{{
+    let g:gundo_width = 45
+endif"}}}
+if !exists('g:gundo_preview_height')"{{{
+    let g:gundo_preview_height = 15
+endif"}}}
+if !exists('g:gundo_preview_bottom')"{{{
+    let g:gundo_preview_bottom = 0
+endif"}}}
+if !exists('g:gundo_right')"{{{
+    let g:gundo_right = 0
+endif"}}}
+if !exists('g:gundo_help')"{{{
+    let g:gundo_help = 1
+endif"}}}
+if !exists("g:gundo_map_move_older")"{{{
+    let g:gundo_map_move_older = 'j'
+endif"}}}
+if !exists("g:gundo_map_move_newer")"{{{
+    let g:gundo_map_move_newer = 'k'
+endif"}}}
+if !exists("g:gundo_close_on_revert")"{{{
+    let g:gundo_close_on_revert = 0
+endif"}}}
+if !exists("g:gundo_prefer_python3")"{{{
+    let g:gundo_prefer_python3 = 0
+endif"}}}
+if !exists("g:gundo_auto_preview")"{{{
+    let g:gundo_auto_preview = 1
+endif"}}}
+if !exists("g:gundo_playback_delay")"{{{
+    let g:gundo_playback_delay = 60
+endif"}}}
+
+let s:has_supported_python = 0
+if g:gundo_prefer_python3 && has('python3')"{{{
+    let s:has_supported_python = 2
+elseif has('python')"
+    let s:has_supported_python = 1
+endif
+
+if !s:has_supported_python
+    function! s:GundoDidNotLoad()
+        echohl WarningMsg|echomsg "Gundo requires Vim to be compiled with Python 2.4+"|echohl None
+    endfunction
+    command! -nargs=0 GundoToggle call s:GundoDidNotLoad()
+    finish
+endif"}}}
+
+let s:plugin_path = escape(expand('<sfile>:p:h'), '\')
+"}}}
+
+"{{{ Gundo utility functions
+
+function! s:GundoGetTargetState()"{{{
+    let target_line = matchstr(getline("."), '\v\[[0-9]+\]')
+    return matchstr(target_line, '\v[0-9]+')
+endfunction"}}}
+
+function! s:GundoGoToWindowForBufferName(name)"{{{
+    if bufwinnr(bufnr(a:name)) != -1
+        exe bufwinnr(bufnr(a:name)) . "wincmd w"
+        return 1
+    else
+        return 0
+    endif
+endfunction"}}}
+
+function! s:GundoIsVisible()"{{{
+    if bufwinnr(bufnr("__Gundo__")) != -1 || bufwinnr(bufnr("__Gundo_Preview__")) != -1
+        return 1
+    else
+        return 0
+    endif
+endfunction"}}}
+
+function! s:GundoInlineHelpLength()"{{{
+    if g:gundo_help
+        return 6
+    else
+        return 0
+    endif
+endfunction"}}}
+
+"}}}
+
+"{{{ Gundo buffer settings
+
+function! s:GundoMapGraph()"{{{
+    exec 'nnoremap <script> <silent> <buffer> ' . g:gundo_map_move_older . " :call <sid>GundoMove(1)<CR>"
+    exec 'nnoremap <script> <silent> <buffer> ' . g:gundo_map_move_newer . " :call <sid>GundoMove(-1)<CR>"
+    nnoremap <script> <silent> <buffer> <CR>          :call <sid>GundoRevert()<CR>
+    nnoremap <script> <silent> <buffer> o             :call <sid>GundoRevert()<CR>
+    nnoremap <script> <silent> <buffer> <down>        :call <sid>GundoMove(1)<CR>
+    nnoremap <script> <silent> <buffer> <up>          :call <sid>GundoMove(-1)<CR>
+    nnoremap <script> <silent> <buffer> gg            gg:call <sid>GundoMove(1)<CR>
+    nnoremap <script> <silent> <buffer> P             :call <sid>GundoPlayTo()<CR>
+    nnoremap <script> <silent> <buffer> p             :call <sid>GundoRenderChangePreview()<CR>
+    nnoremap <script> <silent> <buffer> r             :call <sid>GundoRenderPreview()<CR>
+    nnoremap <script> <silent> <buffer> q             :call <sid>GundoClose()<CR>
+    cabbrev  <script> <silent> <buffer> q             call <sid>GundoClose()
+    cabbrev  <script> <silent> <buffer> quit          call <sid>GundoClose()
+    nnoremap <script> <silent> <buffer> <2-LeftMouse> :call <sid>GundoMouseDoubleClick()<CR>
+endfunction"}}}
+
+function! s:GundoMapPreview()"{{{
+    nnoremap <script> <silent> <buffer> q     :call <sid>GundoClose()<CR>
+    cabbrev  <script> <silent> <buffer> q     call <sid>GundoClose()
+    cabbrev  <script> <silent> <buffer> quit  call <sid>GundoClose()
+endfunction"}}}
+
+function! s:GundoSettingsGraph()"{{{
+    setlocal buftype=nofile
+    setlocal bufhidden=hide
+    setlocal noswapfile
+    setlocal nobuflisted
+    setlocal nomodifiable
+    setlocal filetype=gundo
+    setlocal nolist
+    setlocal nonumber
+    setlocal norelativenumber
+    setlocal nowrap
+    call s:GundoSyntaxGraph()
+    call s:GundoMapGraph()
+endfunction"}}}
+
+function! s:GundoSettingsPreview()"{{{
+    setlocal buftype=nofile
+    setlocal bufhidden=hide
+    setlocal noswapfile
+    setlocal nobuflisted
+    setlocal nomodifiable
+    setlocal filetype=diff
+    setlocal nonumber
+    setlocal norelativenumber
+    setlocal nowrap
+    setlocal foldlevel=20
+    setlocal foldmethod=diff
+    call s:GundoMapPreview()
+endfunction"}}}
+
+function! s:GundoSyntaxGraph()"{{{
+    let b:current_syntax = 'gundo'
+
+    syn match GundoCurrentLocation '@'
+    syn match GundoHelp '\v^".*$'
+    syn match GundoNumberField '\v\[[0-9]+\]'
+    syn match GundoNumber '\v[0-9]+' contained containedin=GundoNumberField
+
+    hi def link GundoCurrentLocation Keyword
+    hi def link GundoHelp Comment
+    hi def link GundoNumberField Comment
+    hi def link GundoNumber Identifier
+endfunction"}}}
+
+"}}}
+
+"{{{ Gundo buffer/window management
+
+function! s:GundoResizeBuffers(backto)"{{{
+    call s:GundoGoToWindowForBufferName('__Gundo__')
+    exe "vertical resize " . g:gundo_width
+
+    call s:GundoGoToWindowForBufferName('__Gundo_Preview__')
+    exe "resize " . g:gundo_preview_height
+
+    exe a:backto . "wincmd w"
+endfunction"}}}
+
+function! s:GundoOpenGraph()"{{{
+    let existing_gundo_buffer = bufnr("__Gundo__")
+
+    if existing_gundo_buffer == -1
+        call s:GundoGoToWindowForBufferName('__Gundo_Preview__')
+        exe "new __Gundo__"
+        if g:gundo_preview_bottom
+            if g:gundo_right
+                wincmd L
+            else
+                wincmd H
+            endif
+        endif
+        call s:GundoResizeBuffers(winnr())
+    else
+        let existing_gundo_window = bufwinnr(existing_gundo_buffer)
+
+        if existing_gundo_window != -1
+            if winnr() != existing_gundo_window
+                exe existing_gundo_window . "wincmd w"
+            endif
+        else
+            call s:GundoGoToWindowForBufferName('__Gundo_Preview__')
+            if g:gundo_preview_bottom
+                if g:gundo_right
+                    exe "botright vsplit +buffer" . existing_gundo_buffer
+                else
+                    exe "topleft vsplit +buffer" . existing_gundo_buffer
+                endif
+            else
+                exe "split +buffer" . existing_gundo_buffer
+            endif
+            call s:GundoResizeBuffers(winnr())
+        endif
+    endif
+    if exists("g:gundo_tree_statusline")
+        let &l:statusline = g:gundo_tree_statusline
+    endif
+endfunction"}}}
+
+function! s:GundoOpenPreview()"{{{
+    let existing_preview_buffer = bufnr("__Gundo_Preview__")
+
+    if existing_preview_buffer == -1
+        if g:gundo_preview_bottom
+            exe "botright new __Gundo_Preview__"
+        else
+            if g:gundo_right
+                exe "botright vnew __Gundo_Preview__"
+            else
+                exe "topleft vnew __Gundo_Preview__"
+            endif
+        endif
+    else
+        let existing_preview_window = bufwinnr(existing_preview_buffer)
+
+        if existing_preview_window != -1
+            if winnr() != existing_preview_window
+                exe existing_preview_window . "wincmd w"
+            endif
+        else
+            if g:gundo_preview_bottom
+                exe "botright split +buffer" . existing_preview_buffer
+            else
+                if g:gundo_right
+                    exe "botright vsplit +buffer" . existing_preview_buffer
+                else
+                    exe "topleft vsplit +buffer" . existing_preview_buffer
+                endif
+            endif
+        endif
+    endif
+    if exists("g:gundo_preview_statusline")
+        let &l:statusline = g:gundo_preview_statusline
+    endif
+endfunction"}}}
+
+function! s:GundoClose()"{{{
+    if s:GundoGoToWindowForBufferName('__Gundo__')
+        quit
+    endif
+
+    if s:GundoGoToWindowForBufferName('__Gundo_Preview__')
+        quit
+    endif
+
+    exe bufwinnr(g:gundo_target_n) . "wincmd w"
+endfunction"}}}
+
+function! s:GundoOpen()"{{{
+    if !exists('g:gundo_py_loaded')
+        if s:has_supported_python == 2 && g:gundo_prefer_python3
+            exe 'py3file ' . s:plugin_path . '/gundo.py'
+            python3 initPythonModule()
+        else
+            exe 'pyfile ' . s:plugin_path . '/gundo.py'
+            python initPythonModule()
+        endif
+
+        if !s:has_supported_python
+            function! s:GundoDidNotLoad()
+                echohl WarningMsg|echomsg "Gundo unavailable: requires Vim 7.3+"|echohl None
+            endfunction
+            command! -nargs=0 GundoToggle call s:GundoDidNotLoad()
+            call s:GundoDidNotLoad()
+            return
+        endif"
+
+        let g:gundo_py_loaded = 1
+    endif
+
+    " Save `splitbelow` value and set it to default to avoid problems with
+    " positioning new windows.
+    let saved_splitbelow = &splitbelow
+    let &splitbelow = 0
+
+    call s:GundoOpenPreview()
+    exe bufwinnr(g:gundo_target_n) . "wincmd w"
+
+    call s:GundoRenderGraph()
+    call s:GundoRenderPreview()
+
+    " Restore `splitbelow` value.
+    let &splitbelow = saved_splitbelow
+endfunction"}}}
+
+function! s:GundoToggle()"{{{
+    if s:GundoIsVisible()
+        call s:GundoClose()
+    else
+        let g:gundo_target_n = bufnr('')
+        let g:gundo_target_f = @%
+        call s:GundoOpen()
+    endif
+endfunction"}}}
+
+function! s:GundoShow()"{{{
+    if !s:GundoIsVisible()
+        let g:gundo_target_n = bufnr('')
+        let g:gundo_target_f = @%
+        call s:GundoOpen()
+    endif
+endfunction"}}}
+
+function! s:GundoHide()"{{{
+    if s:GundoIsVisible()
+        call s:GundoClose()
+    endif
+endfunction"}}}
+
+"}}}
+
+"{{{ Gundo mouse handling
+
+function! s:GundoMouseDoubleClick()"{{{
+    let start_line = getline('.')
+
+    if stridx(start_line, '[') == -1
+        return
+    else
+        call s:GundoRevert()
+    endif
+endfunction"}}}
+
+"}}}
+
+"{{{ Gundo movement
+
+function! s:GundoMove(direction) range"{{{
+    let start_line = getline('.')
+    if v:count1 == 0
+        let move_count = 1
+    else
+        let move_count = v:count1
+    endif
+    let distance = 2 * move_count
+
+    " If we're in between two nodes we move by one less to get back on track.
+    if stridx(start_line, '[') == -1
+        let distance = distance - 1
+    endif
+
+    let target_n = line('.') + (distance * a:direction)
+
+    " Bound the movement to the graph.
+    if target_n <= s:GundoInlineHelpLength() - 1
+        call cursor(s:GundoInlineHelpLength(), 0)
+    else
+        call cursor(target_n, 0)
+    endif
+
+    let line = getline('.')
+
+    " Move to the node, whether it's an @ or an o
+    let idx1 = stridx(line, '@')
+    let idx2 = stridx(line, 'o')
+    if idx1 != -1
+        call cursor(0, idx1 + 1)
+    else
+        call cursor(0, idx2 + 1)
+    endif
+
+    if g:gundo_auto_preview == 1
+        call s:GundoRenderPreview()
+    endif
+endfunction"}}}
+
+"}}}
+
+"{{{ Gundo rendering
+
+function! s:GundoRenderGraph()"{{{
+    if s:has_supported_python == 2 && g:gundo_prefer_python3
+        python3 GundoRenderGraph()
+    else
+        python GundoRenderGraph()
+    endif
+endfunction"}}}
+
+function! s:GundoRenderPreview()"{{{
+    if s:has_supported_python == 2 && g:gundo_prefer_python3
+        python3 GundoRenderPreview()
+    else
+        python GundoRenderPreview()
+    endif
+endfunction"}}}
+
+function! s:GundoRenderChangePreview()"{{{
+    if s:has_supported_python == 2 && g:gundo_prefer_python3
+        python3 GundoRenderChangePreview()
+    else
+        python GundoRenderChangePreview()
+    endif
+endfunction"}}}
+
+"}}}
+
+"{{{ Gundo undo/redo
+
+function! s:GundoRevert()"{{{
+    if s:has_supported_python == 2 && g:gundo_prefer_python3
+        python3 GundoRevert()
+    else
+        python GundoRevert()
+    endif
+endfunction"}}}
+
+function! s:GundoPlayTo()"{{{
+    if s:has_supported_python == 2 && g:gundo_prefer_python3
+        python3 GundoPlayTo()
+    else
+        python GundoPlayTo()
+    endif
+endfunction"}}}
+
+"}}}
+
+"{{{ Misc
+
+function! gundo#GundoToggle()"{{{
+    call s:GundoToggle()
+endfunction"}}}
+
+function! gundo#GundoShow()"{{{
+    call s:GundoShow()
+endfunction"}}}
+
+function! gundo#GundoHide()"{{{
+    call s:GundoHide()
+endfunction"}}}
+
+function! gundo#GundoRenderGraph()"{{{
+    call s:GundoRenderGraph()
+endfunction"}}}
+
+augroup GundoAug
+    autocmd!
+    autocmd BufNewFile __Gundo__ call s:GundoSettingsGraph()
+    autocmd BufNewFile __Gundo_Preview__ call s:GundoSettingsPreview()
+augroup END
+
+"}}}

File home/dot.vim/autoload/syntastic/c.vim

+if exists("g:loaded_syntastic_c_autoload")
+    finish
+endif
+let g:loaded_syntastic_c_autoload = 1
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+" initialize c/cpp syntax checker handlers
+function! s:Init()
+    let s:handlers = []
+    let s:cflags = {}
+
+    call s:RegHandler('gtk', 'syntastic#c#CheckPKG',
+                \ ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
+    call s:RegHandler('glib', 'syntastic#c#CheckPKG',
+                \ ['glib', 'glib-2.0', 'glib'])
+    call s:RegHandler('glade', 'syntastic#c#CheckPKG',
+                \ ['glade', 'libglade-2.0', 'libglade'])
+    call s:RegHandler('libsoup', 'syntastic#c#CheckPKG',
+                \ ['libsoup', 'libsoup-2.4', 'libsoup-2.2'])
+    call s:RegHandler('webkit', 'syntastic#c#CheckPKG',
+                \ ['webkit', 'webkit-1.0'])
+    call s:RegHandler('cairo', 'syntastic#c#CheckPKG',
+                \ ['cairo', 'cairo'])
+    call s:RegHandler('pango', 'syntastic#c#CheckPKG',
+                \ ['pango', 'pango'])
+    call s:RegHandler('libxml', 'syntastic#c#CheckPKG',
+                \ ['libxml', 'libxml-2.0', 'libxml'])
+    call s:RegHandler('freetype', 'syntastic#c#CheckPKG',
+                \ ['freetype', 'freetype2', 'freetype'])
+    call s:RegHandler('SDL', 'syntastic#c#CheckPKG',
+                \ ['sdl', 'sdl'])
+    call s:RegHandler('opengl', 'syntastic#c#CheckPKG',
+                \ ['opengl', 'gl'])
+    call s:RegHandler('ruby', 'syntastic#c#CheckRuby', [])
+    call s:RegHandler('Python\.h', 'syntastic#c#CheckPython', [])
+    call s:RegHandler('php\.h', 'syntastic#c#CheckPhp', [])
+endfunction
+
+" default include directories
+let s:default_includes = [ '.', '..', 'include', 'includes',
+            \ '../include', '../includes' ]
+
+" convenience function to determine the 'null device' parameter
+" based on the current operating system
+function! syntastic#c#GetNullDevice()
+    if has('win32')
+        return '-o nul'
+    elseif has('unix') || has('mac')
+        return '-o /dev/null'
+    endif
+    return ''
+endfunction
+
+" get the gcc include directory argument depending on the default
+" includes and the optional user-defined 'g:syntastic_c_include_dirs'
+function! syntastic#c#GetIncludeDirs(filetype)
+    let include_dirs = []
+
+    if !exists('g:syntastic_'.a:filetype.'_no_default_include_dirs') ||
+        \ !g:syntastic_{a:filetype}_no_default_include_dirs
+        let include_dirs = copy(s:default_includes)
+    endif
+
+    if exists('g:syntastic_'.a:filetype.'_include_dirs')
+        call extend(include_dirs, g:syntastic_{a:filetype}_include_dirs)
+    endif
+
+    return join(map(syntastic#util#unique(include_dirs), '"-I" . v:val'), ' ')
+endfunction
+
+" read additional compiler flags from the given configuration file
+" the file format and its parsing mechanism is inspired by clang_complete
+function! syntastic#c#ReadConfig(file)
+    " search in the current file's directory upwards
+    let config = findfile(a:file, '.;')
+    if config == '' || !filereadable(config) | return '' | endif
+
+    " convert filename into absolute path
+    let filepath = substitute(fnamemodify(config, ':p:h'), '\', '/', 'g')
+
+    " try to read config file
+    try
+        let lines = map(readfile(config),
+                    \ 'substitute(v:val, ''\'', ''/'', ''g'')')
+    catch /E484/
+        return ''
+    endtry
+
+    let parameters = []
+    for line in lines
+        let matches = matchlist(line, '\C^\s*-I\s*\(\S\+\)')
+        if matches != [] && matches[1] != ''
+            " this one looks like an absolute path
+            if match(matches[1], '^\%(/\|\a:\)') != -1
+                call add(parameters, '-I' . matches[1])
+            else
+                call add(parameters, '-I' . filepath . '/' . matches[1])
+            endif
+        else
+            call add(parameters, line)
+        endif
+    endfor
+
+    return join(parameters, ' ')
+endfunction
+
+" search the first 100 lines for include statements that are
+" given in the handlers dictionary
+function! syntastic#c#SearchHeaders()
+    let includes = ''
+    let files = []
+    let found = []
+    let lines = filter(getline(1, 100), 'v:val =~# "#\s*include"')
+
+    " search current buffer
+    for line in lines
+        let file = matchstr(line, '"\zs\S\+\ze"')
+        if file != ''
+            call add(files, file)
+            continue
+        endif
+        for handler in s:handlers
+            if line =~# handler["regex"]
+                let includes .= call(handler["func"], handler["args"])
+                call add(found, handler["regex"])
+                break
+            endif
+        endfor
+    endfor
+
+    " search included headers
+    for hfile in files
+        if hfile != ''
+            let filename = expand('%:p:h') . (has('win32') ?
+                        \ '\' : '/') . hfile
+            try
+                let lines = readfile(filename, '', 100)
+            catch /E484/
+                continue
+            endtry
+            let lines = filter(lines, 'v:val =~# "#\s*include"')
+            for handler in s:handlers
+                if index(found, handler["regex"]) != -1
+                    continue
+                endif
+                for line in lines
+                    if line =~# handler["regex"]
+                        let includes .= call(handler["func"], handler["args"])
+                        call add(found, handler["regex"])
+                        break
+                    endif
+                endfor
+            endfor
+        endif
+    endfor
+
+    return includes
+endfunction
+
+" try to find library with 'pkg-config'
+" search possible libraries from first to last given
+" argument until one is found
+function! syntastic#c#CheckPKG(name, ...)
+    if executable('pkg-config')
+        if !has_key(s:cflags, a:name)
+            for i in range(a:0)
+                let l:cflags = system('pkg-config --cflags '.a:000[i])
+                " since we cannot necessarily trust the pkg-config exit code
+                " we have to check for an error output as well
+                if v:shell_error == 0 && l:cflags !~? 'not found'
+                    let l:cflags = ' '.substitute(l:cflags, "\n", '', '')
+                    let s:cflags[a:name] = l:cflags
+                    return l:cflags
+                endif
+            endfor
+        else
+            return s:cflags[a:name]
+        endif
+    endif
+    return ''
+endfunction
+
+" try to find PHP includes with 'php-config'
+function! syntastic#c#CheckPhp()
+    if executable('php-config')
+        if !exists('s:php_flags')
+            let s:php_flags = system('php-config --includes')
+            let s:php_flags = ' ' . substitute(s:php_flags, "\n", '', '')
+        endif
+        return s:php_flags
+    endif
+    return ''
+endfunction
+
+" try to find the ruby headers with 'rbconfig'
+function! syntastic#c#CheckRuby()
+    if executable('ruby')
+        if !exists('s:ruby_flags')
+            let s:ruby_flags = system('ruby -r rbconfig -e '
+                        \ . '''puts RbConfig::CONFIG["rubyhdrdir"] || RbConfig::CONFIG["archdir"]''')
+            let s:ruby_flags = substitute(s:ruby_flags, "\n", '', '')
+            let s:ruby_flags = ' -I' . s:ruby_flags
+        endif
+        return s:ruby_flags
+    endif
+    return ''
+endfunction
+
+" try to find the python headers with distutils
+function! syntastic#c#CheckPython()
+    if executable('python')
+        if !exists('s:python_flags')
+            let s:python_flags = system('python -c ''from distutils import '
+                        \ . 'sysconfig; import sys; sys.stdout.write(sysconfig.get_python_inc())''')
+            let s:python_flags = substitute(s:python_flags, "\n", '', '')
+            let s:python_flags = ' -I' . s:python_flags
+        endif
+        return s:python_flags
+    endif
+    return ''
+endfunction
+
+" return a handler dictionary object
+function! s:RegHandler(regex, function, args)
+    let handler = {}
+    let handler["regex"] = a:regex
+    let handler["func"] = function(a:function)
+    let handler["args"] = a:args
+    call add(s:handlers, handler)
+endfunction
+
+call s:Init()
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
+
+" vim: set et sts=4 sw=4:

File home/dot.vim/autoload/syntastic/makeprg.vim

+if exists("g:loaded_syntastic_makeprg_autoload")
+    finish
+endif
+let g:loaded_syntastic_makeprg_autoload = 1
+
+"Returns a makeprg of the form
+"
+"[exe] [args] [filename] [post_args] [tail]
+"
+"A (made up) example:
+"    ruby -a -b -c test_file.rb --more --args > /tmp/output
+"
+"To generate this you would call:
+"
+"    let makeprg = syntastic#makeprg#build({
+"                \ 'exe': 'ruby',
+"                \ 'args': '-a -b -c',
+"                \ 'post_args': '--more --args',
+"                \ 'tail': '> /tmp/output',
+"                \ 'filetype': 'ruby',
+"                \ 'subchecker': 'mri' })
+"
+"Note that the current filename is added by default - but can be overridden by
+"passing in an 'fname' arg.
+"
+"Arguments 'filetype' and 'subchecker' are mandatory, handling of composite
+"types and user-defined variables breaks if you omit them.
+"
+"All other options can be overriden by the user with global variables - even
+"when not specified by the checker in syntastic#makeprg#build().
+"
+"E.g. They could override the checker exe with
+"
+"   let g:syntastic_ruby_mri_exe="another_ruby_checker_exe.rb"
+"
+"The general form of the override option is:
+"   syntastic_[filetype]_[subchecker]_[option-name]
+"
+function! syntastic#makeprg#build(opts)
+    let builder = g:SyntasticMakeprgBuilder.New(
+                \ get(a:opts, 'exe', ''),
+                \ get(a:opts, 'args', ''),
+                \ get(a:opts, 'fname', ''),
+                \ get(a:opts, 'post_args', ''),
+                \ get(a:opts, 'tail', ''),
+                \ get(a:opts, 'filetype', ''),
+                \ get(a:opts, 'subchecker', '') )
+
+    return builder.makeprg()
+endfunction

File home/dot.vim/autoload/syntastic/postprocess.vim

+if exists("g:loaded_syntastic_postprocess_autoload")
+    finish
+endif
+let g:loaded_syntastic_postprocess_autoload = 1
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+function! s:compareErrorItems(a, b)
+    if a:a['bufnr'] != a:b['bufnr']
+        " group by files
+        return a:a['bufnr'] - a:b['bufnr']
+    elseif a:a['lnum'] != a:b['lnum']
+        return a:a['lnum'] - a:b['lnum']
+    elseif a:a['type'] !=? a:b['type']
+        " errors take precedence over warnings
+        return a:a['type'] ==? 'e' ? -1 : 1
+    else
+        return get(a:a, 'col') - get(a:b, 'col')
+    endif
+endfunction
+
+" natural sort
+function! syntastic#postprocess#sort(errors)
+    return sort(a:errors, 's:compareErrorItems')
+endfunction
+
+function syntastic#postprocess#compressWhitespace(errors)
+    let llist = []
+
+    for e in a:errors
+        let e['text'] = substitute(e['text'], "\001", '', 'g')
+        let e['text'] = substitute(e['text'], '\n', ' ', 'g')
+        let e['text'] = substitute(e['text'], '\s\{2,}', ' ', 'g')
+        call add(llist, e)
+    endfor
+
+    return llist
+endfunction
+
+" remove spurious CR under Cygwin
+function! syntastic#postprocess#cygwinRemoveCR(errors)
+    if has('win32unix')
+        let llist = []
+
+        for e in a:errors
+            let e['text'] = substitute(e['text'], '\r', '', 'g')
+            call add(llist, e)
+        endfor
+    else
+        let llist = a:errors
+    endif
+
+    return llist
+endfunction
+
+" decode XML entities
+function! syntastic#postprocess#decodeXMLEntities(errors)
+    let llist = []
+
+    for e in a:errors
+        let e['text'] = syntastic#util#decodeXMLEntities(e['text'])
+        call add(llist, e)
+    endfor
+
+    return llist
+endfunction
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
+" vim: set et sts=4 sw=4:

File home/dot.vim/autoload/syntastic/util.vim

+if exists("g:loaded_syntastic_util_autoload")
+    finish
+endif
+let g:loaded_syntastic_util_autoload = 1
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+if !exists("g:syntastic_debug")
+    let g:syntastic_debug = 0
+endif
+
+let s:deprecationNoticesIssued = []
+
+function! syntastic#util#DevNull()
+    if has('win32')
+        return 'NUL'
+    endif
+    return '/dev/null'
+endfunction
+
+"search the first 5 lines of the file for a magic number and return a map
+"containing the args and the executable
+"
+"e.g.
+"
+"#!/usr/bin/perl -f -bar
+"
+"returns
+"
+"{'exe': '/usr/bin/perl', 'args': ['-f', '-bar']}
+function! syntastic#util#parseShebang()
+    for lnum in range(1,5)
+        let line = getline(lnum)
+
+        if line =~ '^#!'
+            let exe = matchstr(line, '^#!\s*\zs[^ \t]*')
+            let args = split(matchstr(line, '^#!\s*[^ \t]*\zs.*'))
+            return {'exe': exe, 'args': args}
+        endif
+    endfor
+
+    return {'exe': '', 'args': []}
+endfunction
+
+" Run 'command' in a shell and parse output as a version string.
+" Returns an array of version components.
+function! syntastic#util#parseVersion(command)
+    return split(matchstr( system(a:command), '\v^\D*\zs\d+(\.\d+)+\ze' ), '\.')
+endfunction
+
+" Verify that the 'installed' version is at least the 'required' version.
+"
+" 'installed' and 'required' must be arrays. If they have different lengths,
+" the "missing" elements will be assumed to be 0 for the purposes of checking.
+"
+" See http://semver.org for info about version numbers.
+function! syntastic#util#versionIsAtLeast(installed, required)
+    for index in range(max([len(a:installed), len(a:required)]))
+        if len(a:installed) <= index
+            let installed_element = 0
+        else
+            let installed_element = a:installed[index]
+        endif
+        if len(a:required) <= index
+            let required_element = 0
+        else
+            let required_element = a:required[index]
+        endif
+        if installed_element != required_element
+            return installed_element > required_element
+        endif
+    endfor
+    " Everything matched, so it is at least the required version.
+    return 1
+endfunction
+
+"print as much of a:msg as possible without "Press Enter" prompt appearing
+function! syntastic#util#wideMsg(msg)
+    let old_ruler = &ruler
+    let old_showcmd = &showcmd
+
+    "convert tabs to spaces so that the tabs count towards the window width
+    "as the proper amount of characters
+    let msg = substitute(a:msg, "\t", repeat(" ", &tabstop), "g")
+    let msg = strpart(msg, 0, winwidth(0)-1)
+
+    "This is here because it is possible for some error messages to begin with
+    "\n which will cause a "press enter" prompt. I have noticed this in the
+    "javascript:jshint checker and have been unable to figure out why it
+    "happens
+    let msg = substitute(msg, "\n", "", "g")
+
+    set noruler noshowcmd
+    redraw
+
+    echo msg
+
+    let &ruler=old_ruler
+    let &showcmd=old_showcmd
+endfunction
+
+" Check whether a buffer is loaded, listed, and not hidden
+function! syntastic#util#bufIsActive(buffer)
+    " convert to number, or hell breaks loose
+    let buf = str2nr(a:buffer)
+
+    if !bufloaded(buf) || !buflisted(buf)
+        return 0
+    endif
+
+    " get rid of hidden buffers
+    for tab in range(1, tabpagenr('$'))
+        if index(tabpagebuflist(tab), buf) >= 0
+            return 1
+        endif
+    endfor
+
+    return 0
+endfunction
+
+" start in directory a:where and walk up the parent folders until it
+" finds a file matching a:what; return path to that file
+function! syntastic#util#findInParent(what, where)
+    let here = fnamemodify(a:where, ':p')
+
+    while !empty(here)
+        let p = split(globpath(here, a:what), '\n')
+
+        if !empty(p)
+            return fnamemodify(p[0], ':p')
+        elseif here == '/'
+            break
+        endif
+
+        " we use ':h:h' rather than ':h' since ':p' adds a trailing '/'
+        " if 'here' is a directory
+        let here = fnamemodify(here, ':p:h:h')
+    endwhile
+
+    return ''
+endfunction
+
+" Returns unique elements in a list
+function! syntastic#util#unique(list)
+    let seen = {}
+    let uniques = []
+    for e in a:list
+        if !has_key(seen, e)
+            let seen[e] = 1
+            call add(uniques, e)
+        endif
+    endfor
+    return uniques
+endfunction
+
+" A less noisy shellescape()
+function! syntastic#util#shescape(string)
+    return a:string =~ '\m^[A-Za-z0-9_/.-]\+$' ? a:string : shellescape(a:string)
+endfunction
+
+" A less noisy shellescape(expand())
+function! syntastic#util#shexpand(string)
+    return syntastic#util#shescape(expand(a:string))
+endfunction
+
+" decode XML entities
+function! syntastic#util#decodeXMLEntities(string)
+    let str = a:string
+    let str = substitute(str, '&lt;', '<', 'g')
+    let str = substitute(str, '&gt;', '>', 'g')
+    let str = substitute(str, '&quot;', '"', 'g')
+    let str = substitute(str, '&apos;', "'", 'g')
+    let str = substitute(str, '&amp;', '\&', 'g')
+    return str
+endfunction
+
+function! syntastic#util#debug(msg)
+    if g:syntastic_debug
+        echomsg "syntastic: debug: " . a:msg
+    endif
+endfunction
+
+function! syntastic#util#info(msg)
+    echomsg "syntastic: info: " . a:msg
+endfunction
+
+function! syntastic#util#warn(msg)
+    echohl WarningMsg
+    echomsg "syntastic: warning: " . a:msg
+    echohl None
+endfunction
+
+function! syntastic#util#error(msg)
+    execute "normal \<Esc>"
+    echohl ErrorMsg
+    echomsg "syntastic: error: " . a:msg
+    echohl None
+endfunction
+
+function! syntastic#util#deprecationWarn(msg)
+    if index(s:deprecationNoticesIssued, a:msg) >= 0
+        return
+    endif
+
+    call add(s:deprecationNoticesIssued, a:msg)
+    call syntastic#util#warn(a:msg)
+endfunction
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
+" vim: set et sts=4 sw=4:

File home/dot.vim/doc/fugitive.txt

+*fugitive.txt*  A Git wrapper so awesome, it should be illegal
+
+Author:  Tim Pope <http://tpo.pe/>
+License: Same terms as Vim itself (see |license|)
+
+This plugin is only available if 'compatible' is not set.
+
+INTRODUCTION                                    *fugitive*
+
+Whenever you edit a file from a Git repository, a set of commands is defined
+that serve as a gateway to Git.
+
+COMMANDS                                        *fugitive-commands*
+
+These commands are local to the buffers in which they work (generally, buffers
+that are part of Git repositories).
+
+                                                *fugitive-:Git*
+:Git [args]             Run an arbitrary git command. Similar to :!git [args]
+                        but chdir to the repository tree first.
+
+                                                *fugitive-:Git!*
+:Git! [args]            Like |:Git|, but capture the output into a temp file,
+                        and edit that temp file.
+
+                                                *fugitive-:Gcd*
+:Gcd [directory]        |:cd| relative to the repository.
+
+                                                *fugitive-:Glcd*
+:Glcd [directory]       |:lcd| relative to the repository.
+
+                                                *fugitive-:Gstatus*
+:Gstatus                Bring up the output of git-status in the preview
+                        window.  The following maps, which work on the cursor
+                        line file where sensible, are provided:
+
+                        <C-N> next file
+                        <C-P> previous file
+                        <CR>  |:Gedit|
+                        -     |:Git| add
+                        -     |:Git| reset (staged files)
+                        cA    |:Gcommit| --amend --reuse-message=HEAD
+                        ca    |:Gcommit| --amend
+                        cc    |:Gcommit|
+                        cva   |:Gcommit| --amend --verbose
+                        cvc   |:Gcommit| --verbose
+                        D     |:Gdiff|
+                        ds    |:Gsdiff|
+                        dp    |:Git!| diff (p for patch; use :Gw to apply)
+                        dp    |:Git| add --intent-to-add (untracked files)
+                        dv    |:Gvdiff|
+                        O     |:Gtabedit|
+                        o     |:Gsplit|
+                        p     |:Git| add --patch
+                        p     |:Git| reset --patch (staged files)
+                        q     close status
+                        R     reload status
+                        S     |:Gvsplit|
+
+                                                *fugitive-:Gcommit*
+:Gcommit [args]         A wrapper around git-commit.  If there is nothing
+                        to commit, |:Gstatus| is called instead.  Unless the
+                        arguments given would skip the invocation of an editor
+                        (e.g., -m), a split window will be used to obtain a
+                        commit message.  Write and close that window (:wq or
+                        |:Gwrite|) to finish the commit.  Unlike when running
+                        the actual git-commit command, it is possible (but
+                        unadvisable) to muck with the index with commands like
+                        git-add and git-reset while a commit message is
+                        pending.
+
+                                                *fugitive-:Ggrep*
+:Ggrep [args]           |:grep| with git-grep as 'grepprg'.
+
+                                                *fugitive-:Glgrep*
+:Glgrep [args]          |:lgrep| with git-grep as 'grepprg'.
+
+                                                *fugitive-:Glog*
+:Glog [args]            Load all previous revisions of the current file into
+                        the quickfix list.  Additional git-log arguments can
+                        be given (for example, --reverse).  If "--" appears as
+                        an argument, no file specific filtering is done, and
+                        previous commits rather than previous file revisions
+                        are loaded.
+
+                                                *fugitive-:Gllog*
+:Gllog [args]           Like |:Glog|, but use the location list instead of the
+                        quickfix list.
+
+                                        *fugitive-:Gedit* *fugitive-:Ge*
+:Gedit [revision]       |:edit| a |fugitive-revision|.
+
+                                                *fugitive-:Gsplit*
+:Gsplit [revision]      |:split| a |fugitive-revision|.
+
+                                                *fugitive-:Gvsplit*
+:Gvsplit [revision]     |:vsplit| a |fugitive-revision|.
+
+                                                *fugitive-:Gtabedit*
+:Gtabedit [revision]    |:tabedit| a |fugitive-revision|.
+
+                                                *fugitive-:Gpedit*
+:Gpedit [revision]      |:pedit| a |fugitive-revision|.
+
+:Gsplit! [args]                 *fugitive-:Gsplit!* *fugitive-:Gvsplit!*
+:Gvsplit! [args]                *fugitive-:Gtabedit!* *fugitive-:Gpedit!*
+:Gtabedit! [args]       Like |:Git!|, but open the resulting temp file in a
+:Gpedit! [args]         split, tab, or preview window.
+
+                                                *fugitive-:Gread*
+:Gread [revision]       Empty the buffer and |:read| a |fugitive-revision|.
+                        When the argument is omitted, this is similar to
+                        git-checkout on a work tree file or git-add on a stage
+                        file, but without writing anything to disk.
+
+:{range}Gread [revision]
+                        |:read| in a |fugitive-revision| after {range}.
+
+                                                *fugitive-:Gread!*
+:Gread! [args]          Empty the buffer and |:read| the output of a Git
+                        command.  For example, :Gread! show HEAD:%.
+
+:{range}Gread! [args]  |:read| the output of a Git command after {range}.
+
+                                        *fugitive-:Gw* *fugitive-:Gwrite*
+:Gwrite                 Write to the current file's path and stage the results.
+                        When run in a work tree file, it is effectively git
+                        add.  Elsewhere, it is effectively git-checkout.  A
+                        great deal of effort is expended to behave sensibly
+                        when the work tree or index version of the file is
+                        open in another buffer.
+
+:Gwrite {path}          You can give |:Gwrite| an explicit path of where in
+                        the work tree to write.  You can also give a path like
+                        :0:foo.txt or even :0 to write to just that stage in
+                        the index.
+
+                                                *fugitive-:Gwq*
+:Gwq [path]             Like |:Gwrite| followed by |:quit| if the write
+                        succeeded.
+
+:Gwq! [path]            Like |:Gwrite|! followed by |:quit|! if the write
+                        succeeded.
+
+                                                *fugitive-:Gdiff*
+:Gdiff [revision]       Perform a |vimdiff| against the current file in the
+                        given revision.  With no argument, the version in the
+                        index is used (which means a three-way diff during a
+                        merge conflict, making it a git-mergetool
+                        alternative).  The newer of the two files is placed
+                        to the right.  Use |do| and |dp| and write to the
+                        index file to simulate "git add --patch".
+
+                                                *fugitive-:Gsdiff*
+:Gsdiff [revision]      Like |:Gdiff|, but split horizontally.
+
+                                                *fugitive-:Gvdiff*
+:Gvdiff [revision]      Identical to |:Gdiff|.  For symmetry with |:Gsdiff|.
+
+                                                *fugitive-:Gmove*
+:Gmove {destination}    Wrapper around git-mv that renames the buffer
+                        afterward.  The destination is relative to the current
+                        directory except when started with a /, in which case
+                        it is relative to the work tree.  Add a ! to pass -f.
+
+                                                *fugitive-:Gremove*
+:Gremove                Wrapper around git-rm that deletes the buffer
+                        afterward.  When invoked in an index file, --cached is
+                        passed.  Add a ! to pass -f and forcefully discard the
+                        buffer.
+
+                                                *fugitive-:Gblame*
+:Gblame [flags]         Run git-blame on the file and open the results in a
+                        scroll bound vertical split.  Press enter on a line to
+                        reblame the file as it was in that commit.  You can
+                        give any of ltfnsewMC as flags and they will be passed
+                        along to git-blame.  The following maps, which work on
+                        the cursor line commit where sensible, are provided:
+
+                        A     resize to end of author column
+                        C     resize to end of commit column
+                        D     resize to end of date/time column
+                        q     close blame and return to blamed window
+                        gq    q, then |:Gedit| to return to work tree version
+                        <CR>  q, then open commit
+                        o     open commit in horizontal split
+                        O     open commit in new tab
+                        -     reblame at commit
+                        ~     reblame at [count]th first grandparent
+                        P     reblame at [count]th parent (like HEAD^[count])
+
+:[range]Gblame [flags]  Run git-blame on the given range.
+
+                                                *fugitive-:Gbrowse*
+:[range]Gbrowse         If the remote for the current branch is on GitHub,
+                        open the current file, blob, tree, commit, or tag
+                        (with git-web--browse) on GitHub.  Otherwise, open the
+                        current file, blob, tree, commit, or tag in
+                        git-instaweb (if you have issues, verify you can run
+                        "git instaweb" from a terminal).  If a range is given,
+                        it is appropriately appended to the URL as an anchor.
+
+                        To use with GitHub FI, point g:fugitive_github_domains
+                        at a list of domains:
+>
+                        let g:fugitive_github_domains = ['https://example.com']
+~
+:[range]Gbrowse!        Like :Gbrowse, but put the URL on the clipboard rather
+                        than opening it.
+