xref: /vim-8.2.3635/runtime/syntax/hitest.vim (revision 61da1bfa)
1" Vim syntax file
2" Language:	none; used to see highlighting
3" Maintainer:	Ronald Schild <[email protected]>
4" Last Change:	2019 Jun 06
5" Version:	5.4n.1
6" Additional Changes By: Lifepillar, Bram
7
8" To see your current highlight settings, do
9"    :so $VIMRUNTIME/syntax/hitest.vim
10
11" save global options and registers
12let s:hidden      = &hidden
13let s:lazyredraw  = &lazyredraw
14let s:more	  = &more
15let s:report      = &report
16let s:whichwrap   = &whichwrap
17let s:shortmess   = &shortmess
18let s:wrapscan    = &wrapscan
19let s:register_a  = @a
20let s:register_se = @/
21
22" set global options
23set hidden lazyredraw nomore report=99999 shortmess=aoOstTW wrapscan
24set whichwrap&
25
26" print current highlight settings into register a
27redir @a
28silent highlight
29redir END
30
31" Open a new window if the current one isn't empty
32if line("$") != 1 || getline(1) != ""
33  new
34endif
35
36" edit temporary file
37edit Highlight\ test
38
39" set local options
40setlocal autoindent noexpandtab formatoptions=t shiftwidth=18 noswapfile tabstop=18
41let &textwidth=&columns
42
43" insert highlight settings
44% delete
45put a
46
47" remove cleared groups
48silent! g/ cleared$/d
49
50" remove the colored xxx items
51g/xxx /s///e
52
53" remove color settings (not needed here)
54global! /links to/ substitute /\s.*$//e
55
56" Move split 'links to' lines to the same line
57% substitute /^\(\w\+\)\n\s*\(links to.*\)/\1\t\2/e
58
59" move linked groups to the end of file
60global /links to/ move $
61
62" move linked group names to the matching preferred groups
63" TODO: this fails if the group linked to isn't defined
64% substitute /^\(\w\+\)\s*\(links to\)\s*\(\w\+\)$/\3\t\2 \1/e
65silent! global /links to/ normal mz3ElD0#$p'zdd
66
67" delete empty lines
68global /^ *$/ delete
69
70" precede syntax command
71% substitute /^[^ ]*/syn keyword &\t&/
72
73" execute syntax commands
74syntax clear
75% yank a
76@a
77
78" remove syntax commands again
79% substitute /^syn keyword //
80
81" pretty formatting
82global /^/ exe "normal Wi\<CR>\t\eAA\ex"
83global /^\S/ join
84
85" find out first syntax highlighting
86let b:various = &highlight.',:Normal,:Cursor,:,'
87let b:i = 1
88while b:various =~ ':'.substitute(getline(b:i), '\s.*$', ',', '')
89   let b:i = b:i + 1
90   if b:i > line("$") | break | endif
91endwhile
92
93" insert headlines
94call append(0, "Highlighting groups for various occasions")
95call append(1, "-----------------------------------------")
96
97if b:i < line("$")-1
98   let b:synhead = "Syntax highlighting groups"
99   if exists("hitest_filetypes")
100      redir @a
101      let
102      redir END
103      let @a = substitute(@a, 'did_\(\w\+\)_syn\w*_inits\s*#1', ', \1', 'g')
104      let @a = substitute(@a, "\n\\w[^\n]*", '', 'g')
105      let @a = substitute(@a, "\n", '', 'g')
106      let @a = substitute(@a, '^,', '', 'g')
107      if @a != ""
108	 let b:synhead = b:synhead." - filetype"
109	 if @a =~ ','
110	    let b:synhead = b:synhead."s"
111	 endif
112	 let b:synhead = b:synhead.":".@a
113      endif
114   endif
115   call append(b:i+1, "")
116   call append(b:i+2, b:synhead)
117   call append(b:i+3, substitute(b:synhead, '.', '-', 'g'))
118endif
119
120" remove 'hls' highlighting
121nohlsearch
122normal 0
123
124" we don't want to save this temporary file
125set nomodified
126
127" the following trick avoids the "Press RETURN ..." prompt
1280 append
129.
130
131" restore global options and registers
132let &hidden      = s:hidden
133let &lazyredraw  = s:lazyredraw
134let &more	 = s:more
135let &report	 = s:report
136let &shortmess	 = s:shortmess
137let &whichwrap   = s:whichwrap
138let &wrapscan	 = s:wrapscan
139let @a		 = s:register_a
140
141" restore last search pattern
142call histdel("search", -1)
143let @/ = s:register_se
144
145" remove variables
146unlet s:hidden s:lazyredraw s:more s:report s:shortmess
147unlet s:whichwrap s:wrapscan s:register_a s:register_se
148
149" vim: ts=8
150