autohotkey.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. Language: AutoHotkey
  3. Author: Seongwon Lee <dlimpid@gmail.com>
  4. Description: AutoHotkey language definition
  5. Category: scripting
  6. */
  7. /** @type LanguageFn */
  8. function autohotkey(hljs) {
  9. const BACKTICK_ESCAPE = { begin: '`[\\s\\S]' };
  10. return {
  11. name: 'AutoHotkey',
  12. case_insensitive: true,
  13. aliases: [ 'ahk' ],
  14. keywords: {
  15. 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',
  16. literal: 'true false NOT AND OR',
  17. built_in: 'ComSpec Clipboard ClipboardAll ErrorLevel'
  18. },
  19. contains: [
  20. BACKTICK_ESCAPE,
  21. hljs.inherit(hljs.QUOTE_STRING_MODE, { contains: [ BACKTICK_ESCAPE ] }),
  22. hljs.COMMENT(';', '$', { relevance: 0 }),
  23. hljs.C_BLOCK_COMMENT_MODE,
  24. {
  25. className: 'number',
  26. begin: hljs.NUMBER_RE,
  27. relevance: 0
  28. },
  29. {
  30. // subst would be the most accurate however fails the point of
  31. // highlighting. variable is comparably the most accurate that actually
  32. // has some effect
  33. className: 'variable',
  34. begin: '%[a-zA-Z0-9#_$@]+%'
  35. },
  36. {
  37. className: 'built_in',
  38. begin: '^\\s*\\w+\\s*(,|%)'
  39. // I don't really know if this is totally relevant
  40. },
  41. {
  42. // symbol would be most accurate however is highlighted just like
  43. // built_in and that makes up a lot of AutoHotkey code meaning that it
  44. // would fail to highlight anything
  45. className: 'title',
  46. variants: [
  47. { begin: '^[^\\n";]+::(?!=)' },
  48. {
  49. begin: '^[^\\n";]+:(?!=)',
  50. // zero relevance as it catches a lot of things
  51. // followed by a single ':' in many languages
  52. relevance: 0
  53. }
  54. ]
  55. },
  56. {
  57. className: 'meta',
  58. begin: '^\\s*#\\w+',
  59. end: '$',
  60. relevance: 0
  61. },
  62. {
  63. className: 'built_in',
  64. begin: 'A_[a-zA-Z0-9]+'
  65. },
  66. {
  67. // consecutive commas, not for highlighting but just for relevance
  68. begin: ',\\s*,' }
  69. ]
  70. };
  71. }
  72. export { autohotkey as default };