hlsplaylist.vim 849 B

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