Mercurial > vim
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 |
rev | line source |
---|---|
2202 | 1 " Vim filetype plugin |
30875 | 2 " Language: Markdown |
3 " Maintainer: Tim Pope <https://github.com/tpope/vim-markdown> | |
4 " Last Change: 2022 Oct 13 | |
2202 | 5 |
6 if exists("b:did_ftplugin") | |
7 finish | |
8 endif | |
9 | |
10 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim | |
11 | |
30875 | 12 let s:keepcpo= &cpo |
13 set cpo&vim | |
14 | |
18818 | 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 | 17 setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:\\&^.\\{4\\} |
2202 | 18 |
3224 | 19 if exists('b:undo_ftplugin') |
30875 | 20 let b:undo_ftplugin .= "|setl cms< com< fo< flp< et< ts< sts< sw<" |
3224 | 21 else |
30875 | 22 let b:undo_ftplugin = "setl cms< com< fo< flp< et< ts< sts< sw<" |
23 endif | |
24 | |
25 if get(g:, 'markdown_recommended_style', 1) | |
26 setlocal expandtab tabstop=4 softtabstop=4 shiftwidth=4 | |
27 endif | |
28 | |
29 if !exists("g:no_plugin_maps") && !exists("g:no_markdown_maps") | |
30 nnoremap <silent><buffer> [[ :<C-U>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR> | |
31 nnoremap <silent><buffer> ]] :<C-U>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR> | |
32 xnoremap <silent><buffer> [[ :<C-U>exe "normal! gv"<Bar>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR> | |
33 xnoremap <silent><buffer> ]] :<C-U>exe "normal! gv"<Bar>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR> | |
34 let b:undo_ftplugin .= '|sil! nunmap <buffer> [[|sil! nunmap <buffer> ]]|sil! xunmap <buffer> [[|sil! xunmap <buffer> ]]' | |
3224 | 35 endif |
2202 | 36 |
18818 | 37 function! s:NotCodeBlock(lnum) abort |
30875 | 38 return synIDattr(synID(a:lnum, 1, 1), 'name') !=# 'markdownCode' |
18818 | 39 endfunction |
40 | |
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 | 44 if line =~# '^#\+ ' && s:NotCodeBlock(v:lnum) |
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 | 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 | 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 | 60 function! s:HashIndent(lnum) abort |
61 let hash_header = matchstr(getline(a:lnum), '^#\{1,6}') | |
62 if len(hash_header) | |
63 return hash_header | |
64 else | |
65 let nextline = getline(a:lnum + 1) | |
66 if nextline =~# '^=\+\s*$' | |
67 return '#' | |
68 elseif nextline =~# '^-\+\s*$' | |
69 return '##' | |
70 endif | |
71 endif | |
72 endfunction | |
73 | |
74 function! MarkdownFoldText() abort | |
75 let hash_indent = s:HashIndent(v:foldstart) | |
76 let title = substitute(getline(v:foldstart), '^#\+\s*', '', '') | |
77 let foldsize = (v:foldend - v:foldstart + 1) | |
78 let linecount = '['.foldsize.' lines]' | |
79 return hash_indent.' '.title.' '.linecount | |
80 endfunction | |
81 | |
30875 | 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 | 85 setlocal foldtext=MarkdownFoldText() |
30875 | 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 | 89 let &cpo = s:keepcpo |
90 unlet s:keepcpo | |
91 | |
2202 | 92 " vim:set sw=2: |