Skip to content
BadBit Documentation
Sign in Download the beta

BadBit extension for VS Code

The BadBit extension for VS Code is the full editor for BadBit CAD programs in LISP and Python: you write in VS Code and run and debug inside the open BadBit CAD, watching the drawing change. (The simple editor that comes with the program, BadBit Scripts, is still there: type SCRIPTEDITOR or SED.)

What it does:

  • Run File and Run Selection (.lsp and .py) in the open BadBit, with the output in the BadBit panel and the error marked on the right line;
  • debugging: breakpoints, step into, over and out, the call stack, the variables and a stop on the error, in LISP and in Python;
  • in LISP: colors, parentheses, comments, completion of the functions and of the badbit-call operations, hover and parameter help, and a warning on the parenthesis that does not close;
  • in Python: completion of the badbit package (through Pylance).

Install

  1. Have BadBit CAD 2027.0.0-beta.8 or newer installed.
  2. In VS Code, open Extensions, search for BadBit (publisher BadBit Tecnologia e Desenvolvimento de Software LTDA) and click Install. The extension page in the store: https://marketplace.visualstudio.com/items?itemName=badbit.badbit. During the beta it is a pre-release: if the search does not show it, click Install Pre-Release Version, or in a terminal code --install-extension badbit.badbit --pre-release.
  3. In Cursor, VSCodium and other compatible editors, the same extension comes from the Open VSX store (search for BadBit).
  4. For Python completion, also have Microsoft's Python extension.

Connect to BadBit

  1. Open BadBit CAD.
  2. That's it: the extension finds BadBit by itself. Running and debugging need nothing turned on: they are your own code, like LISP in BadBit (the AI (MCP) switch in Options is only for AI assistants).

The extension talks only to the BadBit on your computer, through the local channel (the same as Python), with the secret key BadBit creates each time it opens. Nothing goes over the internet.

Run

  • Run File: the BadBit run button on the editor title (the green ▶ with the yellow dot), Ctrl+Alt+R (Cmd+Alt+R on Mac) or the right-click menu. It runs the text of the editor, also with unsaved changes, in the drawing open in BadBit (with only the Start tab showing, BadBit asks you to open a drawing).

Watch out for ▷ "Run Python File": in .py files, that button belongs to Microsoft's Python extension and runs the computer's Python, outside BadBit (it gives No module named 'badbit'). Use the BadBit button.

The first Python program downloads the Python of BadBit (only once, about 40 MB); the BadBit panel says "Downloading Python (only the first time)…" and the program runs when the download ends.

  • Run Selection: select the lines and press Ctrl+Alt+E (Cmd+Alt+E). In Python, the extension removes the common indentation of the lines.
  • Stop: Ctrl+Alt+. (Cmd+Alt+.), the "BadBit: running" status bar item, or Esc in BadBit itself.

What the program prints appears in the BadBit panel (Output). On an error, the message goes to the panel and the editor marks the line (in LISP, the line inside the function where the error happened; in Python, the line of the traceback).

  • The whole LISP file is one undo step in BadBit; in Python, each call of the badbit package is one step.
  • One program at a time: while one runs (from the extension or from BadBit Scripts), another one waits.

Debug

Open the .lsp or .py, click the margin to set breakpoints and press F5 (or Debug File in BadBit). The program runs inside BadBit and stops at the breakpoints:

  • Continue (F5), Step Over (F10), Step Into (F11), Step Out (Shift+F11), Pause;
  • the call stack (the user functions in LISP; the functions in Python);
  • the variables: in LISP, the parameters and locals of each function (/ a b) and the globals; in Python, the locals and globals, with lists and dictionaries expanded;
  • the Debug Console and hovering evaluate expressions while the program is stopped ((* x 2) in LISP, x * 2 in Python);
  • on an error, the program stops where it happened, with the variables of that moment; continuing ends the program (in LISP, *error* runs as always).

To keep the configuration, create .vscode/launch.json:

JSON
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "badbit",
      "request": "launch",
      "name": "Debug in BadBit",
      "program": "${file}",
      "stopOnEntry": false
    }
  ]
}

The Python debugger uses only the Python standard library (bdb): nothing to install.

LISP: completion and help

  • Start typing a function name ((strc) and pick it from the list: the signature and the description appear beside it. The functions of the file itself (defun) are included.
  • Hover a function to see its signature and description; hover an operation id in badbit-call to see what it does, its action type (reads the drawing, changes the drawing or acts outside the drawing) and its parameters.
  • Inside (badbit-call " the list shows the operations; inside the parameter list ('((") it shows the parameters of that operation.
  • A parenthesis that does not close (or closes without opening) and open quotes appear in Problems, at the right place.

The texts come from BadBit itself, in its language (the badbit.language setting changes it). The language server only reads the text of the files: it never runs anything.

Python: completion of the badbit package

The badbit package comes with BadBit and has type stub files. The extension adds its folder to python.analysis.extraPaths (in the user settings) and Pylance completes badbit.cad.layer.create(...) with the parameters and the documentation. If the folder is not found (Python has not been downloaded yet), run a Python script once in BadBit Scripts and use the Set Up Python Completion for the badbit Package command.

Settings

SettingWhat it is
badbit.executableThe BadBit CAD program, if it is not in the standard place.
badbit.discoveryFileThe discovery file of the local channel, if it is not in the standard place.
badbit.languageThe language of the language server and debugger messages (auto: the one of BadBit).
badbit.languageServer.enabledTurns the LISP language server on and off.
badbit.python.configureAnalysisAdds the badbit package to Pylance.
badbit.python.packagePathThe folder of the badbit package, if the extension does not find it.

Scripts: always available

Running and debugging from the extension always work, with nothing to turn on and nothing to accept, like BadBit Scripts, APPLOAD and the Python on your machine with the badbit package: they are your own code. The local channel always opens with the program, for your user only, and connected scripts do not show on the status bar.

AI (MCP): turning it on and the risk notice

BadBit's only switch is AI (MCP), in Options > AI (MCP) or with the AI button on the status bar: it lets AI assistants (including the VS Code assistant, over MCP) control BadBit and comes turned off. When you turn it on, BadBit shows what the AI can then do (everything you do in BadBit, and run Python and LISP code with your user's permissions) and the risks, and asks for the box I understand the risks and authorize it. It changes nothing for the extension. The details are in the MCP guide.

Security

  • Running and debugging are your own code and run with your user's permissions: only run programs from people you trust.
  • The connection is local (a socket only for your user on Mac and Linux; a protected pipe on Windows), with the secret key of each BadBit run.
  • The extension sends the text of the editor; a file asked for by its path needs an absolute path.
  • A debugging session belongs to the connection that opened it: another program cannot control it, and it ends if the connection drops.
  • In an untrusted VS Code workspace, the extension only colors LISP.

Other editors

The program comes with the language server and the debug adapter over the open protocols: badbit lsp (LSP) and badbit dap (DAP), over standard input and output. Any editor that speaks these protocols (Neovim, Emacs, Zed...) can use them with the same program.

Common problems

  • "BadBit CAD is not open": open BadBit CAD (there is nothing to turn on in it).
  • "A program is already running": wait for it to finish or stop it (Esc in BadBit or Stop in VS Code).
  • BadBit CAD was not found: set the program in badbit.executable.
  • A LISP breakpoint does not stop: the debugger stops on the lines of the file you ran; routines loaded from other files (load) run without stopping.
  • Python takes a while the first time: BadBit downloads Python the first time it needs it.
Search the documentation