vim-notebook icon indicating copy to clipboard operation
vim-notebook copied to clipboard

Configuring vim-notebook for node

Open jonahx opened this issue 8 years ago • 3 comments

I've tried the following configuration:

" attempt at node
let g:notebook_cmd = 'NODE_DISABLE_COLORS=1 node'
let g:notebook_stop = "process.exit()"
let g:notebook_send0 = ""
let g:notebook_send = "'VIMNODENOTEBOOK'"
let g:notebook_detect = "'VIMNODENOTEBOOK'"

Note that the final two lines reflect the fact that node echoes back quotes when literal strings are entered:

Node REPL

However, when I :NotebookStart, vim just hangs and needs to be killed. Do you know the correct settings for node? If not, any tips for debugging or what I might attempt to make it work?

Thanks!

jonahx avatar Jul 12 '17 13:07 jonahx

Hi, thank you for your interest; using it with Node actually is a good idea. I will have a look at it very soon unless you solve it before me. Most of the time issues are fixed by wrapping the main program in some unbuffer, stdbuf or even script for unbuffering its input/output. Regards.

baruchel avatar Jul 12 '17 14:07 baruchel

I got working settings though a little hacky. First, try to launch it with node -i (though I didn't check it was absolutely necessary). Then add the two characters of the prompt > (greater than followed by one space before the expected output); what I used was:

let g:notebook_sed='console.log(\"VIMNODENOTEBOOK\");'
let g:notebook_detect='> VIMNODENOTEBOOK'

because the prompt is merged with the output. Please, let me know if you get something working. Maybe there is a way to disable the prompt, which would be cleaner.

baruchel avatar Jul 13 '17 10:07 baruchel

Thanks. I got it working with that, but it still outputs the prompt, and, perhaps more difficult to address, it outputs the result of every line, including variable assignments. Probably what you want is for only console.log statements and the result of the final line in a code block to be shown. Any idea how difficult that change would be?

Also, if you do any node dev yourself, I just discovered this, which looks promising (though has the drawback of not existing within vim itself): https://runkit.com

jonahx avatar Jul 13 '17 17:07 jonahx