tpope / vim-fireplace

fireplace.vim: Clojure REPL support
https://www.vim.org/scripts/script.php?script_id=4978
1.74k stars 139 forks source link

Add g:fireplace_cljs_repl_option to control default CLJS REPL #328

Closed Deraen closed 5 years ago

Deraen commented 5 years ago

I find it inconvenient that if I accidentally hit cpp in .cljs files, or when using omnicomplete, when I don't have browser repl connection set up, Vim stops for few seconds opening up Nashorn REPL, so I'd like to have option to disable default Nashorn REPL creation.

Cljs also nowadays supports many other REPL environments, like Node.js, Graal.JS and Rhino so I think it would be good idea to provide option to control this.

tpope commented 5 years ago

The need for arguments in #326 points to a simple string option instead: "(foo.bar/baz "quux")". An empty string could be used to disable.

Deraen commented 5 years ago

What about calling require? Currently ns and fn name are separate to it is easy to call require for the ns part.

I guess the value could be something like (do (require 'cljs.repl.nashorn) (resolve 'cljs.repl.nashorn/repl-env)), does this make sense?

326 also point to having to replace Piggieback cljs-repl with figwheel.main.api/cljs-repl:

https://github.com/tpope/vim-fireplace/blob/master/plugin/fireplace.vim#L323-L325 But I'm not sure if that is correct.

tpope commented 5 years ago

Yeah I guess the do variant is acceptable.

Deraen commented 5 years ago

Okay, this is now reworked to use single string option.

tpope commented 5 years ago

I missed the resolve nastiness. Could we do something like let ns = matchstr(var, '^(\zs[^/]\+\ze/') or is that getting too convoluted?

Deraen commented 5 years ago

Sorry about forgetting this.

I'm not sure if we should just allow qualified symbols and then parse the namespace from that automatically, or if providing custom code (e.g. require and resolve, or something else) is required in some cases. Simplest solution might be to even only take the namespace as option, because the name is repl-env in all cases I know.

One benefit from taking Clojure code as the option value is, that it allows repl env options, like :port 1234.

tpope commented 5 years ago

I know this is a long shot, but is there any way we can figure out the port automatically? Ages ago I made rails.vim automatically find the port of the web server by querying lsof or netstat with the server pid, and hoo boy that was a godsend when dealing with multiple apps.