From 7221629d8d1e82d6c8feb00a4201f0934f0595f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20M=C3=A4der?= <maeder@phys.ethz.ch> Date: Tue, 16 Apr 2019 09:24:57 +0200 Subject: [PATCH] Add custom markdown folding rda --- profile/rda/.vimrc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/profile/rda/.vimrc b/profile/rda/.vimrc index 7601aa9..6cc327b 100644 --- a/profile/rda/.vimrc +++ b/profile/rda/.vimrc @@ -241,7 +241,7 @@ au filetype markdown syntax match RedTodo /TODO/ let g:markdown_folding = 1 au filetype markdown setlocal foldlevel=1 -let g:markdown_fenced_languages = ['ruby', 'perl', 'bash=sh', 'sh', 'vim', 'html', 'javascript', 'css', 'python'] +let g:markdown_fenced_languages = ['ruby', 'perl', 'bash=sh', 'sh', 'vim', 'html', 'javascript', 'css', 'python', 'yaml'] let g:markdown_minlines = 100 "synchronize syntax highlighting with more lines (default:50) ""Enable concealing of links (https://github.com/tpope/vim-markdown/pull/9/commits/44dec444c959fa57c2fc835980ad15dbbbf11d1c) @@ -249,6 +249,28 @@ let g:markdown_minlines = 100 "synchronize syntax highlighting with more l "au filetype markdown syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained conceal "au filetype markdown syn region markdownId matchgroup=markdownIdDelimiter start="\s*\[" end="\]" keepend contained conceal "au filetype markdown syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline concealends + +"Custom markdown folding +au filetype markdown setlocal foldexpr=MyMarkdownFold() +au filetype markdown setlocal foldmethod=expr +au filetype markdown setlocal foldlevel=1 +function! MyMarkdownFold() + let line = getline(v:lnum) + " regular headers + let depth = match(line, '\(^##\+\)\@<=\( .*$\)\@=') + if depth > 0 + return ">" . depth + endif + " setext headers + let nextline = getline(v:lnum + 1) + if (line =~ '^.\+$') && (nextline =~ '^=\+$') + return ">1" + endif + if (line =~ '^.\+$') && (nextline =~ '^-\+$') + return ">2" + endif + return "=" +endfunction "}}} " --- ansible ---{{{ -- GitLab