nix.js 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. module.exports = function(hljs) {
  2. var NIX_KEYWORDS = {
  3. keyword:
  4. 'rec with let in inherit assert if else then',
  5. literal:
  6. 'true false or and null',
  7. built_in:
  8. 'import abort baseNameOf dirOf isNull builtins map removeAttrs throw ' +
  9. 'toString derivation'
  10. };
  11. var ANTIQUOTE = {
  12. className: 'subst',
  13. begin: /\$\{/,
  14. end: /}/,
  15. keywords: NIX_KEYWORDS
  16. };
  17. var ATTRS = {
  18. begin: /[a-zA-Z0-9-_]+(\s*=)/, returnBegin: true,
  19. relevance: 0,
  20. contains: [
  21. {
  22. className: 'attr',
  23. begin: /\S+/
  24. }
  25. ]
  26. };
  27. var STRING = {
  28. className: 'string',
  29. contains: [ANTIQUOTE],
  30. variants: [
  31. {begin: "''", end: "''"},
  32. {begin: '"', end: '"'}
  33. ]
  34. };
  35. var EXPRESSIONS = [
  36. hljs.NUMBER_MODE,
  37. hljs.HASH_COMMENT_MODE,
  38. hljs.C_BLOCK_COMMENT_MODE,
  39. STRING,
  40. ATTRS
  41. ];
  42. ANTIQUOTE.contains = EXPRESSIONS;
  43. return {
  44. aliases: ["nixos"],
  45. keywords: NIX_KEYWORDS,
  46. contains: EXPRESSIONS
  47. };
  48. };