From 882519aaeff052c53e2b4369f8c100388766f067 Mon Sep 17 00:00:00 2001 From: Steve Losh Date: Sat, 9 Oct 2010 09:00:41 -0400 Subject: [PATCH] Syntax highlighting! --- plugin/gundo.vim | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/plugin/gundo.vim b/plugin/gundo.vim index 81776b1..ab8f201 100644 --- a/plugin/gundo.vim +++ b/plugin/gundo.vim @@ -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 @@ function! s:GundoRevert() 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 @@ function! s:GundoMarkBuffer() 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 @@ else: result = generate(walk_nodes(dag), asciiedges, current).splitlines() +INLINE_HELP = '''\ +" j/k - move between undo states +" - 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 @@ for line in result: except ValueError: pass i += 1 -vim.command('%d' % i) +vim.command('%d' % (i+3)) ENDPYTHON endfunction