kaku for VS Code
Write .kaku
drawings in VS Code. You get:
- Syntax highlighting. Keywords, layer names, options, colours,
{token} references, gradients, strings and comments are highlighted, and
folding follows indentation.
- Live preview. A
.kaku file opens as its preview. The <> button
in the preview's toolbar opens the code beside it, and so does clicking a
layer. To open a file as code, use Reopen Editor With… › Text Editor;
to make that the default, set workbench.editorAssociations to
{"*.kaku": "default"}. From the code, kaku: Open Preview to the Side
(⌘K V, or the preview button in the editor title bar) brings
the preview back. The drawing re-renders as
you type, even before you save. The toolbar has a page / board picker,
the drawing's themes (as buttons when there are two or three, otherwise
a menu), a problems badge that opens the Problems panel, a checkerboard
for transparent areas and a button back to the source. The status bar
shows the render time, the drawing's size and the canvas position under
the pointer.
- Canvas. The preview is a canvas you move around like a design
tool's: pinch or ⌘/Ctrl + scroll zooms around the pointer, scrolling (two
fingers, or Shift + wheel for sideways) pans, and so does dragging with
Space held, with the middle button, or from the empty canvas
around the drawing. The zoom bar in the corner has Fit
(Shift+1) and 1:1 (Shift+0), and once the
drawing no longer fits, a minimap shows where the view is: click or drag
in it to move. The view stays put while the drawing re-renders.
- Click to source. Hover over the preview to see which layer is under
the pointer: it is outlined and tagged with its path and line. Click to
select its line in the editor, or double-click to jump there and start
typing. The other way round, the layers of the line the cursor is on are
outlined in amber with their size.
- Errors. When the drawing doesn't compile, a strip under the toolbar
gives the file, line and message with a button to go there, and the last
good image stays on screen, marked as stale.
- Lint as you type. Compile errors and
kaku lint findings (clipped
or hidden shapes, overflowing text, low contrast, uneven spacing and so
on) appear as problems on their lines.
- Colour swatches. A swatch and a colour picker next to every
#hex
colour.
Install
Search for kaku in the Extensions view, or install it from the
VS Code Marketplace:
code --install-extension loalf.kaku-lang
Each release also has it
as kaku-vscode.vsix, to install with Extensions › … › Install from
VSIX….
The extension runs the kaku command-line tool, so install that too, with
Homebrew or from the same release
(how):
brew install loalf/tap/kaku
The extension and kaku are released together and share version numbers:
use a kaku at least as new as the extension.
Settings
| Setting |
Default |
|
kaku.path |
kaku |
The kaku executable |
kaku.preview.updateOn |
change |
change re-renders as you type; save only when you save |
kaku.preview.delay |
300 |
How long to wait after the last change before re-rendering (ms) |
kaku.preview.scale |
2 |
Render scale (2 stays sharp on high-density screens) |
kaku.preview.maxSize |
4000 |
Longest side of the preview image, in pixels |
kaku.lint.enable |
true |
Show lint findings as problems |
kaku.lint.hints |
true |
Include hints, not only errors and warnings |
kaku.fonts.download |
true |
Let kaku download fonts it cannot find |
Fonts that kaku downloads, and any warnings about them, are logged in the
kaku output channel.
Development
cd vscode
npm install
npm run compile # or: npm run watch
npm run test:unit # the CLI glue, without VS Code
npm run test:integration # in a downloaded VS Code, against ../target/release/kaku
npm run package # kaku-lang-<version>.vsix
To try it out, open this folder in VS Code and press F5, or
install the .vsix with code --install-extension kaku-lang-<version>.vsix.
KAKU_PATH sets the kaku executable that the integration tests use.
| |