Atom AHK Support

Discuss features, issues, about Editors for AHK
mikek
Posts: 11
Joined: 30 Sep 2013, 17:17

Atom AHK Support

29 Dec 2015, 13:12

A coworker has prepared an updated Atom syntax theme for AHK, forked from an earlier piece of work from another user. The link is shown below if anyone is interested.

https://github.com/cescue/language-autohotkey

Image
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: Atom AHK Support

29 Dec 2015, 15:11

comments in orange?

normal variables in faded gray?

and aString = "Three point one four" is a literal string, with quotes included, since you used = instead of :=

cescue
Posts: 3
Joined: 29 Dec 2015, 13:14
Contact:

Re: Atom AHK Support

29 Dec 2015, 16:14

Hi there - maintainer of the repository chiming in.
guest3456 wrote:comments in orange?

normal variables in faded gray?
These colors are determined by Atom themes, not the syntax package. The syntax package simply identifies constructs of the language, themes handle which of those constructs should be highlighted (and in what color).
guest3456 wrote: aString = "Three point one four" is a literal string, with quotes included, since you used = instead of :=
This is valid criticism, I'll eventually update the screenshot.
lexikos
Posts: 9553
Joined: 30 Sep 2013, 04:07
Contact:

Re: Atom AHK Support

29 Dec 2015, 19:30

The entire sample script should be orange. ;)

Code: Select all

/* This is a comment
This is a comment  */
This is still a comment ....
*/
This is not a comment
The forum's syntax highlighting also gets it wrong.
cescue
Posts: 3
Joined: 29 Dec 2015, 13:14
Contact:

Re: Atom AHK Support

30 Dec 2015, 11:43

Thanks for the feedback! I'll look into fixing that in a (near) future update - it's still a work in progress, and there's a lot left to do.
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: Atom AHK Support

30 Dec 2015, 11:49

cescue wrote: These colors are determined by Atom themes, not the syntax package. The syntax package simply identifies constructs of the language, themes handle which of those constructs should be highlighted (and in what color).
gotcha, similar to Vim

cescue
Posts: 3
Joined: 29 Dec 2015, 13:14
Contact:

Re: Atom AHK Support

30 Dec 2015, 12:08

guest3456 wrote:
cescue wrote: These colors are determined by Atom themes, not the syntax package. The syntax package simply identifies constructs of the language, themes handle which of those constructs should be highlighted (and in what color).
gotcha, similar to Vim
Exactly. I'll eventually add some screenshots with different themes to the readme, but I'd like to iron out the kinks before working on the documentation.
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
Contact:

Re: Atom AHK Support

30 Dec 2015, 16:16

@cescue: I'm not really familiar w/ Atom's customization. Last I read, Atom chose to emulate Sublime/TextMate language grammar definition(.tmLanguage), the only difference is the storage mechanism which is CSON/JSON for Atom. As reference, you can check out the AutoHotkey package for Sublime which comes with the language file or you can check out my custom language file for Sublime.
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Atom AHK Support

04 Jan 2016, 00:14

cescue's fork will now be the "defacto" official one. ;)
https://github.com/nshakin/language-aut ... -168565610
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: Atom AHK Support

03 Feb 2018, 07:11

cescue's syntax highlight (github and in Atom PM) is the most recent one I found but it has some issues for expressions.

For example look at these weird highlight variations with RegExMatch.
atom2.PNG
atom2.PNG (12.61 KiB) Viewed 12327 times
The needle strings should consistently have green highlight here. But that only works if the string has a special character and no option set. In line 9 the green works but instead the expression RegExMatch lacks blue highlight.

Any ideas on how to fix this? Or link to already existing solution?

edit: apparently this is the source file that would need to be changed, https://github.com/cescue/language-auto ... otkey.cson . I've never tweaked syntax highlight files before. Any help is much appreciated.
neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: Atom AHK Support

05 Feb 2018, 17:48

I think that's only how to change text color for functions. Not changing what in the text gets detected as a functions. The problem is Cescue's syntax highlight code doesn't recognize all valid AutoHotkey functions (and strings, ...) as such. All "RegExMatch" instances in my image above should have the same color, since they're the same language entity. But the colors differ. All three needle strings should also have the same color.

Compare this from Notepad++ where the AutoHotkey syntax is detected correctly.
notepadpp.PNG
notepadpp.PNG (6.83 KiB) Viewed 12273 times
The thing to fix is the regex parts in this file https://github.com/cescue/language-auto ... otkey.cson

But I'm stuck on that. Tried peeking at how Notepad++ does it, but the syntax files there are very different. See
https://github.com/k4gdw/AutoHotKey-Not ... ng_AHK.xml . Do you know of some other editor with good AutoHotkey syntax highlighting where the syntax detection code uses regex and have some similarity in structure with the linked Atom file? Some such related good example could be very helpful in figuring out a fix.

edit: realized I had missed coco's comment upthread.
Coco wrote:@cescue: I'm not really familiar w/ Atom's customization. Last I read, Atom chose to emulate Sublime/TextMate language grammar definition(.tmLanguage), the only difference is the storage mechanism which is CSON/JSON for Atom. As reference, you can check out the AutoHotkey package for Sublime which comes with the language file or you can check out my custom language file for Sublime.
Those do look similar. Will look for some spec on the Atom syntax file and how they differ and then try to port over from Sublime. But troubleshooting regex code for detecting regex code is disorienting.
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Atom AHK Support

05 Feb 2018, 22:28

Yes you're right.... possibly the regex used is just wonky?
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: Atom AHK Support

24 Feb 2018, 14:51

I took another look at getting better AutoHotkey syntax highlight in Atom. No solution yet, but here are some notes.

There are two separate Sublime syntax files for AutoHotkey here
https://github.com/ahkscript/SublimeAut ... tmLanguage
https://github.com/cocobelgica/Subl-Aut ... tmLanguage

Those files have the plist format (it says so near the top in the files at least).

According to this comment
https://github.com/idleberg/atom-atomiz ... -244297705
plist formatted syntax files can be converted to Atom format

The manual has a page here
https://flight-manual.atom.io/hacking-a ... -textmate/
however it is only for converting from .tmbundle (TextMate Grammar Bundle) , which from what I can tell includes more than the .tmLanguage file. So the described command doesn't work on the .tmLanguage files. (I tried on both with both the github URL and with downloaded versions of the same file).

I have found no instruction on how to autoconvert only .tmLanguage files.

Others have run into the same problem as seen in these two posts
https://discuss.atom.io/t/how-to-get-sy ... iles/39594
https://github.com/atom/apm/issues/416

but neither of those pages contain a solution

The instruction for creating a grammar from scratch is here
https://flight-manual.atom.io/hacking-a ... a-grammar/

There is also a tool called Atomizr https://atom.io/packages/atomizr but it "can only convert .sublime-completions and .sublime-snippet files", not syntax files.

Return to “Editors”

Who is online

Users browsing this forum: No registered users and 20 guests