Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Nbb in VSCode extension
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require('vscode');
const path = require('path');
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
* @param {vscode.ExtensionContext} context
async function activate(context) {
const nbb = await import('nbb');
await import('nbb/lib/nbb_promesa.js');
globalThis.vscode = vscode;
const res = await nbb.loadFile(path.resolve(__dirname, 'script.cljs'));
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "borkdude" is now active!');
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
let disposable = vscode.commands.registerCommand('borkdude.helloWorld', res.command);
// this method is called when your extension is deactivated
function deactivate() {}
module.exports = {
(ns script
[clojure.edn :as edn]
[goog.string :as gstring]
[promesa.core :as p]))
(def vscode js/vscode)
(defn command []
(vscode.window.showInformationMessage "Hello world from nbb!")
(p/let [input (vscode.window.showInputBox #js {:placeHolder "Add these numbers"
:prompt "Add these numbers"})
input (gstring/format "[%s]" input)
input (edn/read-string input)
sum (apply + input)]
(vscode.window.showInformationMessage (str "The sum: " sum))))
#js {:command command}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment