– by Alex Gordon & Jean-Nicolas Jolivet
A wild update appears!
Good god, an update. I know, right? You thought Chocolat had gone the way of TM2? I don't blame you. It's been months since the last update.
We’ve had every delay imaginable, and what should've been a 1 month turnaround turned into 4 months.
But we’re back, and boy do we have an update for you.
Code completion galore
1.5 focuses on code completion. One of Chocolat's most beloved features is its handy HTML and CSS code completion. But not everybody is a web developer. We want awesome code completion in ALL the languages.
Unfortunately, it's not that easy (or the update would've been out months ago!). The reason our HTML code completion is so good is because it knows HTML. It knows which attributes go with which tags, which attributes can have values, which tags are most popular in real world code, which syntax to look out for so that it can show the code completion menu at exactly the right time.
To make awesome code completion, you need awesome special casing for each individual language. And that takes time.
Fortunately, I've had four months.
Python has the best support of the update, due to a mix of excellent language design and favouritism on my part.
Chocolat understands Python
Now when I go to use models, Chocolat knows what's inside.
Chocolat, obviously, knows about the whole Python standard library.
But wait there's more.
I spend most of my days zipping between Chocolat and looking up API documentation in the browser. It's such a huge waste of time. It's so easy to get distracted by something online: before you know it you're reading about sea urchins on wikipedia, when you originally just wanted to look up the arguments of a function.
Documentation is a big problem, and I don't hope to solve it in one go. But Chocolat 1.5 now has documentation popovers. It'll show you the documentation for the current class/method/function/etc.
Ruby poses some of its own unique problems. For one, there’s no
import statements like in Python. You don’t even have to
require a library in order to use it.
Chocolat does know about modules
(note that Chocolat can detect when you're using rails, so it doesn't depend on
require 'activerecord' except in untitled files)
Chocolat also knows about methods, though due to Ruby's love of duck typing and frequent use of monkey patching, it's pretty hopeless to guess which methods a given object has. My plan is to add some more heuristics to push the more likely methods up to the top.
Of course, Ruby gets the documentation popovers love as well
Chocolat’s already had good code completion for PHP for some time.
I haven't (yet) got around to writing a library indexer for PHP. Sorry!
What we do have are some of those nice documentation popovers for PHP. Needle-haystack? Haystack-needle? Now you needn't guess.
Say hi on #chocolat on freenode.net if you’d like to muck in.
As I said at the start, it’s my mission to add good code completion for every language possible.
We are somewhat limited by the fact that
- There’s only two of us!
- To add support for a language I have to learn it first. I learnt Ruby for this update.
So any help is welcome.
I did consider making completions available to the Chocolat JS API. However, I wasn’t happy with the performance, so we’re going to be sticking to pure Objective-C.
I hope you like this update. Normal weekly updates will resume promptly.
Image previews, reorder active files, subword movement
Just had enough time to squeeze in another update this week: 1.3.2.
Headline feature of the update is the ability to preview images. Selecting an image in the source list will show a preview:
One of the most requested changes has been to be able to drag-to-reorder active files.
Finally, you can now move between SubWords using ctrl-alt-left/right (it's also possible to use ctrl-left/right, though you must unbind it from spaces first).
Other changes include:
- You can now hide the line number bar.
- Code completion is no longer clipped if it reaches the bottom of the screen, but moves above the current line.
Full release notes here.
"Nothing selected" + CLI improvements
We've just pushed Chocolat 1.3.1. Here's a little of what's new:
Chocolat now shows a list of recently edited files if nothing else is open (previously it was just a boring gray rectangle).
There's also a search field to search the whole project, just like Go to File.
Additionally, we've made some improvements to the choc CLI tool:
- Pass the
--lineoption (or append a colon and the line number) to open the file at a particular line.
- Chocolat notifies you if choc is out of date.
- choc now creates intermediate directories if they don't already exist.
Full release notes here.
Chocolat + Node = ♥
Scripting Chocolat with Node.js
Every self-respecting text editor needs a scripting language. Vim has vimscript, Emacs has elisp and—as of version 1.3—Chocolat has Node.js!
Yep, you can script Chocolat using Node. It’s pretty cool:
We call these scripts Chocolat mixins.
So what have people been making?
Carter Allen is making a mixin to read serial output from an Arduino:
The pretty UIs are made using HTML and CSS. You can create windows, sheets and popovers, and show HTML in them.
Mixins are simply folders with the extension
.chocmixin and with an
init.js file inside. They can be put in either
~/.chocolat/mixins or Application Support. Since we’re using Node, you should place any dependencies in a
node_modules folder inside the mixin.
~/.chocolat/mixins └ helloworld.chocmixin ├ init.js ├ package.json └ node_modules
Of course, you shouldn’t have to know all this to be able to install mixins. So we put together mixins.chocolatapp.com so you can share your mixins with Chocolat users.
To add a mixin to the site, login via your GitHub account and select the repository that corresponds to the mixin you want to add. As soon as you’ve added the mixin, it will be visible inside Chocolat’s "Install Mixins" window (see Actions menu).
We’ve only started working on the API a month or so ago, so it’s bound to have a few rough edges.
We can’t wait to see what you will come up with!