Emacs mode for Unity Javascript

January 15, 2010 in Community

As you  may have heard before every friday we spend our time working on personal projects.

I have been working on a Unity Javascript mode for Emacs for a few weeks ago and now is in a state that is usable enough to share with the community :).

emacs UnityJS

As you can see it colors comments (multiline and single line), has support for basic data types, and also supports string coloring.

It also colors function declarations, if – else decisions, while and for/foreach loops and most importantly, it colors all the Unity functions supported by the engine!

Feel free to modify it. Also if you do anything interesting that can be added to the mode just let me know!

If I have time I’ll add a function to open the browser and search the docs for the word where the cursor is positioned. If for some reason you make it before I can, then just contact me and I’ll add it to the mode :).

Anyway, if you, like me, are an emacs addict, you can grab this mode from here: unityjs-mode.el

To make it work, just add this to your .emacs:

;; UnityJS mode for emacs
(autoload ‘unityjs-mode “unityjs-mode” “Major mode for editing Unity script code.” t)
(require ‘unityjs-mode)

;; UnityJS mode for emacs
(autoload 'unityjs-mode "unityjs-mode" "Major mode for editing Unity Javascript code." t)
(require 'unityjs-mode)

And make sure to load the path where you are going to store the mode ;).

Comments (7)

Subscribe to comments
  1. jpkotta

    March 23, 2011 at 8:31 pm / 

    One of autoload or require are useless. The require loads the library immediately, the autoload defers it until unityjs-mode is invoked. Autoloading makes start up faster, and is usually preferable. This is what I would use:

    (autoload ‘unityjs-mode “unityjs-mode” “Major mode for editing Unity Javascript code.” t)
    (add-to-list ‘auto-mode-alist ‘(“\\.js\\'” . unityjs-mode))

  2. Juan

    January 22, 2010 at 11:30 am / 

    @timmcd: Shouldnt be difficult if you know some elisp.
    Actually, you can create a minor mode for Unity Javascript and use as Major mode js2-mode : ).
    check this page:

    This is where I got the info for creating the mode, you can create a minor mode with the words and it should work : )

    @technicat: I’m using Aquamacs as well : ), and now I only write unity js on emacs : P

  3. technicat

    January 21, 2010 at 10:38 pm / 

    Just tried it with Aquamacs. Nice!

  4. timmcd

    January 21, 2010 at 6:17 pm / 

    Awesome! I was wondering how difficult it would be to merge with http://code.google.com/p/js2-mode/ ? It has some nifty features, I’d love to have it’s features and the unity-function stuff from yours!

  5. Ashkan

    January 17, 2010 at 4:47 pm / 

    visual web developer express 2010 has a great java script IDE and it’s free. everyone that needs javascript IDE and has windows should take a look at VS2010. i encourage you to use C# however.

  6. Juan Sebastian

    January 17, 2010 at 3:51 pm / 

    Well… no…
    you can add it tho with some ELisp programming : )

  7. Cam Jackson

    January 17, 2010 at 6:22 am / 

    Does this have intellisense?

Comments are closed.