blob: 879a04f0f96dafa48a3c43d12bb37eb9825d9d0b [file] [log] [blame]
AvidSeekerab03dd22024-07-08 21:10:08 +02001" Vim filetype plugin
2" Language: HLS/M3U Playlist
3" Maintainer: AvidSeeker <avidseeker7@protonmail.com>
4" Last Change: 2024 Jul 07
5"
6
7if exists("b:did_ftplugin")
8 finish
9endif
10let g:did_ftplugin = 1
11
12setlocal commentstring=#%s
13
14let b:undo_ftplugin = "setl commentstring<"
15
16function! M3UFold() abort
17 let line = getline(v:lnum)
18 if line =~# '^#EXTGRP'
19 return ">1"
20 endif
21 return "="
22endfunction
23
24function! M3UFoldText() abort
25 let start_line = getline(v:foldstart)
26 let title = substitute(start_line, '^#EXTGRP:*', '', '')
27 let foldsize = (v:foldend - v:foldstart + 1)
28 let linecount = '['.foldsize.' lines]'
29 return title.' '.linecount
30endfunction
31
32if has("folding")
33 setlocal foldexpr=M3UFold()
34 setlocal foldmethod=expr
35 setlocal foldtext=M3UFoldText()
36 let b:undo_ftplugin .= "|setl foldexpr< foldmethod< foldtext<"
37endif