summaryrefslogtreecommitdiff
blob: 8d539a8a9f3cef997b08e7daebf56aaf71c4debe (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
<?xml version="1.0" encoding="UTF-8"?>

<!--
	GtkSourceView syntax highlight for Gentoo-specific files

	Originally written for gtksourceview-1.x by:
		Leonardo Ferreira Fontenelle <leo.fontenelle@gmail.com>, 2006.
	Rewritten for gtksourceview-2 by:
		Rene 'Necoro' Neumann <necoro@necoro.net>, 2007
	
	Distributed under the same license(s) as gtksourceview.

	TODO:
	- do not highlight "enable" in the configure options
	- perhaps highlight portage variables and portage functions different

-->

<language name="gentoo" id="gentoo" version="2.0" _section="Scripts">
	<metadata>
		<property name="globs">*.ebuild;*.eclass</property>
		<property name="line-comment-start">#</property>
	</metadata>

	<styles>
		<style id="variable" _name="Portage variables" map-to="def:builtin" />
		<style id="command" _name="Portage command" map-to="def:type" />
		<style id="function" _name="Portage function" map-to="def:function" />
		<style id="string" _name="String" map-to="def:string" />
	</styles>

	<definitions>

		<!-- rewrite shell string to show highlighted variables -->
		<context id="string" style-ref="def:string">
			<start>"</start>
			<end>"</end>
			<include>
				<context ref="def:escape"/>
				<context ref="def:line-continue"/>
				<context ref="sh:variable"/>
			</include>
		</context>

		<context id="string-2" style-ref="def:string">
			<start>'</start>
			<end>'</end>
			<include>
				<context ref="def:escape"/>
				<context ref="def:line-continue"/>
				<context ref="sh:variable"/>
			</include>
		</context>

		<!-- subprograms:
			- $(..) is not supported currently in the normal sh.lang
			- `...` is interpreted as string - I think the subshell behavior is more acurate -->
		<context id="subprogram">
      		<start>\$\(</start>
      		<end>\)</end>
			<include>
				<context sub-pattern="0" where="start" style-ref="sh:keyword"/>
				<context sub-pattern="0" where="end" style-ref="sh:keyword"/>
				<context ref="gentoo"/>
			</include>
		</context>

		<context id="subprogram-2">
			<start>`</start>
      		<end>`</end>
			<include>
				<context sub-pattern="0" where="start" style-ref="sh:keyword"/>
				<context sub-pattern="0" where="end" style-ref="sh:keyword"/>
				<context ref="gentoo"/>
			</include>
		</context>

		<!-- portage variables - currently unused -->
		<context id="portvars" style-ref="variable">
			<match>\b((ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|FILESDIR|WORKDIR|(P|R)?DEPEND|PROVIDE|DISTDIR|RESTRICT|USERLAND)|(S|D|T|PV|PF|P|PN|A)|C(XX)?FLAGS|LDFLAGS|C(HOST|TARGET|BUILD))\b</match>
		</context>

		<!-- portage functions - currently unused -->
		<context id="portfuncs" style-ref="function">
			<match>^(src_(unpack|compile|install|test)|pkg_(config|nofetch|setup|(pre|post)(inst|rm)))</match>
		</context>

		<!-- extra portage commands -->
		<context id="portcmds" style-ref="command">
			<match>\b(e(begin|end|conf|install|make|warn|infon?|error|patch)|die|use(_(with|enable))?|inherit|has|(has|best)_version|unpack|(do|new)(ins|s?bin|doc|lib(|\.so|\.a)|man|info|exe|initd|confd|envd|pam|menu|icon)|do(python|sed|dir|hard|sym|html|jar|mo)|keepdir|prepall(|docs|info|man|strip)|prep(info|lib|lib\.(so|a)|man|strip)|(|doc|ins|exe)into|f(owners|perms)|(exe|ins|dir)opts)\b</match>
		</context>
		
		<context id="built-in-command">
			<include> <!-- do not include "sh:built-in-command" as it is replaced down there - which would lead to an endless loop -->
				<context ref="sh:reserved-word" />
				<context ref="sh:let-command" />
				<context ref="portcmds" />
			</include>
		</context>

		<!-- gentoo is just a shell with the replacements -->
		<replace id="sh:built-in-command" ref="built-in-command" />
		<replace id="sh:backtick-subshell" ref="subprogram-2" />
		<context id="gentoo">
			<include>
				<context ref="subprogram"/>
				<context ref="sh:sh"/>
			</include>
		</context>
	</definitions>
</language>