| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | " Vim filetype plugin | 
					
						
							|  |  |  | " Language:		Markdown | 
					
						
							|  |  |  | " Maintainer:		Tim Pope <vimNOSPAM@tpope.org> | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | " Last Change:		2019 Dec 05 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=<!--%s--> | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]: | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-14 21:17:39 +01:00
										 |  |  | if exists('b:undo_ftplugin') | 
					
						
							|  |  |  |   let b:undo_ftplugin .= "|setl cms< com< fo< flp<" | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   let b:undo_ftplugin = "setl cms< com< fo< flp<" | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | function! s:NotCodeBlock(lnum) abort | 
					
						
							|  |  |  |   return synIDattr(synID(v:lnum, 1, 1), 'name') !=# 'markdownCode' | 
					
						
							|  |  |  | 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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | if has("folding") && exists("g:markdown_folding") | 
					
						
							|  |  |  |   setlocal foldexpr=MarkdownFold() | 
					
						
							|  |  |  |   setlocal foldmethod=expr | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  |   setlocal foldtext=MarkdownFoldText() | 
					
						
							|  |  |  |   let b:undo_ftplugin .= " foldexpr< foldmethod< foldtext<" | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | " vim:set sw=2: |