robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
c7a9404019
master
1" Vim filetype plugin file 2" Original Author: Maxim Kim <habamax@gmail.com> 3" Previous Maintainer: Luca Saccarola <github.e41mv@aleeas.com> 4" Maintainer: This runtime file is looking for a new maintainer. 5" Language: asciidoc 6" Last Change: 2025 Aug 05 7 8if exists ( "b:did_ftplugin" ) 9finish 10endif 11let b: did_ftplugin = 1 12 13if exists ( 'b:undo_ftplugin' ) 14let b: undo_ftplugin .= "|setl cms< com< fo< flp< inex< efm< cfu< fde< fdm<" 15else 16let b: undo_ftplugin = "setl cms< com< fo< flp< inex< efm< cfu< fde< fdm<" 17endif 18 19" gf to open include::file.ext[] and link:file.ext[] files 20setlocal includeexpr = substitute (v:fname,'\\(link:\\\|include::\\)\\(.\\{-}\\)\\[ .*','\\2','g') 21 22setlocal comments = 23setlocal commentstring = //\ %s 24 25setlocal formatoptions += cqn 26setlocal formatlistpat = ^\\s*[\\[({]\\?\\([0-9]\\+ 27setlocal formatlistpat += \\\|[a-zA-Z]\\)[\\]:.)}]\\s\\+ 28setlocal formatlistpat += \\\|^\\s*-\\s\\+ 29setlocal formatlistpat += \\\|^\\s*[*]\\+\\s\\+ 30setlocal formatlistpat += \\\|^\\s*[.]\\+\\s\\+ 31 32function AsciidocFold () 33let line = getline ( v: lnum ) 34 35if ( v: lnum == 1 ) && ( line =~ '^----*$' ) 36return ">1" 37endif 38 39let nested = get ( g:, "asciidoc_foldnested" , 1 ) 40 41" Regular headers 42let depth = match ( line , '\(^=\+\)\@<=\( .*$\)\@=' ) 43 44" Do not fold nested regular headers 45if depth > 1 && ! nested 46let depth = 1 47endif 48 49if depth > 0 50" fold all sections under title 51if depth > 1 && ! get ( g:, "asciidoc_fold_under_title" , 1 ) 52let depth -= 1 53endif 54" check syntax, it should be asciidocTitle or asciidocH 55let syncode = synstack ( v: lnum , 1 ) 56if len ( syncode ) > 0 && synIDattr ( syncode [ 0 ], 'name' ) =~ 'asciidoc\%(H[1-6]\)\|Title' 57return ">" . depth 58endif 59endif 60 61return "=" 62endfunction 63 64if has ( "folding" ) && get ( g:, 'asciidoc_folding' , 0 ) 65setlocal foldexpr = AsciidocFold () 66setlocal foldmethod = expr 67let b: undo_ftplugin .= "|setl foldexpr< foldmethod< foldtext<" 68endif