UNPKG

1.44 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 relevance: 0.2
57 }
58 ]
59 };
60 const STRING = {
61 className: 'string',
62 contains: [ ANTIQUOTE ],
63 variants: [
64 {
65 begin: "''",
66 end: "''"
67 },
68 {
69 begin: '"',
70 end: '"'
71 }
72 ]
73 };
74 const EXPRESSIONS = [
75 hljs.NUMBER_MODE,
76 hljs.HASH_COMMENT_MODE,
77 hljs.C_BLOCK_COMMENT_MODE,
78 STRING,
79 ATTRS
80 ];
81 ANTIQUOTE.contains = EXPRESSIONS;
82 return {
83 name: 'Nix',
84 aliases: [ "nixos" ],
85 keywords: KEYWORDS,
86 contains: EXPRESSIONS
87 };
88}
89
90module.exports = nix;