robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1" Vim filetype plugin file 2" Language: iCalendar 3" Maintainer: Anakin Childerhose <anakin@childerhose.ca> 4" Latest Change: 2026 Sept 22 5" License: Vim (see :h license) 6 7if exists ( 'b:did_ftplugin' ) 8finish 9endif 10let b: did_ftplugin = 1 11 12let b: undo_ftplugin = '' 13 14let s: cpo_save = & cpo 15set cpo & vim 16 17if exists ( 'g:loaded_matchit' ) && ! exists ( 'b:match_words' ) 18let b: match_words = '\<BEGIN\:.*\>:\<END\:.*\>' 19let b: undo_ftplugin ..= '| unlet! b:match_words' 20endif 21 22function s: icalendarComponentFold () abort 23if get ( b:, 'icalendar_fold_tick' , -1 ) == b: changedtick 24return get ( b: icalendar_fold_levels , v: lnum - 1 , '=' ) 25endif 26 27let levels = repeat ([ '=' ], line ( '$' )) 28let depth = 0 29for match in matchbufline ( '%' , '\C^\%(BEGIN\|END\):.*' , 1 , '$' ) 30if match . text =~# '^BEGIN:' 31let depth += 1 32let levels [ match . lnum - 1 ] = '>' .. depth 33elseif match . text =~# '^END:' && depth > 0 34let levels [ match . lnum - 1 ] = '<' .. depth 35let depth -= 1 36endif 37endfor 38 39let b: icalendar_fold_levels = levels 40let b: icalendar_fold_tick = b: changedtick 41return get ( levels , v: lnum - 1 , '=' ) 42endfunction 43 44if has ( 'folding' ) && exists ( '*matchbufline' ) && get ( g:, 'icalendar_folding' , 0 ) 45setlocal foldexpr = s :icalendarComponentFold() 46setlocal foldmethod = expr 47let b: undo_ftplugin ..= '| setlocal foldexpr< foldmethod< | unlet! b:icalendar_fold_tick b:icalendar_fold_levels' 48endif 49 50let & cpo = s: cpo_save 51unlet s: cpo_save 52 53" vim: ts=2 sw=2