-
Notifications
You must be signed in to change notification settings - Fork 34
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
Better dune support #347
Better dune support #347
Conversation
Thanks, this looks like a great start.
I can look into making
I agree. I was thinking something like If you have the time and interest to continue working on this, feel free, but if not I could take it from here. Just let me know what parts, if any, you want to work on so we don't get in each other's way. |
Thanks! What you write makes sense. The remaining tasks all seem to require more advanced vim knowledge than I have, and I'll probably not have too much time in the next two weeks to play with that. So if you're happy to look into that, please feel free to take it from here! Of course, otherwise I'll also be happy to work on that once I get more time. |
I've got some time to work on this now. I think I'll look into adding the config options you suggested. |
a27cf3b
to
507c3da
Compare
I added two configuration flags:
I also tried to make |
I fixed an issue where stopping Coq (e.g. when dune or coqtop failed to start up correctly) would deadlock vim, due to a reentrancy issue with the channel implementation (?) when invoking Another issue I discovered, which I haven't fixed yet, is that commands (like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, this is looking great so far. I just did a quick pass and made a couple minor notes. I still need to take a closer look and test it more thoroughly, which I'll try to get to soon.
As for the issue with the commands that call coqtail#start()
, one option could be to pass them as a callback that only gets called if Coq is started successfully.
So instead of
if s:running() || coqtail#start() | cmd | endif
it could look something like
if s:running() | cmd | else | coqtail#start(string(cmd)) | endif
And then cmd
gets passed to coqtail#after_startCB
to be executed on success.
Thanks for reviewing! Sounds good, I'll make the change |
6d065e5
to
437a920
Compare
I made the change you suggested, and this seems to work now.
|
Is there anything I can do to make this easier to review (e.g. provide an example dune setup for an example project with instructions how to set it up, provide more documentation, etc.)? |
Sorry for the delayed response. I’ve been on vacation, but I’m back now and I’ll try to get to this by this weekend at the latest. Thanks for your patience. I have some sample projects I can test with, but if you have any test cases or workflows that might help check subtle corner cases, that would be appreciated. |
Thanks! No worries, hope you had a good vacation.
I mostly tested this on some projects I'm working on, for instance RefinedC. I encountered some corner cases recently which we should probably fix:
I'm not sure how to properly fix the first point. Maybe the functions we call in the |
I hacked around this by temporarily switching the buffer in the start callback, which seems to work fine for now: https://github.com/whonore/Coqtail/pull/347/files#diff-12174b01a001d27521768009705e83d295825ed51961111f5edb2f82662a8e3fR457
As a first step, I adapted the "interrupt" signal to also terminate the dune process, if it is currently running. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work really well for the most part. Aside from a couple minor style edits I made, I think the only real issue is how the after_start_cmd
argument is handled in coqtail#start
(see comments).
if switching the buffer while the asynchronous start is going on, things go wrong, as the after_startCB callback is executed in the context of the wrong buffer
I think your solution is good. A couple other parts of the code do basically the same thing to make sure things are executed in the right context.
if calling CoqToLine while Coq hasn't started yet, coqtail#toline will be called after the start has happened, and so the current line will be evaluated at that time and not at the time when CoqToLine was called. Probably we should evaluate this earlier in that case.
This is tricky because CoqToLine
passes 0
as the line by default, and then if coqtail#toline
sees that, it uses the cursor position, which may have changed since the command was called. I'm inclined to leave this for now and fix it only if it actually turns out to be an issue for people. We'd have to split each command into a "evaluate before CoqStart" and "evaluate after CoqStart" part, which would be annoying and error prone, and it just doesn't seem like that pressing an issue.
if calling CoqStop while CoqStart is running and dune is compiling dependencies, the dune process won't be properly stopped and keeps running until it succeeds. Probably we should kill it when receiving a stop signal
Calling interrupt
from coqtail#stop
before calling stop
might be a good idea. Additionally, Coqtop.stop
should probably kill the dune process if self.dune
is not None
. But the current implementation seems to work well from what I've seen. Interrupting Coq is pretty janky in general.
Thanks for the review and the comment!
Okay, sounds good.
I think with the current implementation, the python I've implemented this and it seems to work fine. I had to add a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgaeher Great work on this. Everything looks good to me now, so if you can just confirm that it still works on your end after my minor changes I can go ahead and merge it.
Co-authored-by: Wolf Honore <wolfhonore@gmail.com>
bbaa771
to
1fcf198
Compare
Yes, looks great! Everything still works for me. Thanks! |
This adds better support for dune, see #344.
Current caveats:
start
non-blocking?For making
CoqStart
non-blocking, I don't really have any idea how to implement that, but it would be pretty nice to have (or even just emit a message that dependencies are being compiled).Alternatively, we could also pass
--no-build
to dune, which skips building the dependencies. That would mirror the current behavior for_CoqProject
.Maybe there should also be a configuration option to enable/disable calling
dune
at all?