| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | " Vim filetype plugin | 
					
						
							| 
									
										
										
										
											2022-10-16 13:11:12 +01:00
										 |  |  | " Language:     Markdown | 
					
						
							|  |  |  | " Maintainer:   Tim Pope <https://github.com/tpope/vim-markdown> | 
					
						
							| 
									
										
										
										
											2023-12-28 12:50:18 -05:00
										 |  |  | " Last Change:  2023 Dec 28 | 
					
						
							| 
									
										
										
										
											2024-06-03 20:40:45 +02:00
										 |  |  | "               2024 May 24 by Riley Bruins <ribru17@gmail.com> ('commentstring') | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | if exists("b:did_ftplugin") | 
					
						
							|  |  |  |   finish | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-16 13:11:12 +01:00
										 |  |  | let s:keepcpo= &cpo | 
					
						
							|  |  |  | set cpo&vim | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-03 20:40:45 +02:00
										 |  |  | setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=<!--\ %s\ --> | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o | 
					
						
							| 
									
										
										
										
											2022-10-16 13:11:12 +01:00
										 |  |  | setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:\\&^.\\{4\\} | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-14 21:17:39 +01:00
										 |  |  | if exists('b:undo_ftplugin') | 
					
						
							| 
									
										
										
										
											2022-10-16 13:11:12 +01:00
										 |  |  |   let b:undo_ftplugin .= "|setl cms< com< fo< flp< et< ts< sts< sw<" | 
					
						
							| 
									
										
										
										
											2011-12-14 21:17:39 +01:00
										 |  |  | else | 
					
						
							| 
									
										
										
										
											2022-10-16 13:11:12 +01:00
										 |  |  |   let b:undo_ftplugin = "setl cms< com< fo< flp< et< ts< sts< sw<" | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if get(g:, 'markdown_recommended_style', 1) | 
					
						
							|  |  |  |   setlocal expandtab tabstop=4 softtabstop=4 shiftwidth=4 | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if !exists("g:no_plugin_maps") && !exists("g:no_markdown_maps") | 
					
						
							|  |  |  |   nnoremap <silent><buffer> [[ :<C-U>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR> | 
					
						
							|  |  |  |   nnoremap <silent><buffer> ]] :<C-U>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR> | 
					
						
							|  |  |  |   xnoremap <silent><buffer> [[ :<C-U>exe "normal! gv"<Bar>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR> | 
					
						
							|  |  |  |   xnoremap <silent><buffer> ]] :<C-U>exe "normal! gv"<Bar>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR> | 
					
						
							|  |  |  |   let b:undo_ftplugin .= '|sil! nunmap <buffer> [[|sil! nunmap <buffer> ]]|sil! xunmap <buffer> [[|sil! xunmap <buffer> ]]' | 
					
						
							| 
									
										
										
										
											2011-12-14 21:17:39 +01:00
										 |  |  | endif | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | function! s:NotCodeBlock(lnum) abort | 
					
						
							| 
									
										
										
										
											2023-12-28 12:50:18 -05:00
										 |  |  |   return synIDattr(synID(a:lnum, 1, 1), 'name') !=# 'markdownCodeBlock' | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | endfunction | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function! MarkdownFold() abort | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  |   let line = getline(v:lnum) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  |   if line =~# '^#\+ ' && s:NotCodeBlock(v:lnum) | 
					
						
							|  |  |  |     return ">" . match(line, ' ') | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  |   endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   let nextline = getline(v:lnum + 1) | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  |   if (line =~ '^.\+$') && (nextline =~ '^=\+$') && s:NotCodeBlock(v:lnum + 1) | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  |     return ">1" | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  |   if (line =~ '^.\+$') && (nextline =~ '^-\+$') && s:NotCodeBlock(v:lnum + 1) | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  |     return ">2" | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return "=" | 
					
						
							|  |  |  | endfunction | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | function! s:HashIndent(lnum) abort | 
					
						
							|  |  |  |   let hash_header = matchstr(getline(a:lnum), '^#\{1,6}') | 
					
						
							|  |  |  |   if len(hash_header) | 
					
						
							|  |  |  |     return hash_header | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     let nextline = getline(a:lnum + 1) | 
					
						
							|  |  |  |     if nextline =~# '^=\+\s*$' | 
					
						
							|  |  |  |       return '#' | 
					
						
							|  |  |  |     elseif nextline =~# '^-\+\s*$' | 
					
						
							|  |  |  |       return '##' | 
					
						
							|  |  |  |     endif | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  | endfunction | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function! MarkdownFoldText() abort | 
					
						
							|  |  |  |   let hash_indent = s:HashIndent(v:foldstart) | 
					
						
							|  |  |  |   let title = substitute(getline(v:foldstart), '^#\+\s*', '', '') | 
					
						
							|  |  |  |   let foldsize = (v:foldend - v:foldstart + 1) | 
					
						
							|  |  |  |   let linecount = '['.foldsize.' lines]' | 
					
						
							|  |  |  |   return hash_indent.' '.title.' '.linecount | 
					
						
							|  |  |  | endfunction | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-16 13:11:12 +01:00
										 |  |  | if has("folding") && get(g:, "markdown_folding", 0) | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  |   setlocal foldexpr=MarkdownFold() | 
					
						
							|  |  |  |   setlocal foldmethod=expr | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  |   setlocal foldtext=MarkdownFoldText() | 
					
						
							| 
									
										
										
										
											2022-10-16 13:11:12 +01:00
										 |  |  |   let b:undo_ftplugin .= "|setl foldexpr< foldmethod< foldtext<" | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-16 13:11:12 +01:00
										 |  |  | let &cpo = s:keepcpo | 
					
						
							|  |  |  | unlet s:keepcpo | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | " vim:set sw=2: |