HEX
Server: Apache/2.4.65 (Debian)
System: Linux 88f31f35b0b8 6.1.0-38-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.147-1 (2025-08-02) x86_64
User: www-data (33)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/share/vim/vim91/ftplugin/hlsplaylist.vim
" Vim filetype plugin
" Language:     HLS/M3U Playlist
" Maintainer:	AvidSeeker <avidseeker7@protonmail.com>
" Last Change:  2024 Jul 07
"

if exists("b:did_ftplugin")
  finish
endif
let g:did_ftplugin = 1

setlocal commentstring=#%s

let b:undo_ftplugin = "setl commentstring<"

function! M3UFold() abort
  let line = getline(v:lnum)
  if line =~# '^#EXTGRP'
    return ">1"
  endif
  return "="
endfunction

function! M3UFoldText() abort
  let start_line = getline(v:foldstart)
  let title = substitute(start_line, '^#EXTGRP:*', '', '')
  let foldsize = (v:foldend - v:foldstart + 1)
  let linecount = '['.foldsize.' lines]'
  return title.' '.linecount
endfunction

if has("folding")
  setlocal foldexpr=M3UFold()
  setlocal foldmethod=expr
  setlocal foldtext=M3UFoldText()
  let b:undo_ftplugin .= "|setl foldexpr< foldmethod< foldtext<"
endif