annotate runtime/ftplugin/markdown.vim @ 33825:d515e012d713 v9.0.2128

patch 9.0.2128: runtime(swig): add syntax and filetype plugins Commit: https://github.com/vim/vim/commit/2e31065a650015892179e520038bf2083a9519b6 Author: Julien Marrec <julien.marrec@gmail.com> Date: Sat Nov 25 15:30:46 2023 +0100 patch 9.0.2128: runtime(swig): add syntax and filetype plugins Add syntax and filetype plugins for SWIG (Simplified Wrapper Interface Generator) description files. The default syntax for .i files highlights comments in a reverse color scheme which doesn't look well. This syntax builds on vim's c++ syntax by adding highlighting for common swig directives and user defined directives. For an alternative syntax, see vimscript #1247 (which I found after writing this). closes: #13562 Co-authored-by: Mat?j Cepl <mcepl@cepl.eu> Co-authored-by: Julien Marrec <julien.marrec@gmail.com> Signed-off-by: Julien Marrec <julien.marrec@gmail.com> Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 25 Nov 2023 15:45:06 +0100
parents 3295247d97a5
children 4a67df32683d
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
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
2 " Language: Markdown
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
3 " Maintainer: Tim Pope <https://github.com/tpope/vim-markdown>
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
4 " Last Change: 2022 Oct 13
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
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
12 let s:keepcpo= &cpo
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
13 set cpo&vim
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
14
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
15 setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=<!--%s-->
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3224
diff changeset
16 setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
17 setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:\\&^.\\{4\\}
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
19 if exists('b:undo_ftplugin')
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
20 let b:undo_ftplugin .= "|setl cms< com< fo< flp< et< ts< sts< sw<"
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
21 else
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
22 let b:undo_ftplugin = "setl cms< com< fo< flp< et< ts< sts< sw<"
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
23 endif
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
24
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
25 if get(g:, 'markdown_recommended_style', 1)
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
26 setlocal expandtab tabstop=4 softtabstop=4 shiftwidth=4
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
27 endif
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
28
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
29 if !exists("g:no_plugin_maps") && !exists("g:no_markdown_maps")
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
30 nnoremap <silent><buffer> [[ :<C-U>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR>
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
31 nnoremap <silent><buffer> ]] :<C-U>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR>
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
32 xnoremap <silent><buffer> [[ :<C-U>exe "normal! gv"<Bar>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR>
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
33 xnoremap <silent><buffer> ]] :<C-U>exe "normal! gv"<Bar>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR>
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
34 let b:undo_ftplugin .= '|sil! nunmap <buffer> [[|sil! nunmap <buffer> ]]|sil! xunmap <buffer> [[|sil! xunmap <buffer> ]]'
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
35 endif
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
37 function! s:NotCodeBlock(lnum) abort
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
38 return synIDattr(synID(a:lnum, 1, 1), 'name') !=# 'markdownCode'
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
39 endfunction
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
40
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
41 function! MarkdownFold() abort
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
42 let line = getline(v:lnum)
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
43
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
44 if line =~# '^#\+ ' && s:NotCodeBlock(v:lnum)
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
45 return ">" . match(line, ' ')
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
46 endif
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
47
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
48 let nextline = getline(v:lnum + 1)
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
49 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
50 return ">1"
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
51 endif
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
52
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
53 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
54 return ">2"
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
55 endif
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
56
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
57 return "="
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
58 endfunction
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
59
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
60 function! s:HashIndent(lnum) abort
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
61 let hash_header = matchstr(getline(a:lnum), '^#\{1,6}')
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
62 if len(hash_header)
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
63 return hash_header
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
64 else
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
65 let nextline = getline(a:lnum + 1)
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
66 if nextline =~# '^=\+\s*$'
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
67 return '#'
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
68 elseif nextline =~# '^-\+\s*$'
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
69 return '##'
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
70 endif
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
71 endif
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
72 endfunction
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
73
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
74 function! MarkdownFoldText() abort
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
75 let hash_indent = s:HashIndent(v:foldstart)
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
76 let title = substitute(getline(v:foldstart), '^#\+\s*', '', '')
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
77 let foldsize = (v:foldend - v:foldstart + 1)
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
78 let linecount = '['.foldsize.' lines]'
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
79 return hash_indent.' '.title.' '.linecount
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
80 endfunction
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
81
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
82 if has("folding") && get(g:, "markdown_folding", 0)
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
83 setlocal foldexpr=MarkdownFold()
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
84 setlocal foldmethod=expr
18818
5c40013d45ee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 10048
diff changeset
85 setlocal foldtext=MarkdownFoldText()
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
86 let b:undo_ftplugin .= "|setl foldexpr< foldmethod< foldtext<"
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
87 endif
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
88
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
89 let &cpo = s:keepcpo
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
90 unlet s:keepcpo
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18818
diff changeset
91
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
92 " vim:set sw=2: