Tape for Visual Studio Code
Language support for Tape, a compiled language
with a bytecode VM and native backends, components and source regions built in.
Features
- Syntax highlighting for every source region:
#code, #view, #style,
#resource, #test and #bytecode. String interpolation, #RRGGBB colour
literals, @tape / @emit compile-time blocks and @ builtins are
highlighted. Asset kinds such as icon and font are keywords only in
#resource, and test / setup / teardown only in #test.
- Diagnostics as you type. These are the same errors
tape check reports:
syntax, types, profile rules (t0/t1/t2) and imported modules.
- Hover answers for every name the compiler resolves: locals and
parameters in every scope (
for variables, match bindings, or { err }),
functions and methods (with *self or *const self), struct fields,
enum variants with their values and descriptions, component props and
events, module aliases, and another module's types, functions and
constants (fb.Framebuffer, serial.write). Types come from the type
checker, doc comments (// or /* */) from the declaring file. Built-in
types get a one-line description.
- Go to definition, including into imported modules and the standard library.
- Completion for keywords and declarations in the file. After
io. or
ui., it lists that module's public declarations.
- Outline and breadcrumbs. Components list their props, events and methods.
- Folding for each source region, for blocks and for comments.
Requirements
Highlighting works on its own. Diagnostics, hover, completion and navigation
come from tape-lsp, the language server that ships with tape.
Install tape
and the extension finds the server by itself:
| Install |
Where tape-lsp is |
| Windows / macOS / Linux archive |
next to tape (put that folder on PATH) |
apt (apt.tapelang.org) |
/usr/bin/tape-lsp |
The extension looks for the server in this order:
- the
tape.lsp.path setting
- next to the
tape found on PATH
tape-lsp on PATH
If none of these exists, the extension offers to open the install page.
Updating tape while VS Code runs
You can update or rebuild tape while VS Code is open. The language server
restarts on the new version by itself.
- Windows locks a running
.exe, so the extension never runs your
tape-lsp.exe itself. It runs a copy kept in the extension's storage
(for example
%APPDATA%\Code\User\globalStorage\puida.tape-language\servers\tape-lsp-<hash>.exe,
named by a hash of the file's contents) and tells it where your tape is
(--home), so it still uses that tape's standard library. Every VS Code
window running the same tape shares one copy. Old copies are deleted once
no window runs them.
- Linux and macOS can replace a running program, so the extension runs
tape-lsp from where it is installed.
On every platform the extension watches tape-lsp. When the file changes,
it waits until the new file has been completely written, then restarts the
server and notes this in the Tape output. Tape: Restart Language
Server does the same on demand: it finds the server again and copies it
again if it has changed. The same applies to a server you set with
tape.lsp.path.
Settings
| Setting |
Default |
|
tape.lsp.path |
"" |
Full path to tape-lsp, when it is not found automatically. |
tape.lsp.restartOnUpdate |
true |
Restart the language server when tape-lsp changes (tape was updated or rebuilt). |
tape.includePaths |
[] |
Directories searched for modules imported by bare name, before the standard library: the -I paths your build passes. Absolute, or relative to the workspace folder (${workspaceFolder} works). |
tape.trace.server |
"off" |
messages or verbose logs the protocol to the Tape output. |
Modules of your own project
import fb from "fb"; finds fb.tape the way tape build does: in the
include paths, then in the standard library, then next to the importing file. A
project that builds with -I for its own directories should list them in
tape.includePaths, for example in .vscode/settings.json:
{
"tape.includePaths": ["kernel/dev", "kernel/mem", "lib/font"]
}
Without the setting, the language server looks for a module it cannot
otherwise find in the workspace (the folder holding .git), and takes the
file of that name nearest the importing file. A module named like a standard
library module (process, io) is taken from the standard library unless
the setting lists its directory, except in a t0 module, which cannot
import the standard library's t1 modules.
Commands
- Tape: Restart Language Server: finds the server again and restarts it, for example after installing tape or changing
PATH. Updates to a server already in use are picked up without it.
- Tape: Show Output: shows server logs and startup problems.
Feedback
Report bugs and send questions through tapelang.org/contact.