1 " Perforce spec filetype plugin file
2 " Language: Perforce Spec File
3 " Maintainer: Hari Krishna Dara <hari_vim at yahoo dot com>
4 " Last Change: 13-Jan-2006 @ 17:38
9 " http://vim.sourceforge.net/scripts/script.php?script_id=240
12 " Only do this when not done yet for this buffer
13 "if exists("b:did_ftplugin")
17 " Don't load another plugin for this buffer
18 let b:did_ftplugin = 1
20 " Set some options suitable for pure text editing.
22 setlocal softtabstop=0
26 setlocal formatoptions=tcqnl
27 setlocal comments=:#,fb:-
30 let b:undo_ftplugin = 'setl ts< sts< sw< et< ai< fo< com< wm< tw<'
32 if !exists("loaded_perforce_ftplugin")
33 let s:patterns{'Change'} = '\%(^Description:\s*\_s\?\s*\)\zs\S\|^Description:'
34 let s:patterns{'Branch'} = '\%(^View:\s*\_s\?\s*\)\zs\S\|^View:'
35 let s:patterns{'Label'} = '\%(^View:\s*\_s\?\s*\)\zs\S\|^View:'
36 let s:patterns{'Client'} = '\%(^View:\s*\_s\?\s*\)\zs\S\|^View:'
37 let s:patterns{'Job'} = '\%(^Job:\s\+\)\@<=new\>\|\%(^Description:\s*\_s\?\s*\)\zs\S\|^Description:'
38 let s:patterns{'Job_Spec'} = '^Fields:'
39 let s:patterns{'User'} = '^User:'
40 let s:patterns{'Depot'} = '\%(^Description:\s*\_s\?\s*\)\zs\S\|^Description:'
41 let s:patterns{'Group'} = '\%(^Users:\s*\_s\?\s*\)\zs\S\|^Users:'
42 " Position cursor on the most appropriate line based on the type of spec being
44 function! s:PositionLine()
45 let specPattern = '^# A Perforce \(.*\) Specification.$'
46 if getline(1) =~ specPattern
47 let spec = substitute(substitute(getline(1), specPattern, '\1', ''), ' ',
49 if spec != "" && exists('s:patterns'. spec) &&
50 \ search(s:patterns{spec}, 'w') != 0
51 let b:p4Pattern = s:patterns{spec}
56 let loaded_perforce_ftplugin=1