neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

hlsplaylist.vim (849B)


      1 " Vim filetype plugin
      2 " Language:     HLS/M3U Playlist
      3 " Maintainer:	AvidSeeker <avidseeker7@protonmail.com>
      4 " Last Change:  2024 Jul 07
      5 "
      6 
      7 if exists("b:did_ftplugin")
      8  finish
      9 endif
     10 let g:did_ftplugin = 1
     11 
     12 setlocal commentstring=#%s
     13 
     14 let b:undo_ftplugin = "setl commentstring<"
     15 
     16 function! M3UFold() abort
     17  let line = getline(v:lnum)
     18  if line =~# '^#EXTGRP'
     19    return ">1"
     20  endif
     21  return "="
     22 endfunction
     23 
     24 function! 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
     30 endfunction
     31 
     32 if has("folding")
     33  setlocal foldexpr=M3UFold()
     34  setlocal foldmethod=expr
     35  setlocal foldtext=M3UFoldText()
     36  let b:undo_ftplugin .= "|setl foldexpr< foldmethod< foldtext<"
     37 endif