robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
0bb2f5cc08
master
1" Vim filetype plugin 2" Language: Markdown 3" Maintainer: Tim Pope <https://github.com/tpope/vim-markdown> 4" Last Change: 2023 Dec 28 5" 2024 May 24 by Riley Bruins <ribru17@gmail.com> ('commentstring') 6" 2026 Jun 27 by Vim Project (normalize recommended style guard) 7 8if exists ( "b:did_ftplugin" ) 9finish 10endif 11 12runtime ! ftplugin/html[.]{vim,lua} ftplugin/html_*.{vim,lua} ftplugin/html/*.{vim,lua} 13 14let s: keepcpo = & cpo 15set cpo & vim 16 17setlocal comments = fb:*,fb:-,fb:+,n:>commentstring = <!--\ %s\ --> 18setlocal formatoptions += tcqlnformatoptions -= rformatoptions -= o 19setlocal formatlistpat = ^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:\\&^.\\{4\\} 20 21if exists ( 'b:undo_ftplugin' ) 22let b: undo_ftplugin .= "|setl cms< com< fo< flp< et< ts< sts< sw<" 23else 24let b: undo_ftplugin = "setl cms< com< fo< flp< et< ts< sts< sw<" 25endif 26 27if get ( g:, 'markdown_recommended_style' , 28 \get ( g:, 'filetype_recommended_style' , 1 )) 29setlocal expandtab tabstop = 4 softtabstop = 4 shiftwidth = 4 30endif 31 32if ! exists ( "g:no_plugin_maps" ) && ! exists ( "g:no_markdown_maps" ) 33nnoremap <silent><buffer> [[ :< C-U > call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR> 34nnoremap <silent><buffer> ]] :< C-U > call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR> 35xnoremap <silent><buffer> [[ :< C-U > exe "normal! gv"< Bar > call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR> 36xnoremap <silent><buffer> ]] :< C-U > exe "normal! gv"< Bar > call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR> 37let b: undo_ftplugin .= '|sil! nunmap <buffer> [[|sil! nunmap <buffer> ]]|sil! xunmap <buffer> [[|sil! xunmap <buffer> ]]' 38endif 39 40function ! s: NotCodeBlock ( lnum ) abort 41return synIDattr ( synID ( a: lnum , 1 , 1 ), 'name' ) !=# 'markdownCodeBlock' 42endfunction 43 44function ! MarkdownFold () abort 45let line = getline ( v: lnum ) 46 47if line =~# '^#\+ ' && s: NotCodeBlock ( v: lnum ) 48return ">" . match ( line , ' ' ) 49endif 50 51let nextline = getline ( v: lnum + 1 ) 52if ( line =~ '^.\+$' ) && ( nextline =~ '^=\+$' ) && s: NotCodeBlock ( v: lnum + 1 ) 53return ">1" 54endif 55 56if ( line =~ '^.\+$' ) && ( nextline =~ '^-\+$' ) && s: NotCodeBlock ( v: lnum + 1 ) 57return ">2" 58endif 59 60return "=" 61endfunction 62 63function ! s: HashIndent ( lnum ) abort 64let hash_header = matchstr ( getline ( a: lnum ), '^#\{1,6}' ) 65if len ( hash_header ) 66return hash_header 67else 68let nextline = getline ( a: lnum + 1 ) 69if nextline =~# '^=\+\s*$' 70return '#' 71elseif nextline =~# '^-\+\s*$' 72return '##' 73endif 74endif 75endfunction 76 77function ! MarkdownFoldText () abort 78let hash_indent = s: HashIndent ( v: foldstart ) 79let title = substitute ( getline ( v: foldstart ), '^#\+\s*' , '' , '' ) 80let foldsize = ( v: foldend - v: foldstart + 1 ) 81let linecount = '[' . foldsize . ' lines]' 82return hash_indent . ' ' . title . ' ' . linecount 83endfunction 84 85if has ( "folding" ) && get ( g:, "markdown_folding" , 0 ) 86setlocal foldexpr = MarkdownFold () 87setlocal foldmethod = expr 88setlocal foldtext = MarkdownFoldText () 89let b: undo_ftplugin .= "|setl foldexpr< foldmethod< foldtext<" 90endif 91 92let & cpo = s: keepcpo 93unlet s: keepcpo 94 95" vim:set sw=2: