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