Atom is actually really good

Monkey Archive Forums/Monkey Discussion/Atom is actually really good

Shinkiro1(Posted 2016) [#1]
I have spent the last few days customizing atom to be used as a monkey editor:



I have the following things working:
* Syntax Highlighting
* Build and Run + Targets
* Terminal Output + Inline Error Messages
* Snippets
* Code Completion (not intelligent though)
* Possibility to run ANY JS code before and after the build



Unfortunately I can't share the complete thing yet, as it relies on Atom functionality that hasn't even hit Beta, so it will be a few weeks until then.

For the snippets and completions I have built a tool that exports functions, methods, etc. so they can then be used by atom.


Nobuyuki(Posted 2016) [#2]
Looking forward to trying this.


Leo Santos(Posted 2016) [#3]
Awesome, please share when possible!


Playniax(Posted 2016) [#4]
Nice. Also looking forward to trying this!


Shinkiro1(Posted 2016) [#5]
Ok, guys. I have published the package here: https://atom.io/packages/monkey-x

You can install it from inside Atom by just going to Settings -> Install and search for 'monkey'. Then hit install.
This should give you syntax highlighting, as well as some snippets.

For building and nice git integration I would install these packages (git one is optional):


In the root of your Project Folder, create a file called '.atom-build.js', paste this code into it:
Replace the MONKEY_PATH and MONKEY_MAIN_FILE depending on your project
var MONKEY_PATH = "~/monkey/bin/transcc_macos";
var MONKEY_MAIN_FILE = "main.monkey";

var REGEXP_ERRORS_MONKEY = "(?<file>[\/0-9a-zA-Z\._]+)<(?<line>[0-9]+)> : Error : (?<message>.+)";

module.exports = monkeyBuild = {
  "cmd": MONKEY_PATH + " -build -target=Html5_Game {PROJECT_PATH}/" + MONKEY_MAIN_FILE,
  "name": "Html5 - Build",
  "sh": true,
  "errorMatch": [
      REGEXP_ERRORS_MONKEY
   ],

  "targets": {
     "Html5 - Build & Run": {
        "cmd": MONKEY_PATH + " -build -run -target=Html5_Game {PROJECT_PATH}/" + MONKEY_MAIN_FILE,
        "errorMatch": [
           REGEXP_ERRORS_MONKEY
         ]
     },
     "Desktop - Build": {
        "cmd": MONKEY_PATH + ' -build -target="Desktop_Game_(Glfw3)" {PROJECT_PATH}/' + MONKEY_MAIN_FILE,
        "errorMatch": [
           REGEXP_ERRORS_MONKEY
         ]
     }
  },

  preBuild: function () {

  },

  postBuild: function () {

  }
};


Restart Atom and you should be all set.
* Change Targets in the lower left corner.
* The compile button is above the terminal, like a lighting icon.

You can change all settings inside Settings -> Packages, click on a package to reveal it's options.


Leo Santos(Posted 2016) [#6]
Works, thanks! And it already seems to work better than the Sublime Monkey package.

Is there a way to lock the main build file with a shortcut? I assume there isn't, but it would be super nice. Currently it looks like that after editing the .atom-build.js file it's necessary to quit Atom and relaunch it so it reads the file again, unless I'm missing something.

Thanks again for doing that!
Leo.


Shinkiro1(Posted 2016) [#7]
> Is there a way to lock the main build file with a shortcut?
It should use the the file you specify in the MONKEY_MAIN_FILE variable.
You only need to change .atom-build.js once.

Btw, you can make shortcuts to these commands:
Go to menu Atom -> Keymap: I use Cmd-R for building:
.platform-darwin atom-workspace, .platform-darwin atom-text-editor':
   'cmd-r': 'build:trigger'



wiebow(Posted 2016) [#8]
Nice!!! I am working on a Monkey 2 Sublime Text package... I personally am not too fond of Atom, overall... Guess I am too used to Sublime. :)


Leo Santos(Posted 2016) [#9]
You only need to change .atom-build.js once.

True, but it doesn't seem to "refresh" the build file, I need to restart Atom (I'm on OS X, not sure what the behavior is on Windows). It's only an issue if I need to temporarily build a different file, like when I download a code example and want to test it quickly outside of my main project.

Still, works great as it is. Thanks again!

Guess I am too used to Sublime. :)

I actually thought they basically built a Sublime 3 clone! :-) But there's something about Atom that seems easier to customise. I think they "hand hold" the user more, providing easy to find links to the config files, helpful explanatory comments in the files themselves, etc. I appreciate that.

Cheers!


Salmakis(Posted 2016) [#10]
i also use atom since a few weeks

i tried brakets, sublime, notepad++, vs code, they all cant beat atoms speed and its possibles of customisation and all the awesome addons wich are installed with 1 click, wich boost the lil atom into a state where it can get into competition with big IDEs such as jungle, netbeans, VisualStudio and even JetBrains stuff.

and all for free

im in love!


skid(Posted 2016) [#11]
Looks awesome!

I wonder if VSCode plugins use a similar system?

As well as being really good, Atom sure is really cool!




Leo Santos(Posted 2016) [#12]
Have been using it and it's been working great.

The only issue I found with syntax highlighting is after a "Select" block, probably because each "Case" doesn't have a corresponding "End"?
Here's a screenshot:




wiebow(Posted 2016) [#13]
Leo Santes: If you're looking for speed then Sublime cannot be beat. But I agree, the docs for Atom are much nicer than Sublimes!

Skid: VScode plugins use a slightly different system. The language definition files are the same.
I'm now using the new sublime-syntax format and it's really nice as well. Pros and cons! :) YAML is nice though!!!!!


Danilo(Posted 2016) [#14]
Crazy world... 254 MB for Atom Editor on Mac OS X.

Mollusk for MonkeyX is 2.9 MB, Ted is 188 KB, Ted2 was 12 MB, Sublime Text with support for many languages is 27.1 MB.

10 to 100 times bigger... that's quite a thing/difference.


wiebow(Posted 2016) [#15]
Atom is based on Electron (node.js) and this adds to the bloat. Native text editors will always be smaller/faster. VS Studio has the same problem as it is based on the same tech. Atom and VS Studio as in essence web servers/pages disguised as desktop applications. Funny stuff, but overly complicated.


wiebow(Posted 2016) [#16]
The thing that is is baffling me atm when making a language file is that an IF statement can be a single line, and it can be a block! It messing up the check for the END statement. I think that is the problem in the above screenshot as well...


Shinkiro1(Posted 2016) [#17]
I have copied the whole grammar from the TextMate bundle someone published here.
And yes, that problem is also in TextMate. It can't handle single line ifs (code after it will not be properly highlighted) and select case seems to be another issue.
If someone knows how to fix this (oh regular expressions) it would be great, as Sublime, TextMate and Atom all use the exact same grammer file/format.

---

I am also running nwjs now instead of mserver.
This gives you a single window when running your game, and I customized the monkey print statement for html5 so it now outputs to the atom console.
You can find a post from AdamRedwoods way back here in the forums describing how to set it up.


RenK(Posted 2016) [#18]
I've been messing around with my own sublime package for a while off and on as I find time to spend tinkering with Monkey, great to see Atom support as well :D

I copied the text in the above screenshot and the syntax highlighting appears to hold up in sublime text with my bundle installed:

Unfortunately I don't know enough about the inner workings of the syntax file to know what's effecting it. It was just copied from a copy of a copy of some old bundles posted on the forums here. Feel free to give it a look: https://github.com/Russell-King/SubMonkey


arawkins(Posted 2016) [#19]
Hey, just wanted to say thanks for doing this. I have been using Atom quite a bit for the past few weeks and having Monkey working with it is great :)


arawkins(Posted 2016) [#20]
@Shinkiro1 Do you want pull requests on this package? I have a few updates I've made to the grammar file that adds some basic Monkey2 support, and fixes the issue with the Select block mentioned above.


Shinkiro1(Posted 2016) [#21]
@arawkins For the fixes, yes that would be great.
For monkey2: I think that should be a separate package. E.g. Keywords like namespace should not be highlighted in monkey1.


arawkins(Posted 2016) [#22]
Yeah, ok, good point. I have submitted a request with the monkey2 stuff removed.


Shinkiro1(Posted 2016) [#23]
@arawkins
sorry for the late reply. With your package "select case" now works like a charm :)
I changed a few things in the package locally though, so I have manually integrated your pull request for now.
Will update when I have time.


arawkins(Posted 2016) [#24]
No worries, glad it works for you. Out of curiosity, are you planning to do any Monkey 2 support in this (or a separate) module? I was thinking about continuing to work on it in my fork. I'm happy to just plug away at it, but if you are working on it as well, maybe we could/should combine our efforts?


Shinkiro1(Posted 2016) [#25]
Right now I don't have the time so feel free to fork it (Publishing an atom package is not that hard, it's all in their docs)


arawkins(Posted 2016) [#26]
Alright, will do. Thanks again for all your work, it is great to have a starting point to work from.

*update*
Monkey2 package is up here:
https://atom.io/packages/language-monkey2

Forum Thread:
http://monkey2.monkey-x.com/forums/topic/atom-package-for-monkey2/