Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring vim-notebook for node #5

Open
jonahx opened this issue Jul 12, 2017 · 3 comments
Open

Configuring vim-notebook for node #5

jonahx opened this issue Jul 12, 2017 · 3 comments

Comments

@jonahx
Copy link

jonahx commented Jul 12, 2017

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!

@baruchel
Copy link
Owner

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
Copy link
Owner

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.

@jonahx
Copy link
Author

jonahx commented Jul 13, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants