dgrnbrg / vim-redl

A better Vim integration story for Clojure
106 stars 8 forks source link

very naive questions: Ritz? A kickstarter campaign? And thank you #26

Closed mascip closed 9 years ago

mascip commented 9 years ago

Hi David :) I'm just starting to use vim-redl and loving the Vim integration: the REPL, text editor, and debugger all in the same place. Amazing!

Apparently redl is not as feature-complete as Ritz (for example, I like the feature "break on exception"), so I was wondering why not integrate Ritz into vim, rather than integrate redl? Does redl provide something that Ritz does not? (could just be simple cleaner code). PS: I said it was a very naive (but genuine) question (^c^)

And an idea: if you did a Kickstarter campaign (or equivalent) to raise funds for a Vim integrated REPL, I guess you could accumulate enough funds to work on this full time for a while. There must be thousands of Clojure devs dreaming of an even better REPL for Vim. I have no idea whether it's something you would like to do; but I just wanted to say that it's something I would like to see happening. And thanks a lot for what you've produced already: coding Clojure has become even nicer than it already was.

If you need someone to try stuff out once in a while, just let me know.

dgrnbrg commented 9 years ago

Hi Pierre, thanks so much for your kind feedback! I'll happily answer your questions:

Ritz does have more features, and I've looked at integrating it with Vim. Essentially, the issue is that it's a lot more work to get all of those features, primarily in terms of the amount of new VimScript that'd need to be written. Ritz using the Java debugger API, which is a complex API with a lot of methods to make a useful debugger. Redl is implemented using macros and core.async, so it's much easier for me to write an API against, as I can do most of the heavy-lifting in Clojure instead, and just port vimclojure's repl to this new one.

Doing a Kickstarter is something I'm not interested in at the moment, because I have several other projects I'm focusing on. I am trying to every 2-4 months clear out the issues, and make sure things continue to work well in future versions for Clojure and popular libraries.

Thanks, David

mascip commented 9 years ago

Thanks for the explanation David!

I've watched this video where Hugo Duncan says that the Ritz debugger can be attached from anywhere including VimClojure. (he doesn't say that it's easy though...).

I've tried a very naive approach: I used the lein-ritz plugin, and did lein ritz-nrepl, which starts a Ritz REPL. Then I tried to :Connect but it didn't work.

I've also found slimv.vim which is Emac's SLIME for Vim (tutorial here). I've configured it to launch a REPL with lein ritz-nrepl. It does break on exceptions, and enables to launch the expression under the cursor in the REPL. It is embedded in a Vim buffer, just like vim-redl.

I haven't tried it extensively yet (and won't have the time this week), but it seems to give most features that vim-redl does, and possibly more. But I remember reading in many places that fireplace.vim is the place to go for Vim users, which makes me wonder:

what are the benefits of using fireplace.vim + redl + vim-redl, compared to using slimv.vim + lein-ritz?

It is a genuine question. I don't mean to undermine the work that has been done. Fireplace.vim is amazing and so is redl, and so far I've really benefited from using them. Just, as a user, I'm trying to understand the tradeoffs in order to choose a set of tools (I have started Clojure a month ago).

One of my beliefs is that tools built on a saner foundation can be more valuable than tools with more features. Because they are likely to

Let me know your thoughts :)

@tpope might be interested in this discussion.

I am ready to delete this message if you want me to (and/or happy for you to delete it yourself if you want)

PS: like I said, I'm away on holidays until Thursday so I won't be able to communicate very much until then.

mascip commented 9 years ago

One advantage of redl over ritz is much less dependencies. I had a few dependency conflicts to resolve, to get lein-ritz to work.

dgrnbrg commented 9 years ago

I agree that it'd be a great thing it integrate ritz, however, the majority of the work is in doing things like making vim commands for all the ritz commands, and making a good debugger interface (highlighting the current line, visualizing breakpoints and watchpoints, etc). That's a lot of work to integrate those things fully.

I think that fireplace is a better foundation than slimv, as fireplace is specially written to be a fully-featured nrepl client, which is going to be able to have much better integration than slimv, which isn't so specialized to clojure development.

mascip commented 9 years ago

Cheers!

fireplace is specially written to be a fully-featured nrepl client, which is going to be able to have much better integration than slimv, which isn't so specialized to clojure development.

Ah ok, I get this: fireplace.vim is for Clojure only, while slimv is for all Lisps. The next question is: what are the benefits of this? (present and future)

Is slimv not an nREPL client? It has a command to start a REPL, and with this command it can start a ritz REPL, which is based on nREPL... but slimv might connect to this REPL without using nREPL; is that the case?

If that is the case, then I'm left searching what are the benefits of a fully featured nREPL client. I've read a bit more about it. I found and guessed these benefits:

We might be able to steal a bit of code from slimv, to integrate ritz. But the real obstacle is to communicate with it through nREPL...which is a whole new thing to learn. This would happen in fireplace.vim, right?

If we used fireplace.vim to communicate with ritz, I'm guessing we would not need redl anymore? vim-redl would be replaced by vim-ritz?

I'm not saying any of this will ever happen, just wishful thinking =) Many questions in this message...

mascip commented 9 years ago

So, I've been trying to understand how all of this is connected. I've avoided to look at autocompletion, because it feels like an orthogonal concern.

fireplace.vim is an nREPL client. It will connect to some REPL server (could be a Ritz REPL), tell it to eval things, and retrieves the result.

redl is a debug REPL. It takes the code to be evaled, checks if there are any debug statements (like break) and takes over if that is the case. When that happens, there is no more interaction with the original nREPL: like I said, redl takes over. It then returns whatever was returned by the debugger. ng vim-redl connects fireplace.vim and redl.

In the redl#repl#eval(form) function it gets the code "evaled" by redl (which means that the redl debugger gets a chance to take over - it's not the same as getting code through a clojure REPL - the fact that it's also called eval is confusing), which returns a full_form (if no debugging took place, it's just the original form). This form is given to fireplace.vhm who will get it evaled through nREPL.

In the redl#repl#create(namespace) function, vim-redl uses fireplace.vim to evaluate the make-repl function of redl. It makes redl start a "supervisor": some sort of worker who will later asynchronously process the code to be checked. This code is later sent by the redl#repl#eval function explained in the previous paragraph.

So basically,

vim-redl is also responsible for creating the Vim buffer, Vim bindings, and all Vim-specific things.

If redl was turned into a middleware, does it mean that it could be programmed in Clojure rather than VimScript? Is this the relevant doc?

If I understand well, the Ritz debugger is itself an nREPL server (see the Ritz video that I pointed to, earlier). If we used it, I think we wouldn't need redl anymore? Instead we would have vim-ritz coordinating fireplace.vim and ritz? Damn, that's going to be another evening of reading code, for me to understand how that could work. And probably several evenings to just think...

Am I on the right track? What did I misunderstand?

dgrnbrg commented 9 years ago

Right, nREPL is just a prinipaled, Clojurish way to make a repl server--it is very flexible and extensible, in terms of functionality, encoding, and transport. That's why nREPL works via the browser, on a regular repl, and on other platforms.

You're correct about how redl and fireplace work. If redl was turned into a middleware, then potentially cider or fireplace could directly interact with redl. The only enhancement they'd need is being able to show the proper debug level.

To do this, you'd need to make redl play nicely with the session middleware, and implement the eval middleware function. You'd possibly need other functions as well: redl is designed to work better with vim by never blocking, even on long function evaluations. I'm not sure what the best way to unify this with cider would be, since cider can handle long blocking just fine.

mascip commented 9 years ago

Cheers for the explanation David :)

redl is designed to work better with vim by never blocking, even on long function evaluations.

Is this an advantage of redl over Ritz?

I've tried a bit to connect to a Ritz nREPL with fireplace.vim, but didn't manage. Will post an issue in vim-fireplace, to get tpope's feedback.

dgrnbrg commented 9 years ago

That is, sadly, going to be the easy part. The hard part is building the interface on the Vim side and connecting it up properly. Given that Ritz is built for an editor that support asynchronous calls, it'd be hard in pure vim.

Another possibility would be to use it with NeoVim, although I don't know the status of NeoVim nrepl client.

On Mon, Aug 11, 2014 at 9:46 AM, Pierre Masci notifications@github.com wrote:

Cheers for the explanation David :)

redl is designed to work better with vim by never blocking, even on long function evaluations. Is this an advantage of redl over Ritz?

I've tried a bit to connect to a Ritz nREPL with fireplace.vim, but didn't manage. Will post an issue in vim-fireplace, to get tpope's feedback.

— Reply to this email directly or view it on GitHub https://github.com/dgrnbrg/vim-redl/issues/26#issuecomment-51789741.

mascip commented 9 years ago

Thanks for your help David, I think my quest ends here. It was fun to try and understand all these tools :)

razum2um commented 9 years ago

@mascip as I understood the best solution for "break on exception" is slimv.vim + lein-ritz ? Please, don't delete your posts, instead, would you like to explain how to get these working?

mascip commented 9 years ago

No, I didn't manage to get slimv.vim break on exception. I manage to connect to a Ritz nREPL, but not to do anything Ritz-specific with it.

Like David explained, the next step is to build an interface for Ritz; that is, to send the right messages to this nREPL, and then do the right things with the responses. Which is near impossible because, as David explained, Vim is synchronous while Ritz was built for an editor that supports asynchronous calls.

-- Pierre Masci

On 24 August 2014 20:26, Vlad Bokov notifications@github.com wrote:

@mascip https://github.com/mascip as I understood the best solution for break on exception is slimv.vim + lein-ritz ? Please, don't delete your posts, instead, would you like to explain how to get these working?

— Reply to this email directly or view it on GitHub https://github.com/dgrnbrg/vim-redl/issues/26#issuecomment-53204066.

razum2um commented 9 years ago

actually it's wrong place for the topic, but I'll continue. I meant "break on exception" - happens in repl and some plugin could properly send commands to it. Actually the editor plugin is not important for me, I'd like to do as much REPL-driven as possible, there I hope to find some fully repl-driven debugger like I saw in ruby-MRI land - pry+debugger/byebug (it's awesome, trust me)