annotate runtime/ftplugin/markdown.vim @ 25744:2d28755ff4a5

Added tag v8.2.3407 for changeset 925ffa1eeb08af233ebe7a45d11b6f241573c3c7
author Bram Moolenaar <Bram@vim.org>
date Mon, 06 Sep 2021 19:30:04 +0200
parents 5c40013d45ee
children 3295247d97a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 " Vim filetype plugin
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 " Language: Markdown
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
4 " Last Change: 2019 Dec 05
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6 if exists("b:did_ftplugin")
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7 finish
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 endif
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
12 setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=<!--%s-->
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3224
diff changeset
13 setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
14 setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
16 if exists('b:undo_ftplugin')
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
17 let b:undo_ftplugin .= "|setl cms< com< fo< flp<"
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
18 else
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
19 let b:undo_ftplugin = "setl cms< com< fo< flp<"
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
20 endif
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
22 function! s:NotCodeBlock(lnum) abort
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
23 return synIDattr(synID(v:lnum, 1, 1), 'name') !=# 'markdownCode'
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
24 endfunction
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
25
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
26 function! MarkdownFold() abort
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
27 let line = getline(v:lnum)
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
28
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
29 if line =~# '^#\+ ' && s:NotCodeBlock(v:lnum)
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
30 return ">" . match(line, ' ')
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
31 endif
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
32
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
33 let nextline = getline(v:lnum + 1)
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
34 if (line =~ '^.\+$') && (nextline =~ '^=\+$') && s:NotCodeBlock(v:lnum + 1)
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
35 return ">1"
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
36 endif
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
37
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
38 if (line =~ '^.\+$') && (nextline =~ '^-\+$') && s:NotCodeBlock(v:lnum + 1)
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
39 return ">2"
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
40 endif
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
41
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
42 return "="
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
43 endfunction
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
44
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
45 function! s:HashIndent(lnum) abort
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
46 let hash_header = matchstr(getline(a:lnum), '^#\{1,6}')
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
47 if len(hash_header)
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
48 return hash_header
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
49 else
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
50 let nextline = getline(a:lnum + 1)
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
51 if nextline =~# '^=\+\s*$'
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
52 return '#'
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
53 elseif nextline =~# '^-\+\s*$'
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
54 return '##'
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
55 endif
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
56 endif
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
57 endfunction
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
58
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
59 function! MarkdownFoldText() abort
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
60 let hash_indent = s:HashIndent(v:foldstart)
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
61 let title = substitute(getline(v:foldstart), '^#\+\s*', '', '')
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
62 let foldsize = (v:foldend - v:foldstart + 1)
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
63 let linecount = '['.foldsize.' lines]'
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
64 return hash_indent.' '.title.' '.linecount
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
65 endfunction
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
66
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
67 if has("folding") && exists("g:markdown_folding")
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
68 setlocal foldexpr=MarkdownFold()
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
69 setlocal foldmethod=expr
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
70 setlocal foldtext=MarkdownFoldText()
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
71 let b:undo_ftplugin .= " foldexpr< foldmethod< foldtext<"
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
72 endif
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
73
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
74 " vim:set sw=2: