Merge branch 'vim-with-runtime' into feat/quickfix-title
[vim_extended.git] / runtime / syntax / hitest.vim
blob7489101060305824fb13acfa42330f9757c31617
1 " Vim syntax file
2 " Language:     none; used to see highlighting
3 " Maintainer:   Ronald Schild <rs@scutum.de>
4 " Last Change:  2001 Sep 02
5 " Version:      5.4n.1
7 " To see your current highlight settings, do
8 "    :so $VIMRUNTIME/syntax/hitest.vim
10 " save global options and registers
11 let s:hidden      = &hidden
12 let s:lazyredraw  = &lazyredraw
13 let s:more        = &more
14 let s:report      = &report
15 let s:shortmess   = &shortmess
16 let s:wrapscan    = &wrapscan
17 let s:register_a  = @a
18 let s:register_se = @/
20 " set global options
21 set hidden lazyredraw nomore report=99999 shortmess=aoOstTW wrapscan
23 " print current highlight settings into register a
24 redir @a
25 highlight
26 redir END
28 " Open a new window if the current one isn't empty
29 if line("$") != 1 || getline(1) != ""
30   new
31 endif
33 " edit temporary file
34 edit Highlight\ test
36 " set local options
37 setlocal autoindent noexpandtab formatoptions=t shiftwidth=16 noswapfile tabstop=16
38 let &textwidth=&columns
40 " insert highlight settings
41 % delete
42 put a
44 " remove the colored xxx items
45 g/xxx /s///e
47 " remove color settings (not needed here)
48 global! /links to/ substitute /\s.*$//e
50 " move linked groups to the end of file
51 global /links to/ move $
53 " move linked group names to the matching preferred groups
54 % substitute /^\(\w\+\)\s*\(links to\)\s*\(\w\+\)$/\3\t\2 \1/e
55 global /links to/ normal mz3ElD0#$p'zdd
57 " delete empty lines
58 global /^ *$/ delete
60 " precede syntax command
61 % substitute /^[^ ]*/syn keyword &\t&/
63 " execute syntax commands
64 syntax clear
65 % yank a
68 " remove syntax commands again
69 % substitute /^syn keyword //
71 " pretty formatting
72 global /^/ exe "normal Wi\<CR>\t\eAA\ex"
73 global /^\S/ join
75 " find out first syntax highlighting
76 let b:various = &highlight.',:Normal,:Cursor,:,'
77 let b:i = 1
78 while b:various =~ ':'.substitute(getline(b:i), '\s.*$', ',', '')
79    let b:i = b:i + 1
80    if b:i > line("$") | break | endif
81 endwhile
83 " insert headlines
84 call append(0, "Highlighting groups for various occasions")
85 call append(1, "-----------------------------------------")
87 if b:i < line("$")-1
88    let b:synhead = "Syntax highlighting groups"
89    if exists("hitest_filetypes")
90       redir @a
91       let
92       redir END
93       let @a = substitute(@a, 'did_\(\w\+\)_syn\w*_inits\s*#1', ', \1', 'g')
94       let @a = substitute(@a, "\n\\w[^\n]*", '', 'g')
95       let @a = substitute(@a, "\n", '', 'g')
96       let @a = substitute(@a, '^,', '', 'g')
97       if @a != ""
98          let b:synhead = b:synhead." - filetype"
99          if @a =~ ','
100             let b:synhead = b:synhead."s"
101          endif
102          let b:synhead = b:synhead.":".@a
103       endif
104    endif
105    call append(b:i+1, "")
106    call append(b:i+2, b:synhead)
107    call append(b:i+3, substitute(b:synhead, '.', '-', 'g'))
108 endif
110 " remove 'hls' highlighting
111 nohlsearch
112 normal 0
114 " add autocommands to remove temporary file from buffer list
115 aug highlighttest
116    au!
117    au BufUnload Highlight\ test if expand("<afile>") == "Highlight test"
118    au BufUnload Highlight\ test    bdelete! Highlight\ test
119    au BufUnload Highlight\ test endif
120    au VimLeavePre * if bufexists("Highlight test")
121    au VimLeavePre *    bdelete! Highlight\ test
122    au VimLeavePre * endif
123 aug END
125 " we don't want to save this temporary file
126 set nomodified
128 " the following trick avoids the "Press RETURN ..." prompt
129 0 append
132 " restore global options and registers
133 let &hidden      = s:hidden
134 let &lazyredraw  = s:lazyredraw
135 let &more        = s:more
136 let &report      = s:report
137 let &shortmess   = s:shortmess
138 let &wrapscan    = s:wrapscan
139 let @a           = s:register_a
141 " restore last search pattern
142 call histdel("search", -1)
143 let @/ = s:register_se
145 " remove variables
146 unlet s:hidden s:lazyredraw s:more s:report s:shortmess
147 unlet s:wrapscan s:register_a s:register_se
149 " vim: ts=8