Skip to content

Instantly share code, notes, and snippets.

@simongregory
Created August 16, 2012 10:30
Show Gist options
  • Save simongregory/3369128 to your computer and use it in GitHub Desktop.
Save simongregory/3369128 to your computer and use it in GitHub Desktop.
TextMate 2, rvm, and the ActionScript 3 bundle playing together

Get TextMate 2, the ActionScript 3 bundle and RVM playing together

For full completion functionality - where swcs are included when searching for the completions results - you need to have the 'nokogiri' and 'rubyzip' gems installed. The default ruby shipping on OS X is 1.8.7 so the easiest solution is to switch to the system default ruby and install the nokogiri and rubyzip gems there.

However the following should also work....

Assuming that

TextMate 2, rvm (with ruby 1.9.3 installed) and the AS3 bundle are installed on your machine and when you try to autocomplete an error gets thrown.

Setup

Create the gemset the ActionScript 3 bundle needs to be fully functional

rvm gemset create tmas3
rvm use 1.9.3@tmas3

Install the required gems

gem install rubyzip
gem install nokogiri

Create the rvm textmate wrapper

rvm wrapper 1.9.3@tmas3 textmate

Open TextMate preferences and set the var TM_RUBY to /Users/{YOUR_USER_NAME}/.rvm/bin/textmate_ruby

Restart TextMate and autocompletion should be working, if you suspect that swc's aren't being searched then ~/Library/Logs/TextMate ActionScript 3.log will confirm it.

@Siduzy
Copy link

Siduzy commented Sep 19, 2012

Hi~ I just did as above. But when I seleted a 'ClassName' and want to import it automatically(using Opt+Esc), a error occured (still):

Exception

private method `split' called for nil:NilClass

Location

/Users/zhangnaixiao/Library/Application Support/TextMate/Managed/Bundles/ActionScript 3.tmbundle/Support/lib/as3/parsers/property_inspector.rb:40:in `property_chain'
/Users/zhangnaixiao/Library/Application Support/TextMate/Managed/Bundles/ActionScript 3.tmbundle/Support/lib/as3/parsers/property_inspector.rb:187:in `capture'
/Users/zhangnaixiao/Library/Application Support/TextMate/Managed/Bundles/ActionScript 3.tmbundle/Support/bin/complete.rb:13

When I check the TextMate\ ActionScript\ 3.log, the file is empty. So what is the problem and how can i solve it?

@simongregory
Copy link
Author

Actually I'm still having trouble with TextMate 2 and RVM, I think I've narrowed down to the way a project is opened but haven't haven't had the time to write up a bug report. When I open a project using the mate tool on the command line, and TM isn't already open, then completion can still fail...

However your stack trace looks like it's related to another problem - the NilClass should be the value of ENV['TM_CURRENT_LINE'] which is set by TM. I've no idea why it isn't getting set, if you can supply a class/project I can reproduce the problem with then I'll try and take a look.

@Siduzy
Copy link

Siduzy commented Sep 20, 2012

The class I use is very simple.

package 
{
    // import flash.display.Sprite; 
    public class Main extends Sprite //When I press Shift+Cmd+I, no 'List' pop up
    {
        private var stg:Sprite;
        public function Main()
        {
        }

    }
}

And I also found that:

  • If the caret is after letter ‘e’ of ‘Sprite’, when I press Shift+Cmd+I, TM2 ask me to update TM Support from the [http://svn.textmate.org/trunk/Support] metioned in ‘Know Issuse’.
  • If I seleced the whole word ‘Sprite’ first(make the word HighLight), when I press Shift+Cmd+I, a error occurs...

and I try to track into the error but don’t konw where to begin...

So I just uninstalled TM2 and use TM Version 1.5.11 (1635). After I set the shell variables as blow, auto completion seems working fine(it can import default flex_sdk class).

PATH: /usr/bin:/bin:/usr/sbin:/sbin:/Users/zhangnaixiao/SDKs/flex_sdk_3/bin
TM_FLEX_PATH: /Users/zhangnaixiao/SDKs/flex_sdk_3
TM_FLEX_USE_FCSH: true
TM_AS3_USUAL_SRC_DIRS: /Users/zhangnaixiao/SDKs

Here is another question: Can I import other class which is in a common source folder(not in flex_sdk, with putting the folder into the project)?

@simongregory
Copy link
Author

Notes - Using the latest build of TM 2.0.0-alpha.9323 and RBenv, with Ruby 1.9.3 specified I'm getting DIALOG errors with the autocompletion system (once I've patched up all the old Ruby 1.8.7 failures) so it's looking like 1.9.3 is problematic.

@ZhangNaixiao thanks for the code example above, using it with TM 2.0.0-alpha.9323, OSX 10.8.2 and the system ruby 1.8.7, with both the master and tm2 branches of the ActionScript 3 bundle is ok for me. It's odd that you're seeing the problems with the old support folder so you might want to take a look at why TM was sourcing it as its unexpected.

Also, there isn't a way to include globally located source folders into the complier path via TM, for this I would use a compiler config file.

@simon-lucas
Copy link

Glad to see that you are trying to support AS3 in Textmate 2. I'd be lost without it. I at last took the plunge to upgrade to Yosemite (from Snow Leopard) at work and cannot get some functions in the Textmate/as3 bundle running.

I'm trying this on Yosemite. I have the latest TM. 2.0-beta.8.5. I have installed ruby 2.2.1. I have SDK 4.6 installed in a Developer/SDKs folder I created.

Autocomplete works, but using the Import library path function does not. Import causes two errors.

Shift-Cmd-I causes the document to be emptied of all content.
Selecting import directly from the AS3 menu causes a long error beginning 'ruby: warning: -K is specified; it is for 1.8 compatibility and may cause odd behaviour'

Is there a fix for this? The Import completion is one of my mainstays for coding AS3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment