jashkenas / coffee-script-tmbundle Goto Github PK
View Code? Open in Web Editor NEWA TextMate Bundle for CoffeeScript
License: MIT License
A TextMate Bundle for CoffeeScript
License: MIT License
It would be nice if escape sequences could be highlighted in regular expression literals, just as in the JavaScript and Ruby bundles. For example:
a = /\t/
In the above code, both the JavaScript and Ruby bundles highlight "\t" with a slightly brighter green than the rest of the regular expression literal.
IcedCoffeeScript is an extension of CoffeeScript, with two new keywords (await
and defer
) that look just like function calls. So the syntax highlighting for CoffeeScript is fine for IcedCoffeeScript as well.
Therefore, it would be nice if coffee-script-tmbundle recognized .iced
as an extension that should be treated as CoffeeScript.
It would be helpful if super
was highlighted when defining classes (unless it already is and I just have an old version). http://coffeescript.org/#classes
Thanks!
I added to my coffee script bundle a new command which runs CoffeeLint for making sure my coffee script is nice and clean
#!/bin/bash
coffeelint "$TM_FILEPATH" | ansifilter -H;
AnsiFilter i found on homebrew and i converts shell outputs
http://www.coffeelint.org/
http://www.andre-simon.de/doku/ansifilter/en/ansifilter.html
I suppose someone can figure out if adding this into this bundle is a good thing or not... I just wanted to show other people what i have setup
There is no such thing as an Application dir in any Linux distro. Please don't state "tested in Ubuntu 11.04" if you didn't.
E.G: in Ubuntu 11.10, the bundle can be copied, without bein zipped, directly in .config/sublime-text-2/Packages
Say the object obj
has the property return
. (Hey, I didn't choose it.) Then the line
obj.return = 1
compiles just fine, but the word return
is highlighted like a keyword. Likewise for any other keyword. Obviously one could type obj['return'], but it would be nice to have accurate highlighting for the dot syntax.
I'm an inexperienced TextMate user, so be nice. ;)
With Check Spelling While Typing enabled, spelling mistakes in string literals are underlined but those in comments are not. According to the 4.10 Spell Checking…
By default spell checking is disabled for source code except strings and comments
Any idea as to how I'd go about having spell-checking apply to comments as well as strings? ack spell
returns no results – it would appear that the spellChecking
preference mentioned in the TextMate documentation is not being specified. Why then, I wonder, does the behaviour differ from the (quoted) default?
Seems like the increaseIndentPattern should have an entry for -> so that function bodies get indented correctly
These three snippets lack a UUID which prevents them from being loaded in TextMate. Didn't do a pull request as I am unsure of their purpose and where they would fit in the menu structure. (You can generate a UUID with uuidgen
in terminal.)
It would appear that this change in CoffeeScript assignment operators:
"0.9.0 introduces a massive backwards-incompatible change: Assignment now uses =, and object literals use :, as in JavaScript."
It hasn't bubbled back into the TextMate bundle snippets.
Just a heads-up, it's a small change to the following snippets:
Function, Class, Require
and the following Commands:
New Function
I believe that's it, thanks!
-Kris
I don't know if this is the right place to do this. The TM2 bundle repository doesn't have an issue tracker attached to it.
From Bartłomiej Kubiak on the Textmate mailing list:
CoffeeScript bundle has broken syntax highlighting
when using division operator ("/") - badly interprets it
as start of regexp…
This might be the culprit.
if you name a variable something like:
formData = 1
# gets indented after newline
When you hit enter, it will automatically indent even though its not a for loop.
Compiling a coffee script file with TextMate (Compile and Display JS) gives a different result compared to compiling with coffee on the command line. This happens if I insert raw javascript with backticks and the javascript code is invalid. For example:
<% if @autoload %>
The above will be compiled into an empty expression ending with a semicolon.
Using the option key in combination with the arrow keys moves the cursor to word boundaries, where a boundary is any one in the set of word separators for a language. In the tm bundles for most other languages, the period is treated as a word separator. This is not the case in the current implementation of coffee-script-tmbundle.
Currently all the indentation in snippets is hardcoded to two spaces. If you change from using spaces to tabs in the snippets then you configure how large you want the indentation to be using soft tabs. The previous behaviour is available if you set Tab Size: 2 and Soft Tabs. If you want to indent 4 spaces instead you can set Tab Size: 4 and Soft Tabs.
Here's a minor syntax highlighting glitch:
foo: bar
highlights foo
differently than
foo : bar
Relately, foo= bar
highlights foo
differently than foo = bar
.
Coffee script seems to work OK in the terminal
coffee -v #=> CoffeeScript version 1.1.1
npm -v # => 1.0.6
node -v # => v0.4.8
When I try to compile to JS in TextMate I get this error:
module:238
throw new Error("Cannot find module '" + request + "'");
^
Error: Cannot find module 'vm'
at loadModule (module:238:15)
at require (module:364:12)
at Object. (/usr/local/lib/coffee-script/lib/coffee-script.js:5:8)
at Object. (/usr/local/lib/coffee-script/lib/coffee-script.js:110:4)
at Module._compile (module:384:23)
at Module._loadScriptSync (module:393:8)
at Module.loadSync (module:296:10)
at loadModule (module:241:16)
at require (module:364:12)
at Object. (/usr/local/lib/coffee-script/lib/command.js:7:18)
TextMate Shell variables:
http://cl.ly/1Y2o2W3n3V2M3U0H183I
Paths:
Currently,
class Foo.Bar
highlights Foo
as a class name, but not Bar
. I believe the most correct behavior would be for the entire string, Foo.Bar
, to be highlighted. Or, perhaps just Bar
should be highlighted, since that's the name given to the constructor function.
Note that the entire string Foo.Bar
is highlighted in
new Foo.Bar
Extra bonus bug: While reporting the bug above, I discovered that single-char class names aren't highlighted at all. So class A.B
doesn't highlight A
, while class AA.B
does highlight AA
.
This is a enhancement request for string interpolation expressions (not sure if it's the correct name). Basically I would like the string interpolation expressions behave like they do in the Ruby bundle.
The only bad part about Coffee Script is that it reports it's errors as line numbers in the compiled result.
Is there anyway the Compile and Display JS window could show line numbers? (or even paste itself into a new TextMate document) This way it would be easier to see where the error occurred in the compiled JS from a stack trace.
Would be nice for the coffeescript language to be detected when being used inline with HTML:
<script type="text/coffeescript">
Clicking the arrow to collapse text is a no-op in TM2 (build 8971).
foo = (bar = false) ->
"false" is not highlighted in the above example.
I installed the tmbundle following the commands and I can successfully reload the bundles, however, why I don't see the change of syntax highlighting? How do I make syntax highlighting work?
On most setups (all?), coffee script uses soft tabs (just like Ruby). I couldn't manage to enable soft tabs in this bundle, setting environment variables in the bundle's config didn't work:
{ name = 'TM_SOFT_TABS';
value = 'YES';
},
{ name = 'TM_TAB_SIZE';
value = '2';
},
Folding doesn't work on coffeescript functions, only on code that looks like javascript. I changed my folding markers as follows, and while it no longer folds on {}'s (which I prefer anyway) it works properly for functions...
foldingStartMarker = '.*(->|=>)\s*$';
foldingStopMarker = '^\s*$';
by adding the following to README.markdown:
osascript -e 'tell app "TextMate" to reload bundles'
Thanks!
The line
str.replace(/\\/g, '')
is perfectly valid CoffeeScript, removing all backslashes from a string. However, the regex /\\/
doesn't get highlighted. Worse, if there's a slash later on the line, then regex highlighting goes all the way up to it, e.g.
str.replace(/\\/g, '\\\\').replace(/\\"/g, '"')
highlights
/\\/g, '\\\\').replace(/
In short, the syntax highlighter isn't currently distinguishing between a single backslash (which escapes the closing /
of a regex) and a double backslash (which doesn't). More precisely, it needs to ignore any even number of backslashes preceding the closing \
, since the current behavior is correct for a regex like
/\\\/foo/
At least one TextMate command ('Continue Line Comment') relies on the scope specifying the character used to start a line comment. The coffeescript grammar is currently not following that convention.
It's a quick fix (change 2 occurrences of comment.line.coffee to comment.line.number-sign.coffee) that I have ready. I'll merge it asap.
A few minor things:
#
inside of a """
string, it should auto-expand to #{_}
the same way that it does inside of a "
string."""\n_\n"""
, why not make Cmd+' generate '''\n_\n'''
? The shortcuts could be labeled "Generate Heredoc Quotes (double)" and "Generate Heredoc Quotes (single)." Typing heredoc strings without a shortcut in TextMate is a bit nasty, because three '
keypresses result in '''_'
...###
, it ought to expand to ###_###
, don't you think? Or perhaps ###\n_\n###
as with the heredoc quote keyboard shortcut mentioned above.Hello, I am wondering if this is possible or am I doing something wrong?
the following code:
Mustache = require 'mustache'
person =
name : "john"
email: "[email protected]"
template = """
<p>Hello {{name}}</p>
<p>your email is: {{email}}</p>
"""
output = Mustache.to_html template, person
console.log output
works fine when using cat test.coffee | coffee -s
through terminal, but if running with cmd+b the Run command within textmate it returns:
Error: Cannot find module 'mustache' at Function._resolveFilename (module.js:289:11) at Function._load (module.js:241:25) at require (module.js:317:19) at Object. (.:3:14) at Object. (.:11:4) at Module._compile (module.js:373:26) at Object.run (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19) at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:115:29 at Socket. (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:149:14) at Socket.emit (events.js:39:17)
Is there any way to use require modules using textmate bundle?
It seems require 'sys'
is possible though...
I added
|^\s*class\s.*$
to foldingStartMarker. I'm not sure if it covers all cases, but it's better than nothing. At least it my classes fold. ^_^
This code in textmate:
sys: require 'sys'
http: require 'http'
server: http.createServer (req,res) ->
res.writeHeader 200, {'Content-Type':'text/plain'}
res.write 'Hello, World!'
res.end()
server.listen 3000
sys.puts "Server running at http://localhost:3000/"
Produces this:
({
sys: require('sys'),
http: require('http'),
server: http.createServer(function(req, res) {
res.writeHeader(200, {
'Content-Type': 'text/plain'
});
res.write('Hello, World!');
return res.end();
})
});
server.listen(3000);
sys.puts("Server running at http://localhost:3000/");
Which as expected doesn't work:
ReferenceError: http is not defined
Changing to equals fixes it:
sys = require 'sys'
http = require 'http'
server = http.createServer (req,res) -> ...
I'm trying to recreate TextMate's Support/lib/ui.rb's #menu helper which calls out to the tm_dialog cocoa app, but my attempt is hanging textmate. I don't know NodeJS well enough to know if I'm calling out correctly (see "Show menu (demo).tmCommand" in my fork, but reproduced below too).
My attempt (which hangs TM):
dialog: process.createChildProcess dialog_cmd, ["-u"]
dialog.addListener "exit", (code) ->
dialog.close()
dialog.addListener "output", (data) ->
res: data.strip()
Ruby's version:
res = ::IO.popen("#{TM_DIALOG} -u", "r+") do |io|
Thread.new do
plist = { 'menuItems' => options }.to_plist
io.write plist; io.close_write
end
OSX::PropertyList::load(io)
end
It includes the RubyCocoa call OSX::PropertyList::load(io)
which I cannot find in the Xcode docco :/
Any thoughts on how I can reproduce the Ruby call in CoffeeScript/NodeJS?
I "test" my command by opening it into TextMate (Ctrl+Cmd+E, and pressing Cmd+R; that hangs TM. Also activating the command hangs TM).
Related to #99: When I'm editing an IcedCoffeeScript file (.iced
extension), it would be nice if await
and defer
were highlighted as keywords (or in some way had a different color from ordinary identifiers).
In plain old CoffeeScript (.coffee
), await
and defer
are just ordinary identifiers. So it might make sense (if it's easy to do so -- I know very little about authoring TextMate bundles) to only highlight the extra keywords if the filename is .iced
. Then again, IcedCoffeeScript can run plain old .coffee
files too (and runs them as IcedCoffeeScript, await
/defer
and all), so it's debatable whether it should be extension-sensitive.
Add this line at the end to do so:
osascript -e 'tell app "TextMate" to reload bundles'
Hitting apple-B to compile& show a coffeescript file fails if it contains a string constant with a unicode character such as "ẚ".
For instance, if the entire file is:
'ẚ'
Hitting apple-b will fail, saying
*** Error while highlighting: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 1: ordinal not in range(128) (file "/Library/Python/2.6/site-packages/Pygments-1.4-py2.6.egg/pygments/lexer.py", line 148, in get_tokens)
According to rtomayko/rocco#10 if you add "-O encoding=utf8" to the call of pygmentize it resolves this issue.
Hello!
Well, the title tells everything.
Have a nice day! :)
Loupi
I'm not getting proper highlighting of anything after the "@something" in "class @something extends SomethingElse"
I'm not using TextMate; I'm using SublimeText, which is compatible with tmLanguage files, just so you know.
Looks like the colorization was been removed? I checked the issues and did not see anything regarding this.
For some reason, the line
a /= 255
is colored incorrectly, as are lines that follow. The _=, += and -+ operators do _not* have this problem. Looking at the .tmLanguage file, I see that /= is defined differently (line 381), preceded in the regex by
(?<!\()
I don't understand the reason for this. Explanation?
49a55aa removed line numbers from the compiled output - I really prefer them for tracking down browser-side errors.
Any chance it was accidental?
starenka@kosmik2:~$ coffee -v
CoffeeScript version 1.1.2
starenka@kosmik2:~$ coffee
node.js:63
throw e;
^
Error: Cannot find module 'vm'
at loadModule (node.js:275:15)
at require (node.js:411:14)
at Object.<anonymous> (/usr/local/lib/coffee-script/lib/repl.js:6:12)
at Object.<anonymous> (/usr/local/lib/coffee-script/lib/repl.js:123:4)
at Module._compile (node.js:462:23)
at Module._loadScriptSync (node.js:469:10)
at Module.loadSync (node.js:338:12)
at loadModule (node.js:283:14)
at require (node.js:411:14)
at Object.run (/usr/local/lib/coffee-script/lib/command.js:47:14)
starenka@kosmik2:~$ node --version
v0.2.4
starenka@kosmik2:~$ which node
/usr/local/bin/node
starenka@kosmik2:~$ which coffee
/usr/local/bin/coffee
starenka@kosmik2:~$ echo $PATH
/home/starenka/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
I've started to find the "Go to Symbol" prompt to be extremely useful. Unfortunately, there are a lot of problem cases with it. It seems to treat :
and =
interchangeably everywhere (not just in a class
), so
a = -> b: ->
gives you
a
b
but
c = -> {d: ->}
gives you
c
d
Neither seems very sensible to me; functions in objects (other than class
prototypes) should be ignored, the way that functions given as callbacks are. Don't you think? Or is it more important to list every function that's assigned a symbol than to present a clean hierarchy? Keep in mind that the current behavior means that if you write
$('#item1').bind click: -> false
$('#item2').bind click: -> false
$('#item3').bind click: -> false
$('#item4').bind click: -> false
$('#item5').bind click: -> false
then you'll see "click" 5 times in the "Go to Symbol" list.
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.