annotate runtime/ftplugin/markdown.vim @ 23825:0bd44e94dd14 v8.2.2454

patch 8.2.2454: leading space can not be made visible Commit: https://github.com/vim/vim/commit/91478ae49a1b2dc1de63821db731a343e855dcc0 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 3 15:58:13 2021 +0100 patch 8.2.2454: leading space can not be made visible Problem: Leading space can not be made visible. Solution: Add "lead:" to 'listchars'. (closes https://github.com/vim/vim/issues/7772)
author Bram Moolenaar <Bram@vim.org>
date Wed, 03 Feb 2021 16:00:07 +0100
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: