From f193fffd16563cfbe7c02a21e19c8bb11707581d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 27 Apr 2006 00:02:13 +0000 Subject: updated for version 7.0f02 --- runtime/ftplugin/debchangelog.vim | 52 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'runtime/ftplugin/debchangelog.vim') 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 -" Last Change: 15 August 2005 +" Stefano Zacchiroli +" 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: -- cgit v1.2.1