codekingpro/portable-devtools
114k
1" Vim filetype plugin file2" 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: asciidoc6" Last Change: 2025 Aug 057 8if exists("b:did_ftplugin")9 finish10endif11let b:did_ftplugin = 112 13if exists('b:undo_ftplugin')14 let b:undo_ftplugin .= "|setl cms< com< fo< flp< inex< efm< cfu< fde< fdm<"15else16 let b:undo_ftplugin = "setl cms< com< fo< flp< inex< efm< cfu< fde< fdm<"17endif18 19" gf to open include::file.ext[] and link:file.ext[] files20setlocal includeexpr=substitute(v:fname,'\\(link:\\\|include::\\)\\(.\\{-}\\)\\[.*','\\2','g')21 22setlocal comments=23setlocal commentstring=//\ %s24 25setlocal formatoptions+=cqn26setlocal 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()33 let line = getline(v:lnum)34 35 if (v:lnum == 1) && (line =~ '^----*$')36 return ">1"37 endif38 39 let nested = get(g:, "asciidoc_foldnested", 1)40 41 " Regular headers42 let depth = match(line, '\(^=\+\)\@<=\( .*$\)\@=')43 44 " Do not fold nested regular headers45 if depth > 1 && !nested46 let depth = 147 endif48 49 if depth > 050 " fold all sections under title51 if depth > 1 && !get(g:, "asciidoc_fold_under_title", 1)52 let depth -= 153 endif54 " check syntax, it should be asciidocTitle or asciidocH55 let syncode = synstack(v:lnum, 1)56 if len(syncode) > 0 && synIDattr(syncode[0], 'name') =~ 'asciidoc\%(H[1-6]\)\|Title'57 return ">" . depth58 endif59 endif60 61 return "="62endfunction63 64if has("folding") && get(g:, 'asciidoc_folding', 0)65 setlocal foldexpr=AsciidocFold()66 setlocal foldmethod=expr67 let b:undo_ftplugin .= "|setl foldexpr< foldmethod< foldtext<"68endif69 