1 " Language: Texte Convivial Technique (TCT)
2 " License: GNU General Public License, version 3 or later (at your option)
3 " Maintainer: Julien Moutinho <julm+hdoc@autogeree.net>
4 " URL: git://git.autogeree.net/hdoc
7 " Copy this file to ~/.vim/ftplugin/tct.vim
8 " then add this line to ~/.vimrc :
9 " autocmd BufNewFile,BufRead *.tct set filetype=tct
10 if exists("b:did_ftplugin")
14 let s:vim_tct_folding_indent = get(g:, "vim_tct_folding_indent", 0)
15 " NOTE: off by default, because quite slow
17 "setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=>\ %s
18 setlocal formatoptions+=tcqln formatoptions-=ro
19 setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:
21 if exists('b:undo_ftplugin')
22 let b:undo_ftplugin .= "|setl cms< com< fo< flp<"
24 let b:undo_ftplugin = "setl cms< com< fo< flp<"
27 function! s:sectionLevel(lnum)
30 let lineCurr = getline(l)
31 let depth = match(lineCurr, '\(^#\+\)\@<=\( .*$\)\@=')
41 let lineCurr = getline(v:lnum)
43 " Fold wrt. section level
44 let depth = match(lineCurr, '\(^#\+\)\@<=\( .*$\)\@=')
49 " Fold wrt. indent level
50 if s:vim_tct_folding_indent == 1
51 let spacesCurr = matchend(lineCurr,"^ *")
52 return s:sectionLevel(v:lnum) + spacesCurr
55 " Keep previous fold level
60 setlocal foldexpr=TctFold()
61 setlocal foldmethod=expr
62 let b:undo_ftplugin .= " foldexpr< foldmethod<"