1 /*! `nix` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
8 Author: Domen Kožar <domen@dev.si>
9 Description: Nix functional language
10 Website: http://nixos.org/nix
14 /** @type LanguageFn */
16 const regex
= hljs
.regex
;
61 match: regex
.either(...[
64 "addDrvOutputDependencies",
175 "unsafeDiscardOutputDependency",
176 "unsafeDiscardStringContext",
180 ].map(b
=> `builtins\\.${b}`)),
184 const IDENTIFIER_REGEX
= '[A-Za-z_][A-Za-z0-9_\'-]*';
186 const LOOKUP_PATH
= {
188 match: new RegExp(`<${IDENTIFIER_REGEX}(/${IDENTIFIER_REGEX})*>`),
191 const PATH_PIECE
= "[A-Za-z0-9_\\+\\.-]+";
194 match: new RegExp(`(\\.\\.|\\.|~)?/(${PATH_PIECE})?(/${PATH_PIECE})*(?=[\\s;])`),
197 const OPERATOR_WITHOUT_MINUS_REGEX
= regex
.either(...[
221 match: regex
.concat(OPERATOR_WITHOUT_MINUS_REGEX
, /(?!-)/),
225 // '-' is being handled by itself to ensure we are able to tell the difference
226 // between a dash in an identifier and a minus operator
229 match: new RegExp(`${hljs.NUMBER_RE}(?!-)`),
232 const MINUS_OPERATOR
= {
237 // The (?!>) is used to ensure this doesn't collide with the '->' operator
242 new RegExp(`${hljs.NUMBER_RE}`),
253 OPERATOR_WITHOUT_MINUS_REGEX
,
267 beforeMatch: /(^|\{|;)\s*/,
268 begin: new RegExp(`${IDENTIFIER_REGEX}(\\.${IDENTIFIER_REGEX})*\\s*=(?!=)`),
274 match: new RegExp(`${IDENTIFIER_REGEX}(\\.${IDENTIFIER_REGEX})*(?=\\s*=)`),
280 const NORMAL_ESCAPED_DOLLAR
= {
281 scope: 'char.escape',
284 const INDENTED_ESCAPED_DOLLAR
= {
285 scope: 'char.escape',
294 const ESCAPED_DOUBLEQUOTE
= {
295 scope: 'char.escape',
298 const ESCAPED_LITERAL
= {
299 scope: 'char.escape',
309 INDENTED_ESCAPED_DOLLAR
,
319 NORMAL_ESCAPED_DOLLAR
,
327 const FUNCTION_PARAMS
= {
329 match: new RegExp(`${IDENTIFIER_REGEX}\\s*:(?=\\s)`),
332 const EXPRESSIONS
= [
334 hljs
.HASH_COMMENT_MODE
,
335 hljs
.C_BLOCK_COMMENT_MODE
,
340 subLanguage: 'markdown',
354 ANTIQUOTE
.contains
= EXPRESSIONS
;
358 scope: 'meta.prompt',
359 match: /^nix-repl>(?=\s)/,
365 begin: /:([a-z]+|\?)/,
371 aliases: [ "nixos" ],
373 contains: EXPRESSIONS
.concat(REPL
),
381 hljs
.registerLanguage('nix', hljsGrammar
);