Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
debcontrol.vim74 linesDownload Raw Back to ftplugin
1" Vim filetype plugin file (GUI menu and folding)2" Language:     Debian control files3" Maintainer:   Debian Vim Maintainers4" Former Maintainer:    Pierre Habouzit <madcoder@debian.org>5" Last Change:  2024 May 256" URL:          https://salsa.debian.org/vim-team/vim-debian/blob/main/ftplugin/debcontrol.vim7 8" Do these settings once per buffer9if exists('b:did_ftplugin')10  finish11endif12let b:did_ftplugin=113 14" {{{1 Local settings (do on every load)15if exists('g:debcontrol_fold_enable')16  setlocal foldmethod=expr17  setlocal foldexpr=DebControlFold(v:lnum)18  setlocal foldtext=DebControlFoldText()19endif20setlocal textwidth=021 22setlocal comments=:#23setlocal commentstring=#\ %s24 25" Clean unloading26let b:undo_ftplugin = 'setlocal tw< foldmethod< foldexpr< foldtext< comments< commentstring<'27 28" }}}129 30" {{{1 folding31 32function! s:getField(f, lnum)33  let line = getline(a:lnum)34  let fwdsteps = 035  while line !~ '^'.a:f.':'36    let fwdsteps += 137    let line = getline(a:lnum + fwdsteps)38    if line ==# ''39      return 'unknown'40    endif41  endwhile42  return substitute(line, '^'.a:f.': *', '', '')43endfunction44 45function! DebControlFoldText()46  if v:folddashes ==# '-'  " debcontrol entry fold47    let type = substitute(getline(v:foldstart), ':.*', '', '')48    if type ==# 'Source'49      let ftext = substitute(foldtext(), ' *Source: *', ' ', '')50      return ftext . ' -- ' . s:getField('Maintainer', v:foldstart) . ' '51    endif52    let arch  = s:getField('Architecture', v:foldstart)53    let ftext = substitute(foldtext(), ' *Package: *', ' [' . arch . '] ', '')54    return ftext . ': ' . s:getField('Description', v:foldstart) . ' '55  endif56  return foldtext()57endfunction58 59function! DebControlFold(l)60 61  " This is for not merging blank lines around folds to them62  if getline(a:l) =~# '^Source:'63    return '>1'64  endif65 66  if getline(a:l) =~# '^Package:'67    return '>1'68  endif69 70  return '='71endfunction72 73" }}}174 
codekingpro/portable-devtools · Team Ai