robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqvim-patch:9.2.0535: tests: matchit plugin is not tested (#40006)13b7319bae

master
3.2 KiB112 linesraw
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")
9  finish
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
22  let b:undo_ftplugin ..= "| setlocal comments< commentstring< matchpairs<"
23else
24  let b:undo_ftplugin = "setlocal comments< commentstring< matchpairs<"
25endif
26
27if get(g:, "ft_html_autocomment", 0)
28  setlocal formatoptions-=t formatoptions+=croql
29  let b:undo_ftplugin ..= " | setlocal formatoptions<"
30endif
31
32if exists('&omnifunc')
33  setlocal omnifunc=htmlcomplete#CompleteTags
34  call htmlcomplete#DetectOmniFlavor()
35  let b:undo_ftplugin ..= " | setlocal omnifunc<"
36endif
37
38" HTML: thanks to Johannes Zellner and Benji Fisher.
39if exists("loaded_matchit") && !exists("b:match_words")
40  let b:match_ignorecase = 1
41  let b:match_words = '<!--:-->,' ..
42	\	      '<:>,' ..
43	\	      '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' ..
44	\	      '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' ..
45	\	      '<\@<=\([^/!][^ \t>]*\)\%([ \t]\|>\|$\):<\@<=/\1>'
46  let b:html_set_match_words = 1
47  let 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")
52  let  b:browsefilter = "HTML Files (*.html, *.htm)\t*.html;*.htm\n" ..
53	\		"JavaScript Files (*.js)\t*.js\n" ..
54	\		"Cascading StyleSheets (*.css)\t*.css\n"
55  if has("win32")
56    let b:browsefilter ..= "All Files (*.*)\t*\n"
57  else
58    let b:browsefilter ..= "All Files (*)\t*\n"
59  endif
60  let b:html_set_browsefilter = 1
61  let b:undo_ftplugin ..= " | unlet! b:browsefilter b:html_set_browsefilter"
62endif
63
64if has("folding") && get(g:, "html_expr_folding", 0)
65  function! HTMLTagFold() abort
66    if empty(get(b:, "foldsmap", {}))
67      if empty(get(b:, "current_syntax", ''))
68	return '0'
69      else
70	let b:foldsmap = htmlfold#MapBalancedTags()
71      endif
72    endif
73
74    return get(b:foldsmap, v:lnum, '=')
75  endfunction
76
77  setlocal foldexpr=HTMLTagFold()
78  setlocal foldmethod=expr
79  let b:undo_ftplugin ..= " | setlocal foldexpr< foldmethod<"
80
81  if !get(g:, "html_expr_folding_without_recomputation", 0)
82    augroup htmltagfold
83      autocmd! htmltagfold
84      autocmd TextChanged,InsertLeave <buffer> let b:foldsmap = {}
85    augroup END
86
87    " XXX: Keep ":autocmd" last in "b:undo_ftplugin" (see ":help :bar").
88    let b:undo_ftplugin ..= " | silent! autocmd! htmltagfold * <buffer>"
89  endif
90endif
91
92let &cpo = s:save_cpo
93unlet s:save_cpo
94
95" See ":help vim9-mix".
96if !has("vim9script")
97  finish
98endif
99
100if exists("*g:HTMLTagFold")
101  def! g:HTMLTagFold(): string
102    if empty(get(b:, "foldsmap", {}))
103      if empty(get(b:, "current_syntax", ''))
104	return '0'
105      else
106	b:foldsmap = g:htmlfold#MapBalancedTags()
107      endif
108    endif
109
110    return get(b:foldsmap, v:lnum, '=')
111  enddef
112endif