autohotkey.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. var BACKTICK_ESCAPE = {
  10. begin: '`[\\s\\S]'
  11. };
  12. return {
  13. name: 'AutoHotkey',
  14. case_insensitive: true,
  15. aliases: ['ahk'],
  16. keywords: {
  17. 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',
  18. literal: 'true false NOT AND OR',
  19. built_in: 'ComSpec Clipboard ClipboardAll ErrorLevel',
  20. },
  21. contains: [
  22. BACKTICK_ESCAPE,
  23. hljs.inherit(hljs.QUOTE_STRING_MODE, {contains: [BACKTICK_ESCAPE]}),
  24. hljs.COMMENT(';', '$', {relevance: 0}),
  25. hljs.C_BLOCK_COMMENT_MODE,
  26. {
  27. className: 'number',
  28. begin: hljs.NUMBER_RE,
  29. relevance: 0
  30. },
  31. {
  32. 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
  33. begin: '%[a-zA-Z0-9#_$@]+%'
  34. },
  35. {
  36. className: 'built_in',
  37. begin: '^\\s*\\w+\\s*(,|%)'
  38. //I don't really know if this is totally relevant
  39. },
  40. {
  41. className: 'title', //symbol would be most accurate however is higlighted just like built_in and that makes up a lot of AutoHotkey code
  42. //meaning that it would fail to highlight anything
  43. variants: [
  44. {begin: '^[^\\n";]+::(?!=)'},
  45. {begin: '^[^\\n";]+:(?!=)', relevance: 0} // zero relevance as it catches a lot of things
  46. // followed by a single ':' in many languages
  47. ]
  48. },
  49. {
  50. className: 'meta',
  51. begin: '^\\s*#\\w+', end:'$',
  52. relevance: 0
  53. },
  54. {
  55. className: 'built_in',
  56. begin: 'A_[a-zA-Z0-9]+'
  57. },
  58. {
  59. // consecutive commas, not for highlighting but just for relevance
  60. begin: ',\\s*,'
  61. }
  62. ]
  63. }
  64. }
  65. module.exports = autohotkey;