robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
13b7319bae
master
1" Vim filetype plugin file 2" Language: HTML 3" Maintainer: Doug Kearns <dougkearns@gmail.com> 4" Previous Maintainer: Dan Sharp 5" Last Change: 2025 Sep 12 6" 2026 May 25 by Vim plugin: improve the matchit plugin #20313 7 8if exists ( "b:did_ftplugin" ) 9finish 10endif 11let b: did_ftplugin = 1 12 13let s: save_cpo = & cpo 14set cpo -= C 15 16setlocal matchpairs += <:> 17setlocal commentstring = <!--\ %s\ --> 18setlocal comments = s:<!--,m:\ \ \ \ ,e:--> 19 20if exists ( 'b:undo_ftplugin' ) 21" no whitespace before |, handle possible :unmap at end of current value 22let b: undo_ftplugin ..= "| setlocal comments< commentstring< matchpairs<" 23else 24let b: undo_ftplugin = "setlocal comments< commentstring< matchpairs<" 25endif 26 27if get ( g:, "ft_html_autocomment" , 0 ) 28setlocal formatoptions -= tformatoptions += croql 29let b: undo_ftplugin ..= " | setlocal formatoptions<" 30endif 31 32if exists ( '&omnifunc' ) 33setlocal omnifunc = htmlcomplete#CompleteTags 34call htmlcomplete#DetectOmniFlavor () 35let b: undo_ftplugin ..= " | setlocal omnifunc<" 36endif 37 38" HTML: thanks to Johannes Zellner and Benji Fisher. 39if exists ( "loaded_matchit" ) && ! exists ( "b:match_words" ) 40let b: match_ignorecase = 1 41let b: match_words = '<!--:-->,' .. 42 \'<:>,' .. 43 \'<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .. 44 \'<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .. 45 \'<\@<=\([^/!][^ \t>]*\)\%([ \t]\|>\|$\):<\@<=/\1>' 46let b: html_set_match_words = 1 47let b: undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words b:html_set_match_words" 48endif 49 50" Change the :browse e filter to primarily show HTML-related files. 51if ( has ( "gui_win32" ) || has ( "gui_gtk" )) && ! exists ( "b:browsefilter" ) 52let b: browsefilter = "HTML Files (*.html, *.htm)\t*.html;*.htm\n" .. 53 \"JavaScript Files (*.js)\t*.js\n" .. 54 \"Cascading StyleSheets (*.css)\t*.css\n" 55if has ( "win32" ) 56let b: browsefilter ..= "All Files (*.*)\t*\n" 57else 58let b: browsefilter ..= "All Files (*)\t*\n" 59endif 60let b: html_set_browsefilter = 1 61let b: undo_ftplugin ..= " | unlet! b:browsefilter b:html_set_browsefilter" 62endif 63 64if has ( "folding" ) && get ( g:, "html_expr_folding" , 0 ) 65function ! HTMLTagFold () abort 66if empty ( get ( b:, "foldsmap" , {})) 67if empty ( get ( b:, "current_syntax" , '' )) 68return '0' 69else 70let b: foldsmap = htmlfold#MapBalancedTags () 71endif 72endif 73 74return get ( b: foldsmap , v: lnum , '=' ) 75endfunction 76 77setlocal foldexpr = HTMLTagFold () 78setlocal foldmethod = expr 79let b: undo_ftplugin ..= " | setlocal foldexpr< foldmethod<" 80 81if ! get ( g:, "html_expr_folding_without_recomputation" , 0 ) 82augroup htmltagfold 83autocmd ! htmltagfold 84autocmd TextChanged , InsertLeave <buffer> let b: foldsmap = {} 85augroup END 86 87" XXX: Keep ":autocmd" last in "b:undo_ftplugin" (see ":help :bar"). 88let b: undo_ftplugin ..= " | silent! autocmd! htmltagfold * <buffer>" 89endif 90endif 91 92let & cpo = s: save_cpo 93unlet s: save_cpo 94 95" See ":help vim9-mix". 96if ! has ( "vim9script" ) 97finish 98endif 99 100if exists ( "*g:HTMLTagFold" ) 101def ! g:HTMLTagFold(): string 102if empty ( get ( b:, "foldsmap" , {})) 103if empty ( get ( b:, "current_syntax" , '' )) 104return '0' 105else 106b :foldsmap = g:htmlfold#MapBalancedTags() 107endif 108endif 109 110return get ( b: foldsmap , v: lnum , '=' ) 111enddef 112endif