-
Notifications
You must be signed in to change notification settings - Fork 0
/
filters.rc
210 lines (182 loc) · 4.98 KB
/
filters.rc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
; $Id: filters.rc,v 1.210 2007/10/21 19:22:26 tom Exp $
; majormodes in this file are ordered alphabetically for convenience - the
; precedence used by vile is strictly alphabetic, counting case.
; This file depends upon modes.rc, which may have been source'd by vileinit.rc
; so we will check if it was not source'd.
~if &error %filters-modes
source modes.rc
~elseif &seq %filters-modes ''
source modes.rc
~endif
unsetv %filters-modes
define-mode cpp
~with define-submode cpp
filtername 'vile-c-filt -k cpp'
~endwith
define-mode cs
~with define-submode cs
filtername 'vile-c-filt -k cs'
~endwith
define-mode csh
~with define-submode csh
filtername 'vile-sh-filt -k csh'
~endwith
; using txt filter will highlight quoted strings
define-mode csv
~with define-submode csv
filtername 'vile-txt-filt'
~endwith
define-mode delphi
~with define-submode delphi
filtername 'vile-pas-filt -k delphi'
~endwith
define-mode docbook
~with define-submode docbook
filtername 'vile-xml-filt -k docbook'
~endwith
define-mode java
~with define-submode java
filtername 'vile-c-filt -j -p -k java'
~endwith
define-mode js
~with define-submode js
filtername 'vile-c-filt -j -s -p -k js'
~endwith
define-mode jsp
~with define-submode jsp
filtername 'vile-html-filt -j'
~endwith
define-mode latex
~with define-submode latex
filtername 'vile-latex-filt -a'
~endwith
define-mode nmake
~with define-submode nmake
filtername 'vile-make-filt'
~endwith
define-mode nsis
~with define-submode nsis
filtername 'vile-conf-filt -k nsis'
~endwith
define-mode pc
~with define-submode pc
filtername 'vile-tc-filt -k pc'
~endwith
define-mode rb
~with define-submode rb
filtername 'vile-ruby-filt -k rb'
~endwith
define-mode RCS
~with define-submode RCS
filtername 'vile-rcs-filt'
~endwith
define-mode SCCS
~with define-submode SCCS
filtername 'vile-sccs-filt'
~endwith
~with define-submode scheme
filtername 'vile-lisp-filt -k scheme'
~endwith
define-mode tex
~with define-submode tex
filtername 'vile-latex-filt -k tex'
~endwith
define-mode vb
~with define-submode vb
filtername 'vile-basic-filt -k vb'
~endwith
define-mode vbs
~with define-submode vbs
filtername 'vile-basic-filt -k vb'
~endwith
define-mode vim
~with define-submode vim
filtername 'vile-vile-filt -k vim'
~endwith
define-mode xpm
~with define-submode xpm
filtername 'vile-c-filt'
~endwith
store-procedure HighlightFilter 'Invoke syntax-highlighting filter on the current buffer'
~if ¬ $highlight
~return
~elseif &seq $majormode ''
~return
~elseif &filter $majormode
~local $curcol $curline
~hidden goto-beginning-of-file
~hidden attribute-directly end-of-file $majormode
~return
~else
~local $curcol $curline
~local %filtername %filterpath %filteropts
~hidden goto-beginning-of-file
~if &seq $filtername ''
set-variable %filtername &cat &cat 'vile-' $majormode '-filt'
~else
set-variable %filtername $filtername
~endif
set-variable %filterpath &word 0 %filtername
set-variable %filteropts &right %filtername &add 1 &len %filterpath
~if &seq '' &lookup e+p &cat %filterpath $exec-suffix
set-variable %filterpath &lookup e+l &cat %filterpath $exec-suffix
~endif
~if ¬ &seq %filterpath ''
~hidden attribute-from-filter end-of-file &cat &pquote %filterpath &cat %filteropts &cat ' -t' $tabstop
~endif
~endif
~endm
store-procedure HighlightFilterMsg 'Attach highlighting to the current buffer'
HighlightFilter
write-message '[Attaching attributes...]'
~endm
bind-key HighlightFilterMsg ^X-q
store-procedure HighlightClear 'Clear all highlighting from the current buffer'
~local $curcol $curline
~hidden goto-beginning-of-file
~hidden clear-attributes-til goto-char
~endm
bind-key HighlightClear ^X-Q
store-procedure set-highlighting ma 'Set a majormode and invoke highlighting'
; show-variables
write-message $1
~force setl $1
HighlightFilter
~endm
; Normally filtermsgs is off since it would slow down autocolor. This macro
; turns it on temporarily to create an error-buffer which can be used to walk
; through the syntax errors.
store-procedure show-filtermsgs 'Show syntax-filter error messages for current buffer'
~local $filtermsgs $highlight
set highlight
~if ¬ $highlight
write-message 'Cannot setup highlighting'
~elseif &seq $majormode ''
write-message 'No majormode is associated with this buffer'
~elseif &filter $majormode
set filtermsgs
; make sure there are no prior results to confuse us
~if &isa buffer '[Filter Messages]'
~quiet ~hidden kill-buffer '[Filter Messages]'
~endif
HighlightFilter
~if &isa buffer '[Filter Messages]'
popup-buffer '[Filter Messages]'
goto-beginning-of-file
error-buffer '[Filter Messages]'
~else
write-message 'No messages found'
~endif
~else
write-message 'This only works for built-in filters'
~endif
~endm
; If we have built-in filters, and colors are available, simply turn on
; the syntax highlighting.
~if &and \
¬ &error $filter-list \
¬ &error $ncolors
setv $read-hook HighlightFilter
set autocolor=5000
setv $autocolor-hook HighlightFilter
~endif