FutureBlitz for VS Code
FutureBlitz (.fb) in VS Code: highlighting, the FutureBlitz logo as .fb files' icon, the language
server's errors as you type and formatting on save, tasks for fb build, fb run, fb test, and
fb fmt, and debugging through CodeLLDB. The design is in
docs/tooling.md.
What it needs
- fb:
futureblitz.path, else fb on PATH, else ~/.futureblitz/bin.
- The language server,
fb-lsp: futureblitz.lspPath, else beside fb, else on PATH. Without
it, highlighting, tasks, and debugging still work.
- CodeLLDB (
vadimcn.vscode-lldb), which VS Code installs with the extension, for debugging
on every OS.
- A trusted workspace: fb-lsp runs a package's build step, a program in the workspace, so in
Restricted Mode, a workspace VS Code doesn't trust, the extension stays off.
Using it
Completion knows where it is: what the code wants there first (a call's argument's type,
an initializer's, a Return's, an Enum's members where one is wanted), the parameters' names a
call doesn't give yet, the keywords that go there, and the names of modules the file doesn't
import, which add the Import when chosen. After a value's ., .if, .ifnull, .for,
.not, .try, and .local write it into what they say, and in a Class's body, the Methods
it can override or implement are written out. VS Code's own word suggestions are off for .fb
files, so the language server's are what's shown.
Fixes and inspections: an error's likely fixes are quick fixes (the Import a name needs, a
name spelled nearly so, Try for a call that throws, what nothing declares written out, a
missing End or Return, and more), and the inspections' warnings come with theirs: what nothing
uses or reaches is faded, with a fix that removes it, and a name that hides another, an As that
changes nothing, and a condition that's always True or False are reported. A warning's code is
its lint, which project.toml's [lints] turns off or makes an error.
Refactorings: a selection can be extracted to a Local, a Function, or a Method, and a
Local or a Function's call inlined, from the light bulb or Refactor...; Source Action...
organizes Imports, sorted and without unused ones, and "editor.codeActionsOnSave": { "source.organizeImports": "explicit" } does it on save. FutureBlitz: Change Signature, in the
editor's context menu, reorders, renames ("new: Type <- old"), takes out, and adds ("name:
Type = value") a Function's or Method's parameters, changing every call. Each is offered only
where the code does the same after it.
Reading code: inlay hints show the types of Locals, For variables, and lambda parameters
where none is written, and the parameters' names at a call's arguments (each a setting). A
name's other uses in its file are highlighted, reads and writes apart; blocks, each If branch,
Select Case, and Catch, runs of comments, and Import lines fold; Expand Selection grows by
expressions and statements. Go to Type Definition, Go to Implementations (an Interface's
Classes and Structs, a Class's subclasses, a Method's overrides), Show Call Hierarchy, and Show
Type Hierarchy work across the package, and a count of references sits above each type and
function.
Tests: the Testing panel lists each file's @Test Functions, and runs or debugs a file's or
one test's, with their buttons in the gutter too: a run is fb test --exact with each test's
name, and a debug run
builds the tests' executable with fb test -o and runs it under CodeLLDB. A program's main file
has Run and Debug above its first line.
Run and Debug are in the editor's title bar on a .fb file, and in the Command Palette as
FutureBlitz: Run, FutureBlitz: Debug, and FutureBlitz: Run Tests. Each takes the open file's
package, the folder with the project.toml above it, or the file itself without one.
Tasks: Terminal > Run Task > fb lists build, run, test, fmt, and check for the workspace
folder's package and for the open file. Their errors, and a program's panics and failed
Expects, go to Problems. In tasks.json:
{
"type": "futureblitz",
"command": "run",
"target": "game",
"release": true,
"programArgs": ["--level", "2"]
}
Debugging: F5 debugs the open file's package, or the file. A launch.json configuration:
{
"type": "futureblitz",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}",
"args": [],
"stopOnEntry": false
}
It builds the program in debug, then CodeLLDB runs it with fb's lldb script, which shows
Strings, arrays, Maps, nullables, and objects as their values. CodeLLDB's own settings, like
env or preRunCommands, go in the same configuration.
AI assistants: Copilot's agent mode gets fb mcp's tools without setup, for the first
workspace folder's package: searching the language's spec and std's reference, looking up a
name, checking code and reading its errors, and formatting code. Where VS Code starts MCP
servers, it's the FutureBlitz server in MCP: List Servers; elsewhere, they're the tools
#fbDocs, #fbLookup, #fbCheck, and #fbFormat. Other assistants run fb mcp in the
package's folder themselves, and read the AGENTS.md fb new writes.
project.toml: fb's errors as you type, completion of its tables and keys, and of a
dependency's name and version from its registry, hover with what each key is and a
dependency's description and newest version, and quick fixes to update a dependency or add
what fb publish needs. Offline, the registries' answers are the cache's.
When the server stops answering
A save never waits long on fb-lsp: formatting, and source.* actions such as
source.organizeImports on save, have 2 seconds, then the save goes on without them and a
notice says so. VS Code doesn't tell an extension whether a save asked for formatting, so Format
Document has the same limit. The extension asks fb-lsp if it's answering every 10 seconds. With no
answer for 15 seconds, or as soon as a message from it can't be read, it restarts the server and
says so. After three restarts in 3 minutes it stops trying and says so, and
FutureBlitz: Restart Language Server starts it again.
Settings
| Setting |
|
futureblitz.path |
fb; ${workspaceFolder} and ~ are expanded |
futureblitz.lspPath |
the language server |
futureblitz.lsp.enabled |
start the language server; on by default |
futureblitz.inlayHints.types |
show the types the code doesn't write; on by default |
futureblitz.inlayHints.parameterNames |
show the parameters' names at calls; on by default |
futureblitz.trace.server |
trace its messages in the FutureBlitz output |
futureblitz.debug.lldbScript |
fb's futureblitz.py; beside fb, else the extension's copy |
In the FutureBlitz repo itself, fb from the CMake build folder is
"futureblitz.path": "${workspaceFolder}/cmake-build-debug/cli/fb.exe".
Building and installing
With Node 22 or newer:
cd editors/vscode
npm ci
npm run package # futureblitz.vsix
code --install-extension futureblitz.vsix
npm run compile type-checks into out/, which the tests use, bundles the extension into
dist/extension.js with esbuild, writes THIRD-PARTY-NOTICES from what's bundled, and copies
tools/lldb/futureblitz.py and the license in. To work on the extension, open editors/vscode in VS
Code and run it with F5's Extension Development Host, with npm run watch bundling each edit
(npm run watch:tests type-checks them into out/).
Tests
npm test # compile, the unit tests, then the extension tests
npm run test:unit # the grammar, language configuration, snippets, and helpers, in Node
npm run test:extension # the extension in VS Code, through @vscode/test-electron
FUTUREBLITZ_FB=<path to fb> runs the tests that build programs, and
FUTUREBLITZ_LSP=<path to fb-lsp> those of the real server's diagnostics and formatting;
without them they're skipped.
- The extension tests download VS Code, the oldest version package.json takes, into
.vscode-test/;
FB_VSCODE_VERSION=stable picks another, and FB_VSCODE_EXECUTABLE runs an
installed one. They run twice, on a workspace of three folders and then with no folder open. A
stand-in for CodeLLDB records each launch, and a stand-in language server formats.
- The grammar's tests are vscode-tmgrammar-test's assertion files, test/grammar/.fb, and its
snapshots of real std and tests/programs code, test/grammar/snap/.fb.snap.
UPDATE_SNAPSHOTS=1 npm run test:unit writes the snapshots again; read what changed before
committing them. node scripts/tokens.mjs <file.fb> prints how the grammar scopes a file.
FUTUREBLITZ_LLDB names an lldb with Python, for the test that it loads fb's script.
Publishing
To the VS Code Marketplace and Open VSX, under the futureblitz publisher, once its accounts
exist: npx vsce publish and npx ovsx publish futureblitz.vsix.
| |