codekingpro/portable-devtools
115k
1" Vim filetype plugin file2" Language: HTML3" Maintainer: Doug Kearns <dougkearns@gmail.com>4" Previous Maintainer: Dan Sharp5" Last Change: 2025 Sep 126 7if exists("b:did_ftplugin")8 finish9endif10let b:did_ftplugin = 111 12let s:save_cpo = &cpo13set cpo-=C14 15setlocal matchpairs+=<:>16setlocal commentstring=<!--\ %s\ -->17setlocal comments=s:<!--,m:\ \ \ \ ,e:-->18 19if exists('b:undo_ftplugin')20 " no whitespace before |, handle possible :unmap at end of current value21 let b:undo_ftplugin ..= "| setlocal comments< commentstring< matchpairs<"22else23 let b:undo_ftplugin = "setlocal comments< commentstring< matchpairs<"24endif25 26if get(g:, "ft_html_autocomment", 0)27 setlocal formatoptions-=t formatoptions+=croql28 let b:undo_ftplugin ..= " | setlocal formatoptions<"29endif30 31if exists('&omnifunc')32 setlocal omnifunc=htmlcomplete#CompleteTags33 call htmlcomplete#DetectOmniFlavor()34 let b:undo_ftplugin ..= " | setlocal omnifunc<"35endif36 37" HTML: thanks to Johannes Zellner and Benji Fisher.38if exists("loaded_matchit") && !exists("b:match_words")39 let b:match_ignorecase = 140 let b:match_words = '<!--:-->,' ..41 \ '<:>,' ..42 \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' ..43 \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' ..44 \ '<\@<=\([^/!][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'45 let b:html_set_match_words = 146 let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words b:html_set_match_words"47endif48 49" Change the :browse e filter to primarily show HTML-related files.50if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")51 let b:browsefilter = "HTML Files (*.html, *.htm)\t*.html;*.htm\n" ..52 \ "JavaScript Files (*.js)\t*.js\n" ..53 \ "Cascading StyleSheets (*.css)\t*.css\n"54 if has("win32")55 let b:browsefilter ..= "All Files (*.*)\t*\n"56 else57 let b:browsefilter ..= "All Files (*)\t*\n"58 endif59 let b:html_set_browsefilter = 160 let b:undo_ftplugin ..= " | unlet! b:browsefilter b:html_set_browsefilter"61endif62 63if has("folding") && get(g:, "html_expr_folding", 0)64 function! HTMLTagFold() abort65 if empty(get(b:, "foldsmap", {}))66 if empty(get(b:, "current_syntax", ''))67 return '0'68 else69 let b:foldsmap = htmlfold#MapBalancedTags()70 endif71 endif72 73 return get(b:foldsmap, v:lnum, '=')74 endfunction75 76 setlocal foldexpr=HTMLTagFold()77 setlocal foldmethod=expr78 let b:undo_ftplugin ..= " | setlocal foldexpr< foldmethod<"79 80 if !get(g:, "html_expr_folding_without_recomputation", 0)81 augroup htmltagfold82 autocmd! htmltagfold83 autocmd TextChanged,InsertLeave <buffer> let b:foldsmap = {}84 augroup END85 86 " XXX: Keep ":autocmd" last in "b:undo_ftplugin" (see ":help :bar").87 let b:undo_ftplugin ..= " | silent! autocmd! htmltagfold * <buffer>"88 endif89endif90 91let &cpo = s:save_cpo92unlet s:save_cpo93 94" See ":help vim9-mix".95if !has("vim9script")96 finish97endif98 99if exists("*g:HTMLTagFold")100 def! g:HTMLTagFold(): string101 if empty(get(b:, "foldsmap", {}))102 if empty(get(b:, "current_syntax", ''))103 return '0'104 else105 b:foldsmap = g:htmlfold#MapBalancedTags()106 endif107 endif108 109 return get(b:foldsmap, v:lnum, '=')110 enddef111endif112 