Search Unity

Unity JS TextMate Bundle?

Discussion in 'Formats & External Tools' started by thylaxene, May 17, 2007.

  1. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    Hi All TextMate users,

    I've finally updated the TextMate Unity JavaScript bundle to support Unity 2.1.

    Please back up the old one before installing this one, just in case! Also note to do a clean install of this bundle first remove the old one from /Users/yourName/Library/Application Support/TextMate/Bundles/ as TextMate seems to append when updating bundles... a bit annoying.

    I've also added the first revision of code completion to the bundle. Start typing a word and hit Option+Escape and a list of functions/classes/enumerations will pop up. Unfortunately this is as close as it gets to auto code completion in TextMate 1.57. So hopefully when 2 is released they'll have some kick arse approach! :wink:

    It's still a bit of a work in progress. I still need to add more function information to each function/class so you can then use "Documentation for Function Call (tool tip)", Control-Option-Escape to get some info to help remember what properties that function is expecting.

    I've also added a documentation link to Microsoft's online API for looking up those useful .NET/Mono functions.

    I've also cleaned up the syntax sets so that they work with the default TextMate syntax colours. Sorry to those who've already setup a nice colour set based of the old bundle.

    [EDITED] Added support for Unity iPhone and for these helpful 3rd party utilities: AniMate and SpriteManager.

    Enjoy.
     

    Attached Files:

  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    I just converted the Unity parts of Emanuel's C# bundle to work with JavaScript. I also added a snippet for Debug.Log (log<tab>). Find the bundle here. Please let me know if anything needs fixing.
     
  3. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Ok, that sort of whet my appetite for snippet making, so I've added macros for Update(), FixedUpdate(), Start(), typed variables, RequireComponent and AddComponentMenu. It's available at the original location.
     
  4. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    cool thanks. I ended up making my own as well. I will look at yours and combine the best of both and post here.

    Cheers.
     
  5. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    [EDITED] See top post.

    Cheers.
     
  6. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    textMate's not doing anything for me with the unzipped Unity JavaScript.tmbundle when I double click on it. :cry:
     
  7. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    see above. hopefully that fixed it

    cheers.
     
  8. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Now I get a error dialogue box at least ...

    Bundle is Corrupt
    The bundle Unity JavaScript.tmbundle does not contain the required info.plist file (or that file is corrupt) and can therefore not be installed.
    [Continue]
     
  9. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    see above hopefully it works now...

    [EDIT] it works. just tried it on a fresh install of TextMate.

    :D
     
  10. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Yup, works fine now here too. Thanks! textMate now set as my default editor.
     
  11. milkytreat

    milkytreat

    Joined:
    Jan 15, 2007
    Posts:
    267
    verfied working! huzzuh!
     
  12. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Yup, many many thanks Jon! I've been wanting to use TextMate as the editor since I bought it in the Macheist bundle. Superb! Hapy now.
     
  13. jeffcraighead

    jeffcraighead

    Joined:
    Nov 15, 2006
    Posts:
    740
    How do you use the autocomplete?

    Jeff
     
  14. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    start typing the word, then hit the escape key.

    Cheers.
     
  15. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Cool. Do you know how to get it to used the local documentation? I tried changing the path, but it comes up with a blank page.

    Edit: got this from here:
    Code (csharp):
    1. ref=${TM_SELECTED_TEXT}
    2. UNITYDOC="/Applications/Unity/Unity.app/Contents/Documentation/Documentation/ScriptReference/$ref.html"
    3.  
    4. if [[ -f "$UNITYDOC" ]]
    5.    then [[ -n "$UNITYDOC" ]]  exit_show_html "<meta http-equiv='Refresh' content='0;URL=tm-file://$UNITYDOC'>"
    6.    else echo "No Unity documentation found for: $TM_SELECTED_TEXT"
    7. fi
    It's better in two ways: it uses the local docs, and it goes directly to the documentation rather than doing a search. Although maybe it should do a search if it can't find the actual file. I'll look into that.
     
  16. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    Yes I know about the local documentation. The reason I changed it on my machine is because it didn't always work reliably. So I changed it to the web version.

    Cheers.
     
  17. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    What's better if you use TextMate instead of Unitron if you use it together with Unity?
     
  18. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    One of the best features is the project wide find replace. It rocks. You cna also work within a project and outside a project at the same time, so you can for instance have the same car.js script open from 2 unity projects and clearly see and tell which is which.
     
  19. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    Hmm okay is the find based on grep?
     
  20. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    I don't know.. I didn't write it... email the TextMate people.
     
  21. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    I thought it might be written in the docs or you can see it if such commands are defined as macros for instance...anyway thanks!
     
  22. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    it has full support for Regular Expressions. And I found it very easy to use it to strip out unwanted characters, etc. I used its regex engine to strip out all the HTML tag info from the index of classes/method names in the online Untiy docs and wrap it in XML to use in the JS bundle. :wink:

    Cheers.
     
  23. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    okidoki
     
  24. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    just bumping. as I've updated the bundle for Unity 2. See my first post.

    Cheers.
     
  25. Richard_B

    Richard_B

    Joined:
    Jul 22, 2005
    Posts:
    436
    The other really useful thing I find with Textmate is the TODO bundle - very useful for keeping track of changes, fixes, todo's etc.

    Richard.

    PS Thanks for the js bundle!
     
  26. DocSWAB

    DocSWAB

    Joined:
    Aug 28, 2006
    Posts:
    615
    Thanks a lot Jon -- I'd been pulling in bits and pieces, and it's nice to add yours in.

    One thing I noticed on the AutoComplete list -- they got rid of the hard numberd Custom GUI Styles -- they are all just members of the Custom array now (Documentation is wrong on this).

    Cheers,
    Steve
     
  27. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Thanks much Jon!
     
  28. Neural Echo

    Neural Echo

    Joined:
    Jul 5, 2007
    Posts:
    83
    Looks good, thanks Jon.

    Is TextMate able to parse multiple project files for programmer defined classes and their associated methods/functions and variables, and then use that information for auto-completion?
     
  29. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    605
    Just discovered and downloaded this! Thanks a lot! ^_^
     
  30. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    Thanks for your efforts all -- I've just started using TextMate with Unity, but it's worth noting that TextWrangler (the free version of BBEdit) has directory-wide search and replace (using grep). It's a shame that the escape key triggers autocomplete, I find it both unintuitive (although I can learn) and slow. RealBasic's or Coda's intellisense-style autocomplete is light-years ahead (neither require you to do anything to see suggested matches).

    Maybe TextMate 2.x.
     
  31. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    I've updated the bundle. Look at the very first post.

    Cheers.
     
  32. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Anyone know if it would be possible to run a command-line program to assist the code completion script? If so, it would be possible to add full code completion via reflection.
     
  33. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    Well the code completion script is already using a ruby script to work... so in theory it already using command line. But the problem is I can't see anywhere in TM where you can hook into 'while user is typing run this script' sort of thing. Which is the sort of code completion people are after with TM. The TM developer has already said that isn't possible in the current version of TM.

    I do have code completion running in skEdit (http://www.skti.org/skedit/) for Unity, which does pop up suggestions while you're typing. But unfortunately there are still some limitations in skEdit that in my mind make it less useful as the external text editor for Unity then TM.

    Cheers.
     
  34. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Hm. I guess we'll have to wait around for TM2. Is the release one of the fouler "soon (tm)" announcements or could it be expected to be sometime within three months for instance?
     
  35. Lab013

    Lab013

    Joined:
    Oct 22, 2008
    Posts:
    405
    You ROCK! Love the bundle, thanks!
     
  36. potan

    potan

    Joined:
    Nov 2, 2008
    Posts:
    177
    thylaxene, any plan to add/update with Iphone related function ??

    btw this bundle is super AWESOME !!
    saves me from lots of typing :D
     
  37. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    Yes I will now that I have an iphone license.

    Cheers.
     
  38. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
  39. potan

    potan

    Joined:
    Nov 2, 2008
    Posts:
    177
    niceee....
    thanks a lot thylaxene 8)
     
  40. S.T.

    S.T.

    Joined:
    Sep 10, 2008
    Posts:
    40
    Is it possible to do the code completion on keyboard shortcut? ("ctrl-space" preferably...)
     
  41. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    It's pretty easy to change that yourself to whatever combo you want using the Bundle Editor under the Bundles menu. But if enough people ask for I will change it in the default bundle.

    Cheers.
     
  42. horsman

    horsman

    Joined:
    Jul 19, 2008
    Posts:
    156
    I've got code completion working for Classes defined anywhere in the Textmate project. They only complete the class names though.

    I am not sure if reflection would work because some classes might not compile (particularly the one that you are typing in). Furthermore, you would need the user to have the program that finds the completions.

    It seems possible, but also like much work. If you could supply me with a C# program that takes:
    current word,
    current type,
    and a file that has the class definition for that type (unless it it a built in type, in which case you find it)
    and returns a list of possible completions, I can put it into textmate. It should fail gracefully and produce no output if no completions are found or the file searched does not compile.
     
  43. horsman

    horsman

    Joined:
    Jul 19, 2008
    Posts:
    156
    I forgot to attach my Bundle!

    EDIT: Just noticed the updates the OP made. Need to add them in too.

    EDIT EDIT: Also noticed that for some reason I lost the documentation lookup and other things that derived from the old Unity Javascript Bundle. More update tomorrow.

    This zip contains two bundles: C#, and Unity.
    The Unity bundle is an amalgamation of the Unity (Javascript) and C# (Unity) Bundles as well as Neal Carter's Unity Bundle. It attempts to replace all three. It includes autoComplete (C#) support for Class names in the current Textmate Project, and highlights Type words properly. It includes Types for unity 2.5 as per Neal's additions. I could probably get teh autocomplete working for JS if there is interest.
     

    Attached Files:

  44. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Is this the latest for v2.5?

    Yes please? :)Would like to see JS autocomplete back in again[/quote]
     
  45. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    Hi Horsman,

    Does your bundle use my JS bundle at the beginning of this thread? As it seems you archive is smaller then mine, would be nice to combine the two so there is one definitive TextMate bundle! :D

    Cheers.
     
  46. gersaky

    gersaky

    Joined:
    Dec 24, 2008
    Posts:
    42
    I've installed the bundle, but for some reason syntax highlighting isn't working for me...

    e.g. comments show up as regular black text...

    Is there something I'm missing?
     
  47. gersaky

    gersaky

    Joined:
    Dec 24, 2008
    Posts:
    42
    I figured it out... For whatever reason, I had the Javascript bundle disabled. The Unity bundle must piggyback on that for the highlighting...

    :oops: :oops: :oops: :oops: :oops: :oops:
     
  48. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Agreed! Seems there are a bunch of different bundle versions floating around and it is not clear which bundle version supports which version of Unity API and which features.

    In this day age, with forums and wikis, etc. the confusion, fragmentation, lack of organization is simply unnecessary!

    Thylaxene, can you _upload_ the latest bundle to the wiki entry here?

    If so, please include version info on the bundle (can be the date if you want), which version of the Unity API is supported (is v2.5 supported?), iPhone support?, etc. Will ask the other TM bundle creators to do the same (for C#, Boo, ShaderLab).

    Rather than linking back to the messy forums for each language, would like to see the wiki become THE place to download TM Unity bundles... Let's use what we have people! :)

    Also, to contribute to the latest bundle, here is an updated folding definition to include switch cases:
    Code (csharp):
    1.  
    2.     foldingStartMarker = '/\*\*|\{\s*$|\s*(case)';
    3.     foldingStopMarker = '\*\*/|^\s*\}|^\s*(break)';
    /me is tired of hunting 4 forum threads to install the latest TM bundles. :)
     
  49. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    Cool no problem I'll have look at both JS bundles and combine the best of both and update it for 2.5 and iPhone. (which it mostly has)... but I've noticed in my daily coding that the JS is missing some definitions. It will take me a couple of days to get it all in order and then I'll put it on the wiki.

    Cheers.
     
  50. horsman

    horsman

    Joined:
    Jul 19, 2008
    Posts:
    156
    I'll get around to JS autocomplete this week.