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

[VsCoq1] Progress on #134: Use dune coq top (when enabled by a setting) #319

Closed
wants to merge 9 commits into from

Conversation

Blaisorblade
Copy link

@Blaisorblade Blaisorblade commented Dec 12, 2022

Address #134 for VsCoq1. The first commit fixes coq-community/vscoq-legacy#55.

This is a V0 prototype with some limitations, but it appears somewhat suitable for use.

  • There's no auto-detection of dune projects, but an explicit setting. Since it can be set per workspace, since most dune projects also have a _CoqProject file, and since dune coq top is probably somewhat experimental, I consider this sufficient for now.
  • If the build fails, this does not redirect build outputs/errors to some proper log window (beyond "Coq Language Server" logs).
  • User experience isn't great when dune decides to build code: a standard progress bar appears, but one must view "Coq Language Server" to understand what is happening.

What I tested was my integration branch — https://github.com/Blaisorblade/vscoq/tree/thread-count-option-misc.

Some unexpected messages appeared, but they seem due to the options added by dune coq top.

coqtop-stderr: Warning: Native compiler is disabled, -native-compiler ondemand option
ignored. [native-compiler-disabled,native-compiler]
Warning: The native-compiler option is deprecated. To compile native files
ahead of time, use the coqnative binary instead.
[deprecated-native-compiler-option,deprecated]

coqtop-stdout:Skipping rcfile loading.

The last one suggests that .coqrc is not being loaded, but it appears untrue — I used

Test Nested Proofs Allowed.
Test Ltac Backtrace.

to confirm my .coqrc settings were active.

"coqtop.binPath": {
"type": "string",
"default": "",
"description": "Path to coqtop and coqidetop binaries (alternatively, hoqtop and hoqidetop)."
"description": "Path to folder with coqtop and coqidetop binaries (alternatively, hoqtop and hoqidetop)."
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unrelated message improvement.

package.json Outdated Show resolved Hide resolved
@Blaisorblade Blaisorblade marked this pull request as ready for review December 17, 2022 20:14
@Blaisorblade
Copy link
Author

This isn't complete but I've been using it for a while (must still rebase over 0.3.7).

I'd like to ask what would be considered necessary. The lack of a decent progress dialog seems the most annoying problem...

@Blaisorblade Blaisorblade changed the title Use dune coq top (when enabled by a setting) Fix #134 for VsCoq1: Use dune coq top (when enabled by a setting) Feb 10, 2023
@Blaisorblade Blaisorblade changed the title Fix #134 for VsCoq1: Use dune coq top (when enabled by a setting) Progress on #134 for VsCoq1: Use dune coq top (when enabled by a setting) Feb 10, 2023
@Blaisorblade
Copy link
Author

Bug report: this still passes flags from _CoqProject to Coq. That's one I can fix.

@4ever2
Copy link
Contributor

4ever2 commented Feb 10, 2023

Doesn't this PR also fix coq-community/vscoq-legacy#55?

@Blaisorblade
Copy link
Author

Yep, thanks @4ever2

@Blaisorblade Blaisorblade force-pushed the dune-coq-top branch 3 times, most recently from ae99c7e to 8564194 Compare February 10, 2023 14:58
@thery
Copy link
Contributor

thery commented Feb 10, 2023

@Blaisorblade tell me when you think it is mergeable

@huynhtrankhanh
Copy link
Contributor

This PR is not ready to merge I guess. But one nitpick: why should we continue using var? We should use const and let, and prefer const whenever possible. var is function scoped, not block scoped like the other two keywords. This is very inconsequential for this PR though.

I'll probably review this PR more carefully later.

server/src/coqtop/CoqTop8.ts Outdated Show resolved Hide resolved
if (uri.scheme == "file")
return uri.fsPath;
else
return undefined
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new since last revision and enables stepping through unsaved files (but only outside dune coq top).

[this.settings.dunePath, ["coq", "top", "--toplevel=" + coqtopModule,
scriptPath, "--", ...coqArgs]] :
[coqtopModule, coqArgs]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huynhtrankhanh Since the code relied on var's scoping, this seems the smallest possible change.

Had to lift error checking since TS seems to lack statement expressions, but I guess that's not too bad. I guess function () { ... } () lets you encode them, but I wouldn't know if that's idiomatic.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, if anything seems silly it's because I'm not really a TypeScript dev and I was following existing idioms.

@Blaisorblade
Copy link
Author

I've done the main changes I planned, tried to address @huynhtrankhanh's comments, but I'll be retesting more later today.

@Blaisorblade
Copy link
Author

The latest changes seem to work, and I addressed @huynhtrankhanh 's comments, so I consider this ready for review and merging.

@thery
Copy link
Contributor

thery commented Feb 13, 2023

@Blaisorblade Perfect I will try to have a look at it today. Would be good if @huynhtrankhanh would give his opinion too

@@ -86,9 +86,12 @@ export class CoqProject {
this.coqProjectRoot = newSettings.coq.coqProjectRoot;
this.console.log("Updated project root to " + this.getCoqProjectRoot());
}
if(newSettings.coq.loadCoqProject ) {
if(newSettings.coq.loadCoqProject && !newSettings.coqtop.useDune) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this means that if your flag is not set, everything works like as before?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was my design goal :-).

@thery
Copy link
Contributor

thery commented Feb 13, 2023

@Blaisorblade I had a look, it seems ok.
As soon as @huynhtrankhanh is ok, we can merge

@huynhtrankhanh
Copy link
Contributor

huynhtrankhanh commented Feb 13, 2023

This PR looks perfect. I really appreciate your work. However, there's one issue: the configuration options! There are two options here, which should be mutually exclusive: coqtop.loadCoqProject and coqtop.useDune. I believe having two mutually exclusive options that could be set independently causes problems when we further build upon your work and makes it hard for users to predict the effect of their configuration. Should we have a single option that allows us to choose whether to load _CoqProject, use Dune or ignore both?

@thery
Copy link
Contributor

thery commented Feb 13, 2023

@huynhtrankhanh you would prefer a coqtop.configMode with the options coqproject or dune?

@Blaisorblade
Copy link
Author

Thanks for the review!

Should we have a single option that allows us to choose whether to load _CoqProject, use Dune or ignore both?

Good idea; that works for me. I'm afraid I can get back to it in a couple days.

Dropping "ignore both" as @thery suggests also seems plausible but has a slightly higher chances of regressions — does any user need to disable loadCoqProject? We should at least test projects with no _CoqProject file.

@maximedenes maximedenes changed the title Progress on #134 for VsCoq1: Use dune coq top (when enabled by a setting) [VsCoq1] Progress on #134: Use dune coq top (when enabled by a setting) Feb 14, 2023
@thery
Copy link
Contributor

thery commented Feb 18, 2023

@Blaisorblade @huynhtrankhanh I would like to make a new release beginning of march, do you think we can make this PR ready to merge by then?

This also allows stepping through unsaved files; before this patch, we passed
`-topfile untitled:Untitled-1`, which failed with:

```
coqtop-stderr: Error: Invalid character ':' in identifier "untitled:Untitled-1".
```
- Add `coqtop.useDune` and dune path to settings.
- spawnCoqTop: use dune coq top
- Skip `_CoqProject` when `useDune` is set.
- Address review: Switch new code to const as requested
@Blaisorblade
Copy link
Author

Sorry I'm late — I plan to address the comment next week, what I pushed just updates the extension for dune coq top changes (now dune wants relative paths, so we oblige).

@thery
Copy link
Contributor

thery commented Sep 28, 2023

what is the status of this PR?

@Blaisorblade
Copy link
Author

Sorry this hasn't progressed :-| ... Closing for now.

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

Successfully merging this pull request may close these issues.

vscoq passes incorrect -topfile argument
4 participants