Skip to content

Commit

Permalink
Vim pathogen
Browse files Browse the repository at this point in the history
  • Loading branch information
cdaddr committed Dec 20, 2010
1 parent cb3f8e3 commit bad01be
Show file tree
Hide file tree
Showing 27 changed files with 1,155 additions and 3 deletions.
132 changes: 132 additions & 0 deletions .vim/autoload/pathogen.vim
@@ -0,0 +1,132 @@
" pathogen.vim - path option manipulation
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
" Version: 1.2

" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
"
" API is documented below.

if exists("g:loaded_pathogen") || &cp
finish
endif
let g:loaded_pathogen = 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 has_key(seen,a:list[i])
call remove(a:list,i)
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

" Prepend all subdirectories of path to the rtp, and append all after
" directories in those subdirectories.
function! pathogen#runtime_prepend_subdirectories(path) " {{{1
let sep = pathogen#separator()
let before = pathogen#glob_directories(a:path.sep."*[^~]")
let after = pathogen#glob_directories(a:path.sep."*[^~]".sep."after")
let rtp = pathogen#split(&rtp)
let path = expand(a:path)
call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
return &rtp
endfunction " }}}1

" For each directory in rtp, check for a subdirectory named dir. If it
" exists, add all subdirectories of that subdirectory to the rtp, immediately
" after the original directory. If no argument is given, 'bundle' is used.
" Repeated calls with the same arguments are ignored.
function! pathogen#runtime_append_all_bundles(...) " {{{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$'
let list += pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after') + [dir]
else
let list += [dir] + pathogen#glob_directories(dir.sep.name.sep.'*[^~]')
endif
endfor
let &rtp = pathogen#join(pathogen#uniq(list))
return 1
endfunction

let s:done_bundles = ''
" }}}1

" Invoke :helptags on all non-$VIM doc directories in runtimepath.
function! pathogen#helptags() " {{{1
for dir in pathogen#split(&rtp)
if dir[0 : strlen($VIM)-1] !=# $VIM && isdirectory(dir.'/doc') && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
helptags `=dir.'/doc'`
endif
endfor
endfunction " }}}1

" vim:set ft=vim ts=8 sw=2 sts=2:
Binary file added .vim/bundle/gundo.vim/.hg/00changelog.i
Binary file not shown.
1 change: 1 addition & 0 deletions .vim/bundle/gundo.vim/.hg/branch
@@ -0,0 +1 @@
default
2 changes: 2 additions & 0 deletions .vim/bundle/gundo.vim/.hg/branchheads.cache
@@ -0,0 +1,2 @@
40049e1b235d68d8d4e35d3f21bab89fd39fbc1a 36
40049e1b235d68d8d4e35d3f21bab89fd39fbc1a default
Binary file added .vim/bundle/gundo.vim/.hg/dirstate
Binary file not shown.
2 changes: 2 additions & 0 deletions .vim/bundle/gundo.vim/.hg/hgrc
@@ -0,0 +1,2 @@
[paths]
default = http://bitbucket.org/sjl/gundo.vim
3 changes: 3 additions & 0 deletions .vim/bundle/gundo.vim/.hg/requires
@@ -0,0 +1,3 @@
revlogv1
store
fncache
Binary file added .vim/bundle/gundo.vim/.hg/store/00changelog.i
Binary file not shown.
Binary file added .vim/bundle/gundo.vim/.hg/store/00manifest.i
Binary file not shown.
Binary file added .vim/bundle/gundo.vim/.hg/store/data/.hgignore.i
Binary file not shown.
Binary file added .vim/bundle/gundo.vim/.hg/store/data/.hgtags.i
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions .vim/bundle/gundo.vim/.hg/store/fncache
@@ -0,0 +1,5 @@
data/.hgignore.i
data/.hgtags.i
data/README.markdown.i
data/doc/gundo.txt.i
data/plugin/gundo.vim.i
Binary file added .vim/bundle/gundo.vim/.hg/store/undo
Binary file not shown.
4 changes: 4 additions & 0 deletions .vim/bundle/gundo.vim/.hg/tags.cache
@@ -0,0 +1,4 @@
36 40049e1b235d68d8d4e35d3f21bab89fd39fbc1a e2c49b93bf7f235e769a8b5cfae330dc2edb8180

4101cbccf1d5fd0cfb81a3c6757c8f71657c1243 semver
4101cbccf1d5fd0cfb81a3c6757c8f71657c1243 v0.8.0
1 change: 1 addition & 0 deletions .vim/bundle/gundo.vim/.hg/undo.branch
@@ -0,0 +1 @@
default
3 changes: 3 additions & 0 deletions .vim/bundle/gundo.vim/.hg/undo.desc
@@ -0,0 +1,3 @@
0
pull
http://bitbucket.org/sjl/gundo.vim
Empty file.
5 changes: 5 additions & 0 deletions .vim/bundle/gundo.vim/.hgignore
@@ -0,0 +1,5 @@
syntax:glob

*.un~
*.pyc
tags
2 changes: 2 additions & 0 deletions .vim/bundle/gundo.vim/.hgtags
@@ -0,0 +1,2 @@
4101cbccf1d5fd0cfb81a3c6757c8f71657c1243 v0.8.0
4101cbccf1d5fd0cfb81a3c6757c8f71657c1243 semver
50 changes: 50 additions & 0 deletions .vim/bundle/gundo.vim/README.markdown
@@ -0,0 +1,50 @@
<a href="http://flattr.com/thing/74149/Gundo-vim" target="_blank">
<img src="http://api.flattr.com/button/button-compact-static-100x17.png" alt="Flattr this" title="Flattr this" border="0" /></a>

Gundo.vim is Vim plugin to visualize your Vim undo tree.

Current status: Beta. It might eat your data. Be careful.
=========================================================

Preview
-------


Screenshot:

<a href="http://www.flickr.com/photos/sjl7678/5093114605/" title="gundo by stevelosh, on Flickr"><img src="http://farm5.static.flickr.com/4113/5093114605_ebc46d6494.jpg" width="487" height="500" alt="gundo" /></a>

Screencast: [http://screenr.com/M9l](http://screenr.com/M9l)


Requirements
------------

* Vim 7.3+
* Python support for Vim.
* Python 2.5+.

Installation
------------

Use [Pathogen][]. Don't use pathogen? Start.

Add a mapping to your `~/.vimrc` (change the key to suit your taste):

nnoremap <F5> :GundoToggle<CR>

[Pathogen]: http://www.vim.org/scripts/script.php?script_id=2332

Usage
-----

When you're editing a file you can bring up the undo graph for that file with
`<F5>` (or whatever key you mapped it to).

Press `<F5>` again to close the undo graph and return to your file.

Use `j` and `k` to move up and down the graph. The preview pane will update with
a diff of the change made by the undo state you're currently on.

Press return to revert the file's contents to that undo state and return to the
file.
128 changes: 128 additions & 0 deletions .vim/bundle/gundo.vim/doc/gundo.txt
@@ -0,0 +1,128 @@
*gundo.txt* Graph your undo tree so you can actually USE it.


CURRENT STATUS: BETA

IT MIGHT EAT YOUR DATA

SERIOUSLY: IF YOU USE THIS PLUGIN, LOSE DATA AND COMPLAIN ABOUT IT
I AM GOING TO MAKE FUN OF YOU ON TWITTER


Making's Vim's undo tree usable by humans.

==============================================================================
1. Intro *Gundo-plugin* *Gundo*

You know that Vim lets you undo changes like any text editor. What you might
not know is that it doesn't just keep a list of your changes -- it keeps
a goddamed |:undo-tree| of them.

Say you make a change (call it X), undo that change, and then make another
change (call it Y). With most editors, change X is now gone forever. With Vim
you can get it back.

The problem is that trying to do this in the real world is painful. Vim gives
you an |:undolist| command that shows you the leaves of the tree. Good luck
finding the change you want in that list.

Gundo is a plugin to make browsing this ridiculously powerful undo tree less
painful.

==============================================================================
2. Usage *GundoUsage*

We'll get to the technical details later, but if you're a human the first
thing you need to do is add a mapping to your |:vimrc| to toggle the undo
graph: >

nnoremap <F5> :GundoToggle<CR>

Change the mapped key to suit your taste. We'll stick with F5 because that's
what the author uses.

Now you can press F5 to toggle the undo graph and preview pane, which will
look something like this: >

Undo graph File
+-----------------------------------+------------------------------------+
| " Gundo for something.txt [1] |one |
| " j/k - move between undo states |two |
| " <cr> - revert to that state |three |
| |five |
| @ [5] 3 hours ago | |
| | | |
| | o [4] 4 hours ago | |
| | | | |
| o | [3] 4 hours ago | |
| | | | |
| o | [2] 4 hours ago | |
| |/ | |
| o [1] 4 hours ago | |
| | | |
| o [0] Original | |
+-----------------------------------+ |
| --- 3 2010-10-12 06:27:35 PM | |
| +++ 5 2010-10-12 07:38:37 PM | |
| @@ -1,3 +1,4 | |
| one | |
| two | |
| three | |
| +five | |
+-----------------------------------+------------------------------------+
Preview pane

Your current position in the undo tree is marked with an '@' character. Other
nodes are marked with an 'o' character.

When you toggle open the graph Gundo will put your cursor on your current
position in the tree. You can move up and down the graph with the j and
k keys.

You can move to the top of the graph (the newest state) with gg and to the
bottom of the graph (the oldest state) with G.

As you move between undo states the preview pane will show you a unified diff
of the change that state made.

Pressing enter on a state will revert the contents of the file to match that
state.

Pressing P while on a state will initiate "play to" mode targeted at that
state. This will replay all the changes between your current state and the
target, with a slight pause after each change. It's mostly useless, but can be
fun to watch and see where your editing lags -- that might be a good place to
define a new mapping to speed up your editing.

Pressing q while in the undo graph will close it. You can also just press your
toggle mapping key.

==============================================================================
3. License *GundoLicense*

GPLv2+. Look it up.

==============================================================================
4. Bugs *GundoBugs*

If you find a bug please post it on the issue tracker:
http://bitbucket.org/sjl/gundo.vim/issues?status=new&status=open

==============================================================================
5. Contributing *GundoContributing*

Think you can make this plugin better? Awesome. Fork it on BitBucket or GitHub
and send a pull request.

BitBucket: http://bitbucket.org/sjl/gundo.vim/
GitHub: http://github.com/sjl/gundo.vim/

==============================================================================
6. Credits *GundoCredits*

The graphing code was all taken from Mercurial, hence the GPLv2+ license.

The plugin was heavily inspired by histwin.vim, and the code for scratch.vim
helped the author get started.

==============================================================================

0 comments on commit bad01be

Please sign in to comment.