aponxi / sublime-better-coffeescript Goto Github PK
View Code? Open in Web Editor NEWSyntax highlighting and checking, commands, shortcuts, snippets, watched compilation and more.
Home Page: http://aponxi.github.com/sublime-better-coffeescript/
Syntax highlighting and checking, commands, shortcuts, snippets, watched compilation and more.
Home Page: http://aponxi.github.com/sublime-better-coffeescript/
Okay, so I've organized my project as follows:
/projectroot/coffee
/projectroot/js
I want the coffee-script in 'coffee' to compile into 'js'. I set my compileDir to '../js/' since that should be the relative path from my coffee-script directory. However, whenever I try to compile, it doesn't save to 'js'. If I just set compileDir to 'true' it'll compile in 'coffee' just fine.
I hope I'm being stupid and just forgetting something. Any thoughts?
Maybe this is linked to issue #23
After closing the tab that shows the watched, compiled js; we still get "Refreshed" message in the console when we change something then save it.
IIRC this is for refreshing the output if there was a change done. Either we are cluttering the console with false "Refreshed" output, OR we are actually compiling but not displaying anything, thus cluttering the memory.
I am running OSX 10.8.2, Sublime Text 2.0.1, sublime-better-coffeescript v2013.01.26.20.45.16, which I installed with Package Control. I tried the following in a file named script.coffee
:
-> "Hello World"
and I obtained:
env: node: No such file or directory
My coffee
executable is located at /usr/local/share/npm/bin
, the global location for npm
when node
is installed with brew
, so I set "binDir": "/usr/local/share/npm/bin"
in the settings.
My node
executable is located in /usr/local/bin
, but I can't set that, and I think /usr/local/bin
is already in my Sublime Text 2 path.
Pressing Option+Shift+C yields Compilation failed
in the status bar.
If I run the file with Command+Shift+B, I obtain:
[Errno 2] No such file or directory
[cmd: [u'coffee', u'/Users/alex/Media/GitHub/sc6-telemetry-code/tel/script.coffee']]
[dir: /Users/alex/Media/GitHub/sc6-telemetry-code/tel]
[path: /usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
[Finished]
And of course Command+B yields:
[Errno 2] No such file or directory
[cmd: [u'cake', u'sbuild']]
[dir: /Users/alex/Media/GitHub/sc6-telemetry-code/tel]
[path: /usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
[Finished]
I don't want to make a Cakefile. I should be able to compile a single source.coffee
file into something like source.js
.
This package nearly completely breaks goto symbol for C/C++. It causes sublime to use the entire function definition, rather than just the function name. This issue occurs in both Sublime text 2 & 3, and I have verified that it goes away as soon as this package is removed, and comes back when it is reinstalled.
ReferenceError: marked is not defined
at Object. (.:4:3)
at Object. (.:78:4)
at Module._compile (module.js:449:26)
at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:83:25)
at compileScript (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:177:29)
at Socket.compileStdio (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:215:14)
at Socket.EventEmitter.emit (events.js:93:17)
at Pipe.onread (net.js:417:51)
I wanna see that.
We have just moved to the Sublime Text 3 by default (master) branch. Test things out a bit.
Thank you.
Have the results shown too, by a command.
Tip: take --print
arg off the coffee
command
Essentially, I have a build tool (Grunt) that does all my CoffeeScript compilation, so I don't actually need to have Better CoffeeScript doing the file compilation for me, however I would like to be able to "preview" the output in a window for inspection (much like CoffeeCompile does).
Is this kind of workflow available with Better CoffeeScript?
I experience a little lag when writing comments like # something something
Maybe increase the delay to a second?
Also saving when refreshing or after a refresh (couldn't tell) sent a message that said the plugin may be unresponsive. Check out saving delays (i forgot how I wrote the method), if there isn't one put one.
When working with a large Coffee Script, when you make changes on the bottom of the document, most likely you would want to view that portion of the compiled JS on the output.
Display javascript in the st3 branch gives you this error in console, dont know what to do about it :/
Thanks for making this project!
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 543, in run_
return self.run(edit, **args)
File "/Users/andreas/Library/Application Support/Sublime Text 3/Packages/Better CoffeeScript/CoffeeScript.py", line 133, in run
res = brew(args, Text.get(self.view))
File "/Users/andreas/Library/Application Support/Sublime Text 3/Packages/Better CoffeeScript/CoffeeScript.py", line 42, in brew
return run("coffee", args=args, source=source.encode('utf-8'))
File "/Users/andreas/Library/Application Support/Sublime Text 3/Packages/Better CoffeeScript/CoffeeScript.py", line 31, in run
proc = Popen(command, env=env, cwd=cwd, stdout=PIPE, stderr=PIPE)
File "X/subprocess.py", line 818, in __init__
File "X/subprocess.py", line 1344, in _execute_child
File "X/subprocess.py", line 1344, in <listcomp>
File "X/os.py", line 800, in fsencode
TypeError: expect bytes or str, not NoneType
The wiki pages are a mess, not to mention the outdated Readme... Fix those.
Investigate if that is really necessary. I know at some point I have added that for future expansion purposes... I don't think it is useful at all to have it lying there.
Add utf-8 encode/decode to prevent unicode decode errors. these occur when you have a symbol in the coffeescript and try to compile it.
Support for Iced Coffee.
Out of all the js pre-processors, I chose https://github.com/maxtaco/coffee-script.
currently I want to convert coffeescript to javascript ,and output the js file to some directory
I submit an issue to sublimetext ,
[question about relative path [sublime-build]]
http://www.sublimetext.com/forum/viewtopic.php?f=3&t=12670
I am not sure if sublime-better-coffeescript support it , if it support , I will use the plugin , output js file to some directory in one command
Attributes and methods of a class are different,
I think it's better to highlight the @
to make it striking.
Would be nice with support for sublime text 3.0 for the context menus and keyboard shortcuts.
I don't know if I am doing something wrong but I can't get the indentation to work correctly.
When I use the reindent command it never deindent any lines and when I tries to create a list of objects the autoindent always adds a new indentation level.
Does the indentation works for anyone else or am I doing something wrong?
class Demo
constructor: ->
alert("Foo")
example: (data) ->
alert("Bar")
for row in array
alert("Baz")
@settings = [{test: 'a'},{
test: 'b'
}, {
test: 'c'
}, {
test: 'd'
}]
after Ctrl+Shift+P, "Reindent lines" it looks like this
class Demo
constructor: ->
alert("Foo")
example: (data) ->
alert("Bar")
for row in array
alert("Baz")
@settings = [{test: 'a'},{
test: 'b'
}, {
test: 'c'
}, {
test: 'd'
}]
I am running a new Linux Mint 14 Nadia and my Sublime Text is version version 2.0.1, build 2217. I installed the package using the Package Control tool.
The installed coffeescript version is 1.6.1
When pressing enter after while
, for
and if
, the new line is indented one extra step automatically. However, that's not the case with else
. I would like the same behavior there! (But not when else
is followed by something on the same line, just like it works for if condition then doThat()
).
by default it compiles either the whole coffee file or the selection. However when you select somestring
and hit {
to put brackets around it or something; as it puts brackets around it and then selects {somestring}
, it compiles that and outputs it.
Maybe disable selection compiling completely? We could use the "compile" command to compile a selection... To do this we must first close #3 so that "compile" command uses the same output view as the watch mode.
when you close the coffeescript, close the compiled output that belongs to that coffee script.
After installing the plugin there is this error at ST2 startup.
Error trying to parse settings: No data in ~/.config/sublime-text-2/Packages/User/CoffeeScript.sublime-settings:1:1
can be solved by puttin []
in CoffeeScript.sublime-settings.
When you use alt+shift+d
you compile to a different output each time. Make it be the same one.
Hi. It seems that plugin is not working as it should with default setting. It must generate js file on compile in current dir. Have solution:
replace CoffeeScript.py line 84:
args = ['-c', self.view.file_name()]
with
args = ['-c', os.path.split(self.view.file_name())[1]]
windows 7 x86, [email protected], sublime text 2.01.2217, sublime-better-coffeescript version 0.6.31 (2013-01-26)
Hi. Would you like to change current model of relativeDir setting to next scheme:
"compileDir": false, // if compiled file's path not exist in compilePaths then use this rule
"compilePaths": {
"/app1/coffee": "/app1/js", // compile from /app1/coffee to /app1/js
"/app2/coffee": "../js", // compile form /app2/coffee to /app2/js
"/app3/coffee": "/app1/js/app3-js" // compile from /app/3/coffee to /app1/js/app3-js
}
Love the plugin! But on one of my machines, I can't seem to get the toggle watch mode to turn off. It keep generating JS files, which end up taking precedence in my rails asset pipeline :/
Here is the log output.
startup, version: 2217 osx x64 channel: stable
executable: /Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2
working dir: /
packages path: /Users/kempair3/Library/Application Support/Sublime Text 2/Packages
settings path: /Users/kempair3/Library/Application Support/Sublime Text 2/Settings
PackageSetup not required
catalogue loaded
found 7 files for base name Default.sublime-keymap
found 1 files for base name Default.sublime-mousemap
found 4 files for base name Main.sublime-menu
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/BracketHighlighter/BracketHighlighter.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/BracketHighlighter/Elements.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/BracketHighlighter/bracket_plugin.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/CSS/css_completions.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/comment.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/copy_path.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/delete_word.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/detect_indentation.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/duplicate_line.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/echo.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/exec.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/fold.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/font.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/goto_line.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/indentation.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/kill_ring.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/mark.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/new_templates.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/open_file_settings.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/open_in_browser.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/paragraph.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/save_on_focus_lost.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/scroll.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/set_unsaved_view_name.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/side_bar.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/sort.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/swap_line.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/switch_file.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/transform.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/transpose.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Default/trim_trailing_white_space.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Diff/diff.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/HTML/encode_html_entities.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/HTML/html_completions.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/JS2Coffee/JS2Coffee.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/Package Control/Package Control.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/SCSS/scss_completions.py
Reloading plugin /Users/kempair3/Library/Application Support/Sublime Text 2/Packages/sublime-better-coffeescript/CoffeeScript.py
plugin init time: 0.137
loading bindings
loading pointer bindings
found 1 files for base name Default.sublime-theme
theme loaded
app ready
pre session restore time: 0.273326
using gamma: 1 (err: 0)
wrote startup cache, added files: 7 orphaned files: 0 total files: 106 cache hits: 99
startup time: 0.409295 (package setup was not run)
loaded 1112 snippets
Package Control: No updated packages
Writing file /Users/kempair3/GitHub/HumanCloud/app/views/dashboard/templates/angular/_hiiro_profile_shared.haml with encoding UTF-8
Writing file /Users/kempair3/GitHub/HumanCloud/app/views/dashboard/templates/angular/_hiiro_profile_shared.haml with encoding UTF-8
Compiling on save...
Writing file /Users/kempair3/GitHub/HumanCloud/app/views/dashboard/templates/angular/_hiiro_profile_shared.haml with encoding UTF-8
Writing file /Users/kempair3/GitHub/HumanCloud/app/views/dashboard/templates/angular/_hiiro_profile_shared.haml with encoding UTF-8
Writing file /Users/kempair3/GitHub/HumanCloud/app/views/dashboard/templates/angular/_hiiro_profile_shared.haml with encoding UTF-8
Writing file /Users/kempair3/GitHub/HumanCloud/app/views/dashboard/templates/angular/_hiiro_profile_shared.haml with encoding UTF-8
Writing file /Users/kempair3/GitHub/HumanCloud/app/views/dashboard/templates/angular/_hiiro_template_scoped_add_to_collection.haml with encoding UTF-8
Writing file /Users/kempair3/GitHub/HumanCloud/app/views/dashboard/templates/angular/_hiiro_profile_shared.haml with encoding UTF-8
Writing file /Users/kempair3/GitHub/HumanCloud/app/views/dashboard/templates/angular/_hiiro_template_scoped_add_to_collection.haml with encoding UTF-8
Compiling on save...
Writing file /Users/kempair3/GitHub/HumanCloud/app/views/dashboard/templates/angular/_hiiro_template_scoped_add_to_collection.haml with encoding UTF-8
Compiling on save...
Writing file /Users/kempair3/GitHub/HumanCloud/app/assets/javascripts/angular/directives/scoped_add_to_collection.js.coffee with encoding UTF-8
Compiling on save...
Also, a quick image of my other plugins, in case there is some conflict.
At first, I thought I was leaving the 'watch mode' on. But when I go to 'toggle it', it actually turns it on. Also, and deleted the JS files and then closed sublime and re-opened it, and upon opening the coffee files, the JS files appear again.
I have also confirmed that it's this plugin, because the issue immediately disappears upon uninstallation.
Hope that helps! Keep up the great work.
shouldn't the interpolated part be highlighted as well?
What do you think about add better lint support?
Tools:
coffee -l
coffeelint
Also I think it is possible to add jshint support (with back to coffee report).
I am trying to install with package controll but it didn't work. it says it was successful, but it was not
so currently I want to use sublime-better-coffeescript format coffeescript code , so does it support?
Finally branch out from CoffeeScript.
Name files as Better_CoffeeScript
please add snippet to console.log with tab trigger
something like con should expand to console.log '$1: ', $2
Literate CoffeeScript would benefit from better syntax highlighting: http://coffeescript.org/#literate
You might know that @
(at) is a shorthand for this
in CoffeeScript. It doesn't get highlighted in Sublime Text 2.0.2, SBC 0.7.0.
Also, you might want to make sure that @
can be highlighted without anything after it (i.e. highlight both @
and @foo
).
I have added ability to automatically compile all .coffee files on save. It would be nice if you could add this. I dont speak python, so I have no idea if this code is right - although it works and helps me a lot!
In package settings:
{ "compileOnSave": true }
In code, prepend to beggining of on_post_save:
def on_post_save ( self, view):
compileOnSave = settings.get('compileOnSave', False)
import os.path
ext = os.path.splitext(view.file_name())[1]
if compileOnSave and ext=='.coffee':
args = ['-c', view.file_name()]
no_wrapper = settings.get('noWrapper', True)
if no_wrapper:
args = ['-b'] + args
result = run("coffee", args=args)
if result['okay'] is True:
status = 'Coffee Succeeded '+view.file_name()
else:
status = 'Coffee FAILED: '+result['err'].splitlines()[0]
later = lambda: sublime.status_message(status); print status
sublime.set_timeout(later, 300)
# ..rest of the code..
Btw, you may also want to add " +result['err'].splitlines()[0] " to status message after compilation in CompileCommand fails, so that people can instantly see what's wrong.
It whould be very handy to allow users setting the --output and --compiler options of the coffee-script compiler.
Currently, the compiled js file is generated in the coffee file parent folder.
Having a src/ folder for coffee script and a lib/ folder for compiled js is a common project layout.
Thanks a lot !
I know this is not something directly related with this package but anyway I'm new to Sublime Text so any help will be great. Looks like the app can't locate to the correct dir to run the command and it probably should be fixed through the Environment Variables. I just don't know what location should I point to?
Looking for coffee.bat or .exe and can't find one.
Windows 7
Sublime Text 2
Coffeescript -> should be CoffeeScript
First, thanks for all your hard work on this - both a timesaver and also learning tool.
Second, how hard would it be to port it over to TypeScript? Would you be able to give me some pointers on how to get started?
When you want to refresh Compiled JS each time you modify the CoffeeScript, it slows down Sublime Text 2 and might even freeze it.
Added a delay for modified, however the method can be improved.
When dealing with more than one watched coffeescripts its hard to see which one is which ones output. Make the tab names something like "This script's output"
The option for compile_output_on_save works for now, but I want it to be smarter. I want it to update the panel when the panel is seen, if it's hidden it shouldn't spend any precious cpu to update it.
Is there any way to create custom preferences inside the .sublime-project settings object?
I would like something like that:
{
"folders":
[
{
"path": "/Users/etc...",
"folder_exclude_patterns": [ "node_modules" ]
}
],
"settings":
{
"sublime-better-coffeescript":
{
"compileOnSave": false
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.