autohotkey.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. module.exports = function(hljs) {
  2. var BACKTICK_ESCAPE = {
  3. begin: '`[\\s\\S]'
  4. };
  5. return {
  6. case_insensitive: true,
  7. aliases: [ 'ahk' ],
  8. keywords: {
  9. keyword: 'Break Continue Critical Exit ExitApp Gosub Goto New OnExit Pause return SetBatchLines SetTimer Suspend Thread Throw Until ahk_id ahk_class ahk_pid ahk_exe ahk_group',
  10. literal: 'true false NOT AND OR',
  11. built_in: 'ComSpec Clipboard ClipboardAll ErrorLevel',
  12. },
  13. contains: [
  14. BACKTICK_ESCAPE,
  15. hljs.inherit(hljs.QUOTE_STRING_MODE, {contains: [BACKTICK_ESCAPE]}),
  16. hljs.COMMENT(';', '$', {relevance: 0}),
  17. hljs.C_BLOCK_COMMENT_MODE,
  18. {
  19. className: 'number',
  20. begin: hljs.NUMBER_RE,
  21. relevance: 0
  22. },
  23. {
  24. className: 'variable', //subst would be the most accurate however fails the point of highlighting. variable is comparably the most accurate that actually has some effect
  25. begin: '%[a-zA-Z0-9#_$@]+%'
  26. },
  27. {
  28. className: 'built_in',
  29. begin: '^\\s*\\w+\\s*(,|%)'
  30. //I don't really know if this is totally relevant
  31. },
  32. {
  33. className: 'title', //symbol would be most accurate however is higlighted just like built_in and that makes up a lot of AutoHotkey code
  34. //meaning that it would fail to highlight anything
  35. variants: [
  36. {begin: '^[^\\n";]+::(?!=)'},
  37. {begin: '^[^\\n";]+:(?!=)', relevance: 0} // zero relevance as it catches a lot of things
  38. // followed by a single ':' in many languages
  39. ]
  40. },
  41. {
  42. className: 'meta',
  43. begin: '^\\s*#\\w+', end:'$',
  44. relevance: 0
  45. },
  46. {
  47. className: 'built_in',
  48. begin: 'A_[a-zA-Z0-9]+'
  49. },
  50. {
  51. // consecutive commas, not for highlighting but just for relevance
  52. begin: ',\\s*,'
  53. }
  54. ]
  55. }
  56. };