aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-12-30 19:53:38 +1300
committerTom Ryder <tom@sanctum.geek.nz>2019-12-30 19:53:38 +1300
commiteb133bd8aea1800ea6ad75bd1642a4c4271bf1c9 (patch)
tree655c338ee0dbd8b02a9372248e2c833f50211f50 /vim/autoload
parentRemove unneeded map#() autoload function (diff)
downloaddotfiles-eb133bd8aea1800ea6ad75bd1642a4c4271bf1c9.tar.gz
dotfiles-eb133bd8aea1800ea6ad75bd1642a4c4271bf1c9.zip
Move Markdown folding into function
Diffstat (limited to 'vim/autoload')
-rw-r--r--vim/autoload/markdown.vim23
1 files changed, 23 insertions, 0 deletions
diff --git a/vim/autoload/markdown.vim b/vim/autoload/markdown.vim
index 6c8187a0..cdd14c12 100644
--- a/vim/autoload/markdown.vim
+++ b/vim/autoload/markdown.vim
@@ -1,3 +1,26 @@
+" Let's try this heading-based fold method out (Tim Pope)
+function! markdown#Fold()
+ let line = getline(v:lnum)
+
+ " Regular headers
+ let depth = match(line, '\(^#\+\)\@<=\( .*$\)\@=')
+ if depth > 0
+ return '>' . depth
+ endif
+
+ " Setext style headings
+ if line =~# '^.\+$'
+ let nextline = getline(v:lnum + 1)
+ if nextline =~# '^=\+$'
+ return '>1'
+ elseif nextline =~# '^-\+$'
+ return '>2'
+ endif
+ endif
+
+ return '='
+endfunction
+
" Add an underline under a heading
function! markdown#Heading(char) abort