Bun Repl
Closed this issue · 4 comments
Describe the language you want support for (compiler, specificities)
I'd like an interpreter for Typescript/Javascript that uses Bun bun repl
[and that work with detected filetypes javascript, typescript]...
Support Level to achieve
Any support is enough for me....
Additional context
Add any other context or screenshots about the feature request here.
I guess that you also want REPL capabilities within sniprun, as," it's possible to run a snippet declaring one variable, and then another one using it" ?
If so, I can implement that, but I'll need some time and luck
If you don't require REPL capabilities, it should be possible to get it running by yourself with the generic interpreter
Well, ofc REPL capability would be nice, but in the mean time, I tried to use the generic interpreter, but the Typescript_original runs instead.
my config:
config = function()
require("sniprun").setup({
interpreter_options = {
Generic = {
Bun = {
supported_filetypes = { "typescript" },
extension = ".ts",
interpreter = "bun repl",
compiler = "",
}
}
},
selected_interpreters = { 'Generic' },
})
end,
There is indeed an error in my current code driving behavior of sniprun when the Generic interpreter is used on a language that already has support. Something not too complex, but since you'll wait anyway I can make a proper TS/JS Bun intepreter... and maybe REPL-capable
So..
There is a fix for for the Generic interpreter issue, which should allow you to run the Generic interpreter with this config:
selected_interpreters = { 'Generic' },
interpreter_options = {
Generic = {
error_truncate="long",
Bun = {
supported_filetypes = { "typescript", "javascript" },
extension = ".ts",
interpreter = "bun run",
compiler = "",
}
}
},
I also made a "full-fledged" bun-based js/ts interpreter, but it doesn't bring much more than the generic config, except for .... a repl mode!
However, bun repl
itself is ..... very very janky about its stdin/stdout, most notably, the order is sometimes borked.
(simplified example with an intentionnal error 'le b=1':
echo "let a=1;console.log('start');a;le b=1;console.log('end')" | bun repl
.... blablah
> console.log('start')
> le b=1
× Expected ';', '}' or <eof>
╭─[$bun$repl.ts:1:1]
1 │ le b=1
· ─┬ ─
· ╰── This is the expression part of an expression statement
╰────
> a
> console.log('end')
start
end
1
So I expect low reliability on complex prompts
You can try these changes on the dev
branch (you'll need rust and sh ./install.sh 1
to compile locally sniprun), or wait for the 1.3.9 release that will probably happen next week