summaryrefslogtreecommitdiffstats
path: root/autoload/filetype/execline.kak
blob: 8ba4d17bc333c4d5360fdafc7344309692334dbf (plain)
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
provide-module execline %&
	add-highlighter shared/execline regions

	add-highlighter shared/execline/ region '#' '\n' fill comment

	add-highlighter shared/execline/sqstring region \' \' group
	add-highlighter shared/execline/sqstring/ fill string

	add-highlighter shared/execline/dqstring region '"' '"' group
	add-highlighter shared/execline/dqstring/ fill string
	add-highlighter shared/execline/dqstring/ \
		regex (\\[\\abefhnrtv\n])|(\\.) 1:keyword 2:Error
	add-highlighter shared/execline/dqstring/ \
		regex (\$\{.*?\}) 0:variable

	add-highlighter shared/execline/code default-region group
	add-highlighter shared/execline/code/value \
		regex (\$\{.*?\}) 0:variable

	evaluate-commands %sh{
    	# Grammar
    	# Generated with `compgen -k` in bash
    	keywords=""
    	s6="
			s6-accessrules-cdb-from-fs
			s6-accessrules-fs-from-cdb
			s6-applyuidgid
			s6-cleanfifodir
			s6-connlimit
			s6-envdir
			s6-envuidgid
			s6-fdholderd
			s6-fdholder-daemon
			s6-fdholder-delete
			s6-fdholder-getdump
			s6-fdholder-list
			s6-fdholder-retrieve
			s6-fdholder-setdump
			s6-fdholder-store
			s6-fdholder-transferdump
			s6-fghack
			s6-ftrig-listen
			s6-ftrig-listen1
			s6-ftrig-notify
			s6-ftrigrd
			s6-ftrig-wait
			s6-instance-control
			s6-instance-create
			s6-instance-delete
			s6-instance-list
			s6-instance-maker
			s6-instance-status
			s6-ioconnect
			s6-ipcclient
			s6-ipcserver
			s6-ipcserver-access
			s6-ipcserverd
			s6-ipcserver-socketbinder
			s6-log
			s6-mkfifodir
			s6-notifyoncheck
			s6-permafailon
			s6-setlock
			s6-setsid
			s6-setuidgid
			s6-socklog
			s6-softlimit
			s6-sudo
			s6-sudoc
			s6-sudod
			s6-supervise
			s6-svc
			s6-svdt
			s6-svdt-clear
			s6-svlink
			s6-svlisten
			s6-svlisten1
			s6-svok
			s6-svperms
			s6-svscan
			s6-svscanctl
			s6-svstat
			s6-svunlink
			s6-svwait
			s6-tai64n
			s6-tai64nlocal
			s6-usertree-maker
			"
    	s6rc="
			s6-rc
			s6-rc-bundle
			s6-rc-compile
			s6-rc-db
			s6-rc-dryrun
			s6-rc-fdholder-filler
			s6-rc-format-upgrade
			s6-rc-init
			s6-rc-oneshot-run
			s6-rc-update
			"
		posix="
			admin
			alias
			ar
			asa
			at
			awk
			basename
			batch
			bc
			bg
			c17
			cal
			cat
			cd
			cflow
			chgrp
			chmod
			chown
			cksum
			cmp
			comm
			command
			compress
			cp
			crontab
			csplit
			ctags
			cut
			cxref
			date
			dd
			delta
			df
			diff
			dirname
			du
			echo
			ed
			env
			ex
			expand
			expr
			false
			fc
			fg
			file
			find
			fold
			fuser
			gencat
			get
			getconf
			getopts
			gettext
			grep
			hash
			head
			iconv
			id
			ipcrm
			ipcs
			jobs
			join
			kill
			lex
			link
			ln
			locale
			localedef
			logger
			logname
			lp
			ls
			m4
			mailx
			make
			man
			mesg
			mkdir
			mkfifo
			more
			msgfmt
			mv
			newgrp
			ngettext
			nice
			nl
			nm
			nohup
			od
			paste
			patch
			pathchk
			pax
			pr
			printf
			prs
			ps
			pwd
			read
			readlink
			realpath
			renice
			rm
			rmdel
			rmdir
			sact
			sccs
			sed
			sh
			sleep
			sort
			split
			strings
			strip
			stty
			tabs
			tail
			talk
			tee
			test
			time
			timeout
			touch
			tput
			tr
			true
			tsort
			tty
			type
			ulimit
			umask
			unalias
			uname
			uncompress
			unexpand
			unget
			uniq
			unlink
			uucp
			uudecode
			uuencode
			uustat
			uux
			val
			vi
			wait
			wc
			what
			who
			write
			xargs
			xgettext
			yacc
			zcat
			"
        execline="
			background
			backtick
			case
			define
			dollarat
			elgetopt
			elgetpositionals
			elglob
			eltest
			emptyenv
			envfile
			exec
			execlineb
			execline-cd
			execline-umask
			exit
			export
			export-array
			fdblock
			fdclose
			fdmove
			fdreserve
			fdswap
			forbacktickx
			foreground
			forstdin
			forx
			getcwd
			getpid
			heredoc
			homeof
			if
			ifelse
			ifte
			ifthenelse
			importas
			loopwhilex
			multidefine
			multisubstitute
			pipeline
			piperw
			posix-cd
			posix-umask
			redirfd
			runblock
			shift
			trap
			tryexec
			unexport
			wait
			withstdinas
			"

        join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }

    	# Add the language's grammar to the static completion list
    	printf %s\\n "declare-option str-list sh_static_words $(join "${keywords}" ' ') $(join "${execline}" ' ') $(join "${s6}" ' ') $(join "${s6rc}" ' ') $(join "${posix}" ' ')"

    	# Highlight keywords
    	printf %s\\n "add-highlighter shared/execline/code/ regex (?<!-)\b($(join "${keywords}" '|')|$(join "${s6}" '|')|$(join "${s6rc}" '|')|$(join "${posix}" '|'))\b(?!-) 0:keyword"

    	# Highlight builtins
    	printf %s "add-highlighter shared/execline/code/builtin regex (?<!-)\b($(join "${execline}" '|'))\b(?!-) 0:builtin"
	}
&

hook global WinSetOption filetype=execline %{
	require-module execline

	add-highlighter window/execline ref execline

	hook -once -always window WinSetOption filetype=.* %{
		remove-highlighter window/execline
	}
}