diff options
author | Bram Moolenaar <Bram@vim.org> | 2006-04-27 00:02:13 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2006-04-27 00:02:13 +0000 |
commit | f193fffd16563cfbe7c02a21e19c8bb11707581d (patch) | |
tree | 4bae3092421aa986103b8000b1012989a9ea49e6 /runtime/ftplugin/debchangelog.vim | |
parent | 551dbcc9b604c2992f908fb475e797fcc116315b (diff) | |
download | vim-git-f193fffd16563cfbe7c02a21e19c8bb11707581d.tar.gz |
updated for version 7.0f02v7.0f02
Diffstat (limited to 'runtime/ftplugin/debchangelog.vim')
-rw-r--r-- | runtime/ftplugin/debchangelog.vim | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/runtime/ftplugin/debchangelog.vim b/runtime/ftplugin/debchangelog.vim index 59f601ad0..6d1f20ee3 100644 --- a/runtime/ftplugin/debchangelog.vim +++ b/runtime/ftplugin/debchangelog.vim @@ -1,7 +1,9 @@ -" Vim filetype plugin file +" Vim filetype plugin file (GUI menu and folding) " Language: Debian Changelog " Maintainer: Michael Piefel <piefel@informatik.hu-berlin.de> -" Last Change: 15 August 2005 +" Stefano Zacchiroli <zack@debian.org> +" Last Change: 25 April 2006 +" License: GNU GPL, version 2.1 or later if exists("g:did_changelog_ftplugin") finish @@ -10,6 +12,8 @@ endif " Don't load another plugin (this is global) let g:did_changelog_ftplugin = 1 +" {{{1 GUI menu + " Helper functions returning various data. " Returns full name, either from $DEBFULLNAME or debianfullname. " TODO Is there a way to determine name from anywhere else? @@ -204,3 +208,47 @@ augroup END setlocal tw=78 setlocal comments=f:* let b:undo_ftplugin = "setlocal tw< comments<" + +" }}} +" {{{1 folding + +setlocal foldmethod=expr +set foldexpr=GetDebChangelogFold(v:lnum) +setlocal foldtext=DebChangelogFoldText() + +" look for an author name searching backward from a given line number +function! s:getAuthor(lnum) + let line = getline(a:lnum) + let backsteps = 0 + while line !~ '^ --' + let backsteps += 1 + let line = getline(a:lnum - backsteps) + endwhile + let author = substitute(line, '^ --\s*\([^<]\+\)\s*.*', '\1', '') + return author +endfunction + +function! DebChangelogFoldText() + if v:folddashes == '-' " changelog entry fold + return foldtext() . ' -- ' . s:getAuthor(v:foldend) . ' ' + endif + return foldtext() +endfunction + +function! GetDebChangelogFold(lnum) + let line = getline(a:lnum) + if line =~ '^\w\+' + return '>1' " beginning of a changelog entry + endif + if line =~ '^\s\+\[.*\]' + return '>2' " beginning of an author-specific chunk + endif + if line =~ '^ --' + return '1' + endif + return '=' +endfunction + +" }}} + +" vim: set foldmethod=marker: |