Open c-cube opened 9 years ago
To fold document and section titles I keep the following in ~/.vim/after/ftplugin/asciidoc.vim
:
" From https://github.com/mjakl/vim-asciidoc/
" Fixed it so that it doesn't interpret every line starting with `=` as heading
" Removed conditional fold options
function! Foldexpr_asciidoc(lnum)
let l0 = getline(a:lnum)
if l0 =~ '^=\{1,5}\s\+\S.*$'
return '>'.matchend(l0, '^=\+')
else
return '='
endif
endfunc
setlocal foldexpr=Foldexpr_asciidoc(v:lnum)
setlocal foldmethod=expr
That looks nice. Could we try to merge this into this project, with due credit to https://github.com/mjakl/vim-asciidoc/
? I can make a PR if the maintainers are in favor.
This is 'expression folding' though, not sure it should go in a syntax file. A filetype plugin is probably a better fit–at least the options shouldn't be set in a syntax file.
It's possible to define folds based on syntax. See :help fold-syntax
and :help syn-fold
. An example from the Java syntax file that ships with Vim:
syn region javaFold start="{" end="}" transparent fold
This creates a fold for a syntax region–everything between {
and }
. In the asciidoc syntax file, section titles are not regions but simple syntax matches, so they can't be folded this way. Could probably create a "section" syntax region that starts with a section title and runs until the next section title, then that region could be folded. That's a little more involved than the simple function above.
No news on this? Should keep the above code outside the project? I know that for small documentation purposes this is not important, but for mid-sized it gets more relevance. That and concealing some syntax, like some M↓ plugins do.
Thanks for the plugin and code, BTW.
To fold document and section titles I keep the following in
~/.vim/after/ftplugin/asciidoc.vim
:" From https://github.com/mjakl/vim-asciidoc/ " Fixed it so that it doesn't interpret every line starting with `=` as heading " Removed conditional fold options function! Foldexpr_asciidoc(lnum) let l0 = getline(a:lnum) if l0 =~ '^=\{1,5}\s\+\S.*$' return '>'.matchend(l0, '^=\+') else return '=' endif endfunc setlocal foldexpr=Foldexpr_asciidoc(v:lnum) setlocal foldmethod=expr
Hi!
How could I add text blocks (----,++++,____) as folding elements?
Thanks.
Hello, I really like the asciidoc coloring! A thing I miss compared to other markup languages, though, is folding based on the document structure (e.g., with markdown, I can fold/unfold sections using the usual vim folds). Is adding such a feature possible? Thanks!