82d190d1da64

Syntax highlighting!
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 09 Oct 2010 09:00:41 -0400
parents ae5f399be2c2
children 2513c9fd4319
branches/tags (none)
files plugin/gundo.vim

Changes

--- a/plugin/gundo.vim	Fri Oct 08 22:10:04 2010 -0400
+++ b/plugin/gundo.vim	Sat Oct 09 09:00:41 2010 -0400
@@ -16,7 +16,7 @@
 "let loaded_gundo = 1
 
 if !exists('g:gundo_width')
-    let g:gundo_width = 40
+    let g:gundo_width = 45
 endif
 
 function! s:GundoOpenBuffer()
@@ -50,6 +50,8 @@
     let back = bufwinnr(s:gundo_back)
     exe back . "wincmd w"
     exe "undo " . target_num
+    GundoRender
+    exe back . "wincmd w"
 endfunction
 
 function! s:GundoToggle()
@@ -68,9 +70,23 @@
     setlocal noswapfile
     setlocal buflisted
     setlocal nomodifiable
+    setlocal filetype=gundo
+    call s:GundoSyntax()
 endfunction
 
+function! s:GundoSyntax()
+    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
 
 
 
@@ -447,10 +463,16 @@
 
 result = generate(walk_nodes(dag), asciiedges, current).splitlines()
 
+INLINE_HELP = '''\
+" j/k  - move between undo states
+" <cr> - revert to that state
+
+'''.splitlines()
+
 vim.command('GundoOpenBuffer')
 vim.command('setlocal modifiable')
 vim.command('normal ggdG')
-vim.current.buffer.append(result)
+vim.current.buffer.append(INLINE_HELP + result)
 vim.command('setlocal nomodifiable')
 
 i = 1
@@ -462,7 +484,7 @@
     except ValueError:
         pass
     i += 1
-vim.command('%d' % i)
+vim.command('%d' % (i+3))
 
 ENDPYTHON
 endfunction