r1047 - /trunk/runtime/ftplugin/debchangelog.vim
jamessan at users.alioth.debian.org
jamessan at users.alioth.debian.org
Sat Sep 29 22:41:33 UTC 2007
Author: jamessan
Date: Sat Sep 29 22:41:33 2007
New Revision: 1047
URL: http://svn.debian.org/wsvn/?sc=1&rev=1047
Log:
Add the bug omnicompletion for debchangelogs and remove a duplicate foldopen command.
Modified:
trunk/runtime/ftplugin/debchangelog.vim
Modified: trunk/runtime/ftplugin/debchangelog.vim
URL: http://svn.debian.org/wsvn/trunk/runtime/ftplugin/debchangelog.vim?rev=1047&op=diff
==============================================================================
--- trunk/runtime/ftplugin/debchangelog.vim (original)
+++ trunk/runtime/ftplugin/debchangelog.vim Sat Sep 29 22:41:33 2007
@@ -1,4 +1,4 @@
-" Vim filetype plugin file (GUI menu and folding)
+" Vim filetype plugin file (GUI menu, folding and completion)
" Language: Debian Changelog
" Maintainer: Michael Piefel <piefel at informatik.hu-berlin.de>
" Stefano Zacchiroli <zack at debian.org>
@@ -15,7 +15,7 @@
if !exists("g:debchangelog_fold_disable")
setlocal foldmethod=expr
endif
-setlocal foldexpr=GetDebChangelogFold(v:lnum)
+setlocal foldexpr=DebGetChangelogFold(v:lnum)
setlocal foldtext=DebChangelogFoldText()
" Debian changelogs are not supposed to have any other text width,
@@ -242,6 +242,22 @@
return '[unknown]'
endfunction
+" Look for a package source name searching backward from the givenline and
+" returns it. Return the empty string if the package name can't be found
+function! DebGetPkgSrcName(lineno)
+ let lineidx = a:lineno
+ let pkgname = ''
+ while lineidx > 0
+ let curline = getline(lineidx)
+ if curline =~ '^\S'
+ let pkgname = matchlist(curline, '^\(\S\+\).*$')[1]
+ break
+ endif
+ let lineidx = lineidx - 1
+ endwhile
+ return pkgname
+endfunction
+
function! DebChangelogFoldText()
if v:folddashes == '-' " changelog entry fold
return foldtext() . ' -- ' . s:getAuthor(v:foldstart, v:foldend) . ' '
@@ -249,7 +265,7 @@
return foldtext()
endfunction
-function! GetDebChangelogFold(lnum)
+function! DebGetChangelogFold(lnum)
let line = getline(a:lnum)
if line =~ '^\w\+'
return '>1' " beginning of a changelog entry
@@ -267,4 +283,47 @@
" }}}
+" {{{1 omnicompletion for Closes: #
+
+if !exists('g:debchangelog_listbugs_severities')
+ let g:debchangelog_listbugs_severities = 'critical,grave,serious,important,normal,minor,wishlist'
+endif
+
+fun! DebCompleteBugs(findstart, base)
+ if a:findstart
+ " it we are just after an '#', the completion should start at the '#',
+ " otherwise no completion is possible
+ let line = getline('.')
+ let colidx = col('.')
+ if colidx > 1 && line[colidx - 2] =~ '#'
+ let colidx = colidx - 2
+ else
+ let colidx = -1
+ endif
+ return colidx
+ else
+ if ! filereadable('/usr/sbin/apt-listbugs')
+ echoerr 'apt-listbugs not found, you should install it to use Closes bug completion'
+ return
+ endif
+ let pkgsrc = DebGetPkgSrcName(line('.'))
+ let listbugs_output = system('apt-listbugs -s ' . g:debchangelog_listbugs_severities . ' list ' . pkgsrc . ' | grep "^ #" 2> /dev/null')
+ let bug_lines = split(listbugs_output, '\n')
+ let completions = []
+ for line in bug_lines
+ let parts = matchlist(line, '^\s*\(#\S\+\)\s*-\s*\(.*\)$')
+ let completion = {}
+ let completion['word'] = parts[1]
+ let completion['menu'] = parts[2]
+ let completion['info'] = parts[0]
+ let completions += [completion]
+ endfor
+ return completions
+ endif
+endfun
+
+setlocal omnifunc=DebCompleteBugs
+
+" }}}
+
" vim: set foldmethod=marker:
More information about the pkg-vim-maintainers
mailing list