UNPKG

1.42 kBJavaScriptView Raw
1/*
2Language: Nix
3Author: Domen Kožar <domen@dev.si>
4Description: Nix functional language
5Website: http://nixos.org/nix
6*/
7
8function nix(hljs) {
9 const KEYWORDS = {
10 keyword: [
11 "rec",
12 "with",
13 "let",
14 "in",
15 "inherit",
16 "assert",
17 "if",
18 "else",
19 "then"
20 ],
21 literal: [
22 "true",
23 "false",
24 "or",
25 "and",
26 "null"
27 ],
28 built_in: [
29 "import",
30 "abort",
31 "baseNameOf",
32 "dirOf",
33 "isNull",
34 "builtins",
35 "map",
36 "removeAttrs",
37 "throw",
38 "toString",
39 "derivation"
40 ]
41 };
42 const ANTIQUOTE = {
43 className: 'subst',
44 begin: /\$\{/,
45 end: /\}/,
46 keywords: KEYWORDS
47 };
48 const ATTRS = {
49 begin: /[a-zA-Z0-9-_]+(\s*=)/,
50 returnBegin: true,
51 relevance: 0,
52 contains: [
53 {
54 className: 'attr',
55 begin: /\S+/
56 }
57 ]
58 };
59 const STRING = {
60 className: 'string',
61 contains: [ ANTIQUOTE ],
62 variants: [
63 {
64 begin: "''",
65 end: "''"
66 },
67 {
68 begin: '"',
69 end: '"'
70 }
71 ]
72 };
73 const EXPRESSIONS = [
74 hljs.NUMBER_MODE,
75 hljs.HASH_COMMENT_MODE,
76 hljs.C_BLOCK_COMMENT_MODE,
77 STRING,
78 ATTRS
79 ];
80 ANTIQUOTE.contains = EXPRESSIONS;
81 return {
82 name: 'Nix',
83 aliases: [ "nixos" ],
84 keywords: KEYWORDS,
85 contains: EXPRESSIONS
86 };
87}
88
89export { nix as default };