blob: 9d60cec8024e998be0470b8fb5233685c6147f63 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: none; used to see highlighting
3" Maintainer: Ronald Schild <rs@scutum.de>
Bram Moolenaar61da1bf2019-06-06 12:14:49 +02004" Last Change: 2019 Jun 06
Bram Moolenaar071d4272004-06-13 20:20:40 +00005" Version: 5.4n.1
Bram Moolenaar61da1bf2019-06-06 12:14:49 +02006" Additional Changes By: Lifepillar, Bram
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
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
Bram Moolenaar61da1bf2019-06-06 12:14:49 +020016let s:whichwrap = &whichwrap
Bram Moolenaar071d4272004-06-13 20:20:40 +000017let 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
Bram Moolenaar61da1bf2019-06-06 12:14:49 +020024set whichwrap&
Bram Moolenaar071d4272004-06-13 20:20:40 +000025
26" print current highlight settings into register a
27redir @a
Bram Moolenaar61da1bf2019-06-06 12:14:49 +020028silent highlight
Bram Moolenaar071d4272004-06-13 20:20:40 +000029redir 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
Bram Moolenaar61da1bf2019-06-06 12:14:49 +020040setlocal autoindent noexpandtab formatoptions=t shiftwidth=18 noswapfile tabstop=18
Bram Moolenaar071d4272004-06-13 20:20:40 +000041let &textwidth=&columns
42
43" insert highlight settings
44% delete
45put a
46
Bram Moolenaar61da1bf2019-06-06 12:14:49 +020047" remove cleared groups
48silent! g/ cleared$/d
49
Bram Moolenaar071d4272004-06-13 20:20:40 +000050" remove the colored xxx items
51g/xxx /s///e
52
53" remove color settings (not needed here)
54global! /links to/ substitute /\s.*$//e
55
Bram Moolenaar61da1bf2019-06-06 12:14:49 +020056" Move split 'links to' lines to the same line
57% substitute /^\(\w\+\)\n\s*\(links to.*\)/\1\t\2/e
58
Bram Moolenaar071d4272004-06-13 20:20:40 +000059" move linked groups to the end of file
60global /links to/ move $
61
62" move linked group names to the matching preferred groups
Bram Moolenaar61da1bf2019-06-06 12:14:49 +020063" TODO: this fails if the group linked to isn't defined
Bram Moolenaar071d4272004-06-13 20:20:40 +000064% substitute /^\(\w\+\)\s*\(links to\)\s*\(\w\+\)$/\3\t\2 \1/e
Bram Moolenaar61da1bf2019-06-06 12:14:49 +020065silent! global /links to/ normal mz3ElD0#$p'zdd
Bram Moolenaar071d4272004-06-13 20:20:40 +000066
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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000124" 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
Bram Moolenaar61da1bf2019-06-06 12:14:49 +0200137let &whichwrap = s:whichwrap
Bram Moolenaar071d4272004-06-13 20:20:40 +0000138let &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
Bram Moolenaar61da1bf2019-06-06 12:14:49 +0200147unlet s:whichwrap s:wrapscan s:register_a s:register_se
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148
149" vim: ts=8