Git Product home page Git Product logo

coffeescript-sublime-plugin's Introduction

Jump to Section

Installation

via Package Control

This is the recommended installation method.

If you have Sublime Package Control, you know what to do. If not, well: it's a package manager for Sublime Text 2; it's awesome and you can read about it here.

To install Package Control, open the Python Console (ctrl+' or cmd+` ) and paste the following into it:

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'

After installing the package and restarting the editor:

  • Open the Command Pallete (ctrl+shift+P or cmd+shift+P).
  • Type "Install Package" and hit return.
  • Type "CoffeeScript" and hit return.

via Source Control

If you plan to contribute, then you should install via this method. Otherwise it is recommended that you install the package via Package Control, see above.

Sublime stores packages in the following locations:

Nix: ~/.config/sublime-text-2/packages
Mac: ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
Win: %APPDATA%\Sublime Text 2\Packages

As a repository within the packages directory

Open a Terminal/Console and run the following commands, replacing PACKAGE_PATH with the path corresponding to your OS above.

cd PACKAGE_PATH
git clone https://github.com/Xavura/CoffeeScript-Sublime-Plugin.git CoffeeScript

As a repository outside of the packages directory

If you use Github for Mac/Windows which store repositories in a specific location, or if you just don't want a repository in your packages directory, then instead you can use a link.

If you don't yet have the repository, then grab it via your GUI program or via the command line:

cd WHEREVER_YOU_WANT
git clone https://github.com/Xavura/CoffeeScript-Sublime-Plugin.git

Once that is done, we will create the link:

Windows:

cd PACKAGE_PATH
mklink /D CoffeeScript ABSOLUTE_PATH_TO_REPOSITORY

Nix/Mac:

cd PACKAGE_PATH
ln -s ABSOLUTE_PATH_TO_REPOSITORY CoffeeScript

A note on Package Control

When Package Control tries to update your packages, if you have a repository in your packages directory then it will try to pull down and merge any changes. If you don't want this to happen and would rather handle everything yourself, then you can add the following to your settings (Preferences » Package Settings » Package Control » Settings - User):

"auto_upgrade_ignore": ["CoffeeScript"]

Updating

If you are using Package Control, updating will be automatic and you don't have to worry about it.

If using Source Control:

cd PACKAGE_PATH/CoffeeScript
git fetch origin
git merge origin/master

Commands/Shortcuts

You can access the commands either using the command palette (ctrl+shift+P or cmd+shift+P) or via shortcuts.

alt+shift+t - Run a Cake task
alt+shift+r - Run some CoffeeScript (puts/print is available for output)
alt+shift+s - Run a syntax check
alt+shift+c - Compile a file
alt+shift+d - Display compiled JavaScript
alt+shift+l - Display lexer tokens
alt+shift+n - Display parser nodes
alt+shift+w - Toggle watch mode
alt+shift+p - Toggle output panel

Note: Some of the commands use the Status Bar for output, so you'll probably want to enable it (Tools » Show Status Bar).

Snippets

  • Use TAB to run a snippet after typing the trigger.
  • Use TAB and shift+TAB to cycle forward/backward through fields.
  • Use ESC to exit snippet mode.

Snippet Triggers

Comprehension

Array:  forin
Object: forof
Range:  fori (inclusive)
Range:  forx (exclusive)

Statements

If:        if
Else:      el
If Else:   ifel
Else If:   elif
Switch:    swi
Ternary:   ter
Try Catch: try
Unless:    unl

Classes

Class - cla

Other

Function:      -
Function:      = (bound)
Interpolation: #

Building

When using the build system, it is assumed that your .sublime-project file lives in your project's base directory (due to limitations with the build system).

Hitting F7 (Tools » Build) will run the Cake task 'sbuild'.

If you're not quite sure what the point of this is then read on.

Let's say before distributing your project that you would like to combine all of your .js files into one and then minify them them using UglifyJS or something.

That's what this is for! You would create a Cakefile and inside it you would write a task:

task 'sbuild', 'Prepare project for distribution.', ->
	# ...

Examples coming soon.

coffeescript-sublime-plugin's People

Contributors

ashtuchkin avatar daquirm avatar johnogle222 avatar sustained avatar turtlepie avatar xavura avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coffeescript-sublime-plugin's Issues

Merge with "official" CoffeeScript Text Editor Plugin?

Hey Joe.

I switched over to Sublime a few months back, and have been greatly enjoying your CoffeeScript bundle -- fun stuff.

Over the last few days, I've been hacking on it a bit in an effort to get it to recognize the newly-merged "literate" CoffeeScript style. I was wondering if you'd like me to start maintaining the plugin officially, and publishing updates alongside the Textmate bundle ... or if you'd prefer me to send you a pull request here.

Whatever works best.

Unicode Decode Error

In one of my files I get the following error on command console when I try alt+shift+d:

Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./CoffeeScript.py", line 96, in run
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 20497: ordinal not in range(128)

The Code is :

tagxi.coffee

It compiles fine with alt+shift+c and the output is:

tagxi.js

What could be the problem here? Python is just a couple of hissSses for me :(

Trouble Compiling

I get this error when trying to Build. I'm not sure if building is equivalent to compiling for this plug-in. Does anyone have any suggestions?

/usr/local/lib/node_modules/coffee-script/lib/coffee-script/cake.js:111
throw new Error("Cakefile not found in " + (process.cwd()));
      ^
Error: Cakefile not found in /Users/robgordon/Music/Max/skewDrum
at cakefileDirectory (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/cake.js:111:11)
at cakefileDirectory (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/cake.js:109:14)
at cakefileDirectory (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/cake.js:109:14)
at cakefileDirectory (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/cake.js:109:14)
at cakefileDirectory (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/cake.js:109:14)
at cakefileDirectory (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/cake.js:109:14)
at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/cake.js:51:19)
at Object.<anonymous> (/usr/local/lib/node_modules/coffee-script/bin/cake:7:38)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
[Finished in 0.2s with exit code 1]

Installation steps incomplete

Good morning,

I just downloaded Sublime Text and pasted the contents of this script's installation commands into the `Cmd+`` window. Nothing happened though. If I try to close that window, it offers to save the file. How do I make it run? That step is not included in the readme.

Thanks!

Clone URL Incorrect

I think the clone URL in the README is for the read/write access. I got a "Public key denied" error when I used it. Replacing it with the HTTP URL worked.

None of the plugin commands work

I cannot get any of the commands for this plugin to work. Any time I try to do something like check syntax (Alt+Shift+S) nothing happens and I get this line in the status bar:
"Syntax env: node: No such file or directory"

I'm on OS X 10.8.1

I assumed this was a path problem, but the Sublime path and my system path match:

import os
os.environ["PATH"]
'/usr/local/mysql/bin:/usr/local/share/npm/bin:/Users/greg/.rvm/gems/ruby-1.9.3-p194/bin:/Users/greg/.rvm/gems/ruby-1.9.3-p194@global/bin:/Users/greg/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/greg/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/greg/.rvm/bin:$HOME/bin'

In the command line:

which node
/usr/local/bin/node

So 'node' should be on the path.

I had a similar problem with not being able to find 'coffee', but I was able to resolve that after finding 'binDir' in 'CoffeeScript.sublime-settings'. It defaults to '/usr/local/bin' while the directory 'coffee' is in is '/usr/local/share/npm/bin'.

I installed 'coffee' the recommended way:
npm install -g coffee-script

And I installed 'node' with:
brew install node

Watch Integration

File watching suport (coffee --watch).

  • Some way to start/stop the auto-compilation of code, specs etc.
  • Compilation errors reported via Sublime in some way.

Compile bug / cyrillic characters

I'm using this command to compile and output CoffeeScript in JS:
{ "keys": ["super+b"], "command": "compile_and_display", "args": {"opt": "-p"}}

If there is any cyrillic characters, it gives me blank output. Selective compiling without including cyrillic characters works just fine.

Fortunately, compile to .js file works sharp.

An expampe of cyrillic + western characters mixed code for testing:
http.createServer(app).listen(app.get('port'), -> console.log "Сайт доступен по адресу: http://localhost:#{app.get 'port'}")

Check syntax does not work on Sublime3, Ubuntu

Hi, I've got a problem with syntax check, syntax highlighting is Okay. When I try to syntax-check with Alt-shift-s, here is the Sublime Console output :

Traceback (most recent call last):
File "/opt/sublime_text_3/sublime_plugin.py", line 549, in run_
return self.run(edit)
File "CoffeeScript in /home/slash4/.config/sublime-text-3/Installed >Packages/CoffeeScript.sublime-package", line 105, in run
File "CoffeeScript in /home/slash4/.config/sublime-text-3/Installed >Packages/CoffeeScript.sublime-package", line 32, in brew
File "CoffeeScript in /home/slash4/.config/sublime-text-3/Installed >Packages/CoffeeScript.sublime-package", line 22, in run
File "X/subprocess.py", line 818, in init
File "X/subprocess.py", line 1344, in _execute_child
File "X/subprocess.py", line 1344, in
File "X/os.py", line 800, in fsencode
TypeError: expect bytes or str, not NoneType

Thanks for this wonderfull plugin :)

compile region

Hi..I'm not sure if it is possible inside sublime or if it's implemented yet...but is possible compile only a region or selection of code?..in emacs is possible but I'm newbie with sublime and I'm not sure how do it...

Can't view compiled code?

Sorry, I'm new to Sublime and plugins.
If I super+shift+p, Coffee: Compile File
literally nothing happens. Or at least nothing is indicated to me. I'm running sublime version 2.0.1 build 2217

string interpolation highlight

Hi there
Thks for the package its really cool
Just one little problem I don't get string interpolation highlight

I have no idea if this because of my color scheme config or is it something that can be fixed in the plugin ?

Broken in 2217

I'm not sure if this is a Sublime 2217 issue or if it's this package. But it doesn't work in 2217. Is anyone else having this problem?

Recently started seeing this bug

I'm not sure whats going on. Everytime I try to compile a snippet or coffeescript file I see the error below (shows up in the console).

Only change I made is I started using NVM to manage my node versions. Any help?

 Traceback (most recent call last):
  File "./sublime_plugin.py", line 362, in run_
  File "./CoffeeScript.py", line 105, in run
  File "./CoffeeScript.py", line 32, in brew
  File "./CoffeeScript.py", line 22, in run
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 623, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1141, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

OS X Terminal

In the old Tomorrow theme there was a .terminal file for OS X's built in Terminal.app. Is there a way to use any of the included files in Terminal.app?

Different compile result through command line

I could just be doing something incorrectly but when I run the Coffee: Compile File command through the Command Palette I get a different result than if I run it through command line.

EXAMPLE: Command Line 'coffee -c example.coffee'

(function() {
  var cube, square;

  square = function(x) {
    return x * x;
  };

  cube = function(x) {
    return square(x) * x;
  };

}).call(this);

EXAMPLE: Command Palette > Coffee Compile File

var cube, square;
square = function(x) {
  return x \* x;
};
cube = function(x) {
  return square(x) \* x;
};

Installation fails on Sublime Text 3, build 3059

Inside console, suggested command line for installation is currently throwing the following:

>>> import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
  File "<string>", line 1
    import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
                                                                                                                                                                                                                                                                                                                                                                                                            ^
SyntaxError: invalid syntax

I don't know how to fix it, can anyone help?

'Display JavaScript' command doesn't work with non-ASCII characters

Valid CoffeeScript won't compile using the 'Display JavaScript' command if there are Japanese or other non-ASCII characters in the file. Instead an error is logged and blank window appears.

This code compiles and displays fine:

foo = "It works with ASCII text."

But, if you add some non-ASCII to the mix, like this, it doesn't work anymore:

foo = "It works with ASCII text."
bar = "日本語だったらダメだ。"

The error printed to console is:

Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./CoffeeScript.py", line 88, in run
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 58: ordinal not in range(128)

The version I am using is the current one from Package Control: v2012.07.19.12.47.26; xavura.github.com/CofffeeScript-Sublime-Plugin

Support for litcoffee?

CoffeeScript 1.5 introduced literate CoffeeScript. I was wondering if there's any plan of implementing it. So far it works well without any change, except for the use of ' inside a block of text, which screws up the formatting of everything below because the highlighter interpreted it as the start of a string.

Build Broken in Sublime Text Version 2.0.1 Build 2217

Attempts to build any Coffeescript file using the Sublime Text build system results in the following error:

/usr/local/lib/node_modules/coffee-script/lib/cake.js:38
        throw new Error("Cakefile not found in " + (process.cwd()));
              ^
Error: Cakefile not found in <my_directory>/<my_coffeescript_file>
    at /usr/local/lib/node_modules/coffee-script/lib/cake.js:38:15
    at path.js:292:19
[Finished in 0.4s with exit code 1]

HTML templating of JSX inside Coffee-script backticks

Hi!

First of all-- this is not a feature that should be added to this project. I'm just hoping for some input from you guys.

  1. is there any way to convert the XML .tmLanguage structure back to a .JSON-tmLanguage? None of the tutorials I've found deal with straight xml.
  2. Per this issue: facebook/react#47 I am writing coffeescript with facebook React JSX. The JSX is inside backticks so that it is templated nicely into JSX which is then compiled into JS. I'd like to be able to use sublime's HTML templating inside any coffeescript backticks.

How would I do that? Is this even possible? Can language packages reference other packages? I'll be making my own branch of this project, but I'm curious for all your input.

Sorry for the noob questions! I'll close this issue in 48 hours.

On Debian binDir must contain /usr/bin and /usr/local/bin

On Debian Testing+Sid, when I try, for example, check the syntax (Alt+Shift+S), or invoke any other action of this plugin, an error occurs (showed in the new tab or status bar):
/usr/bin/env: node: No such file or directory
This happens with the default settings.

When I correct binDir value to /usr/bin, it just silently fails.

Accidentally discovered that the variable PATH (in terminal) contains /usr/bin and /usr/local/bin, so I tried to set binDir value to /usr/local/bin:/usr/bin … and it worked!

Further investigation revealed that this happens because node is in /usr/bin, but coffee in /usr/local/bin.

Also tried on Ubuntu 12.04 and there is the same situation.

So I thought it's would be nice if plugin use /usr/local/bin:/usr/bin as a default value for binDir.

PS. I'm sorry for my google-translated English. :)

run() smashes PATH

CoffeeScript.py#run() overwrites the PATH environment variable. I can specify binDir in my ST2 settings, but if I've already got my environment set correctly, this overwrites it. Note that if I don't specify binDir that the PATH is set to /usr/local/bin.

Mac Keyboard shadows characters

Using the "alt" key on the Mac keyboard interferes with the usage of "alt" (with and without "shift") to produce other characters. This is especially difficult because the keymap is not restricted to coding in CoffeeScript, but also seems to be active in other modes.

In general, the only way to avoid this problem is to avoid "alt" as a modifier unless accompanied by "ctrl" or "super", as almost all keys produce some special character when modified by "alt".

parentheses in default argument values breaks syntax highlighting

When parentheses are used in the expression for the value of a default argument of a function, it breaks highlighting for its function's argument list. It's easier to understand with an example:

func = (arg1, arg2 = 'item(s)') ->

Here's how it looks:

image

Here are some similar examples of how it should look:

image

Here are some other examples of it being broken:

image

conflict with c language

Recently, when I use Ctrl-R to list functions in c code, It shows some mess.
After I uninstalled CoffeeScript plugin, It shows good.
Could you check this issue?

I try it in both Windows and Linux(Ubuntu)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.